/**
  * parse_gateway_notification method, receives data from the payment gateway
  * @access private
  */
 function parse_gateway_notification()
 {
     /// PayPal first expects the IPN variables to be returned to it within 30 seconds, so we do this first.
     if ('sandbox' == get_option('paypal_certified_server_type')) {
         $paypal_url = "https://www.sandbox.paypal.com/webscr";
     } else {
         $API_Endpoint = "https://api-3t.paypal.com/nvp";
         $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
     }
     $received_values = array();
     $received_values['cmd'] = '_notify-validate';
     $received_values += stripslashes_deep($_POST);
     $options = array('timeout' => 20, 'body' => $received_values, 'httpversion' => '1.1', 'user-agent' => 'WP eCommerce/' . WPSC_PRESENTABLE_VERSION);
     $response = wp_safe_remote_post($paypal_url, $options);
     do_action('wpsc_paypal_express_ipn', $received_values, $this);
     if ('VERIFIED' == $response['body']) {
         $this->paypal_ipn_values = $received_values;
         $this->session_id = $received_values['invoice'];
         if (strtolower($received_values['payment_status']) == 'completed') {
             $this->set_purchase_processed_by_sessionid(3);
             transaction_results($this->session_id, false);
         } elseif (strtolower($received_values['payment_status']) == 'denied') {
             $this->set_purchase_processed_by_sessionid(6);
         }
     } else {
         exit("IPN Request Failure");
     }
 }
Exemple #2
0
 /**
  * Decide whether to send tracking data or not.
  *
  * @param bool $override
  */
 public static function send_tracking_data($override = false)
 {
     // Don't trigger this on AJAX Requests
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!self::is_allow_track()) {
         return;
     }
     if (!apply_filters('elementor/tracker/send_override', $override)) {
         // Send a maximum of once per week by default.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > apply_filters('elementor/tracker/last_send_interval', strtotime('-1 week'))) {
             return;
         }
     } else {
         // Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > strtotime('-1 hours')) {
             return;
         }
     }
     // Update time first before sending to ensure it is set
     update_option('elementor_tracker_last_send', time());
     // Send here..
     $params = ['system' => self::_get_system_reports_data(), 'site_lang' => get_bloginfo('language'), 'email' => get_option('admin_email'), 'usages' => ['posts' => self::_get_posts_usage(), 'library' => self::_get_library_usage()]];
     add_filter('https_ssl_verify', '__return_false');
     $response = wp_safe_remote_post(self::$_api_url, ['timeout' => 25, 'blocking' => false, 'body' => ['data' => wp_json_encode($params)]]);
 }
 /**
  * Validate a PDT transaction to ensure its authentic
  * @param  string $transaction
  * @return bool
  */
 protected function validate_transaction($transaction)
 {
     $pdt = array('body' => array('cmd' => '_notify-synch', 'tx' => $transaction, 'at' => $this->identity_token), 'timeout' => 60, 'httpversion' => '1.1', 'user-agent' => 'WooCommerce/' . WC_VERSION);
     // Post back to get a response
     $response = wp_safe_remote_post($this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $pdt);
     if (is_wp_error($response) || !strpos($response['body'], "SUCCESS") === 0) {
         return false;
     }
     return true;
 }
 /**
  * Performs an HTTP POST to the specified URL with the CSV
  *
  * @since 3.0
  * @param string $filename unused
  * @param string $csv the CSV to include the HTTP POST body
  * @throws Exception WP HTTP error handling
  */
 public function perform_action($filename, $csv)
 {
     $args = apply_filters('wc_customer_order_csv_export_http_post_args', array('timeout' => 60, 'redirection' => 0, 'httpversion' => '1.0', 'sslverify' => true, 'blocking' => true, 'headers' => array('accept' => 'text/csv', 'content-type' => 'text/csv'), 'body' => $csv, 'cookies' => array(), 'user-agent' => "WordPress " . $GLOBALS['wp_version']));
     $response = wp_safe_remote_post(get_option('wc_customer_order_csv_export_http_post_url'), $args);
     // check for errors
     if (is_wp_error($response)) {
         throw new Exception($response->get_error_message());
     }
     // log responses
     wc_customer_order_csv_export()->log(print_r($response, true));
 }
 private function executePayPalRequest($postData)
 {
     $args = array('body' => $postData, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => 'AffiliatesManager/' . WPAM_VERSION);
     $response = wp_safe_remote_post($this->apiEndPoint, $args);
     if (is_wp_error($response)) {
         throw new WPAM_PayPal_ServiceException(sprintf(__("POST failed\nerrors:\n%serrordata:\n%s", 'affiliates-manager'), print_r($response->errors, true), print_r($response->error_data, true)));
     } elseif (isset($response['response']['code']) && $response['response']['code'] == 200) {
         return $response['body'];
     }
     throw new WPAM_PayPal_ServiceException(sprintf(__('Unknown response: %s', 'affiliates-manager'), print_r($response, true)));
 }
function grav_paypal_sandbox_ipn_tester()
{
    if (!empty($_GET['ipn-test']) && current_user_can('manage_options')) {
        $response = wp_safe_remote_post('https://www.sandbox.paypal.com/cgi-bin/webscr', array('body' => array('test_ipn' => 1, 'cmd' => '_notify-validate')));
        if (!is_wp_error($response)) {
            wp_die('Test successful!  No changes need to be made.');
        } else {
            wp_die('Test failed.  You will need to update your hosting environment.  Failure response: ' . $response->get_error_message());
        }
    }
}
 /**
  * @param $url
  * @param $parameters
  *
  * @return array|bool
  * @throws Exception
  */
 function do_request($url, $args)
 {
     // request (http://websupporter.net/blog/wp_remote_get-vs-wp_safe_remote_get-2/)
     $response = wp_safe_remote_post($url, $args);
     $body = wp_remote_retrieve_body($response);
     // evaluate body
     if (is_array($response) && $response['response']['code'] === 200) {
         return $this->parse_downloadlinks($body);
     } else {
         throw new Exception(__('An error occurred while watermarking. Please check your BooXtream Dashboard: ', 'woocommerce_booxtream'));
     }
 }
 /**
  * Refund an order via PayPal.
  * @param  WC_Order $order
  * @param  float    $amount
  * @param  string   $reason
  * @return object Either an object of name value pairs for a success, or a WP_ERROR object.
  */
 public static function refund_transaction($order, $amount = null, $reason = '')
 {
     $raw_response = wp_safe_remote_post(self::$sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', array('method' => 'POST', 'body' => self::get_refund_request($order, $amount, $reason), 'timeout' => 70, 'user-agent' => 'WooCommerce/' . WC()->version, 'httpversion' => '1.1'));
     WC_Gateway_Paypal::log('Refund Response: ' . print_r($raw_response, true));
     if (empty($raw_response['body'])) {
         return new WP_Error('paypal-api', 'Empty Response');
     } elseif (is_wp_error($raw_response)) {
         return $raw_response;
     }
     parse_str($raw_response['body'], $response);
     return (object) $response;
 }
 /**
  * Refund an order via PayPal
  * @param  WC_Order $order
  * @param  float $amount
  * @param  string $reason
  * @param  boolean $sandbox
  * @return array|wp_error The parsed response from paypal, or a WP_Error object
  */
 public static function refund_order($order, $amount = null, $reason = '', $sandbox = false)
 {
     $response = wp_safe_remote_post($sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', array('method' => 'POST', 'body' => self::get_request($order, $amount, $reason), 'timeout' => 70, 'user-agent' => 'WooCommerce', 'httpversion' => '1.1'));
     if (is_wp_error($response)) {
         return $response;
     }
     if (empty($response['body'])) {
         return new WP_Error('paypal-refunds', 'Empty Response');
     }
     parse_str($response['body'], $response_array);
     return $response_array;
 }
Exemple #10
0
/**
 * Request a visitor be deleted via the WordPRess admin ajax path
 *
 * @access private
 * @since 3.8.14
 *
 * @param int $visitor_id
 *
 * @return boolean, true on success, false on failure
 *
 */
function wpsc_do_delete_visitor_ajax($visitor_id)
{
    $delete_visitor_nonce_action = 'wpsc_delete_visitor_id_' . $visitor_id;
    $wpsc_security = wp_create_nonce($delete_visitor_nonce_action);
    $response = wp_safe_remote_post(admin_url('admin-ajax.php'), array('method' => 'POST', 'timeout' => 15, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('action' => 'wpsc_delete_visitor', 'wpsc_visitor_id' => $visitor_id, 'wpsc_security' => $wpsc_security), 'cookies' => array()));
    if (is_wp_error($response)) {
        $result = false;
    } else {
        $result = true;
    }
    return $result;
}
Exemple #11
0
 /**
  * Sends a POST request with the given article and bundles.
  *
  * @param string $url
  * @param string $article
  * @param array $bundles
  * @param array $meta
  * @return mixed
  * @since 0.2.0
  */
 public function post($url, $article, $bundles = array(), $meta = null)
 {
     // Assemble the content to send
     $content = $this->build_content($article, $bundles, $meta);
     // Build the post request args
     $args = array('headers' => array('Authorization' => $this->sign($url, 'POST', $content), 'Content-Length' => strlen($content), 'Content-Type' => 'multipart/form-data; boundary=' . $this->mime_builder->boundary()), 'body' => $content);
     // Allow filtering and merge with the default args
     $args = apply_filters('apple_news_post_args', wp_parse_args($args, $this->default_args));
     // Perform the request
     $response = wp_safe_remote_post(esc_url_raw($url), $args);
     // Parse and return the response
     return $this->parse_response($response);
 }
 private static function send_to_zapier($target_url, $data)
 {
     if (strpos($target_url, 'zapier.com/hooks') === false) {
         return;
     }
     $headers = array();
     if (empty($data)) {
         $headers['X-Hook-Test'] = 'true';
     }
     $post_args = array('headers' => $headers, 'body' => wp_json_encode($data), 'timeout' => apply_filters('http_request_timeout', 15), 'sslverify' => false, 'ssl' => true);
     $resp = wp_safe_remote_post($target_url, $post_args);
     if ($resp) {
         // If 410 header than unsubscribe the zap
     }
 }
 /**
  * Check with PayPal whether posted data is valid IPN request.
  *
  * @throws Exception
  *
  * @param array $posted_data Posted data
  * @return bool True if posted_data is valid IPN request
  */
 public function is_valid_ipn_request(array $posted_data)
 {
     wc_gateway_ppec_log(sprintf('%s: %s', __FUNCTION__, 'Checking IPN request validity'));
     $ipn_request = array('cmd' => '_notify-validate');
     $ipn_request += wp_unslash($posted_data);
     $params = array('body' => $ipn_request, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => get_class($this->gateway));
     // Post back to PayPal to check validity of IPN request.
     $response = wp_safe_remote_post($this->get_validator_url(), $params);
     wc_gateway_ppec_log(sprintf('%s: %s: %s', __FUNCTION__, 'Verify IPN request', print_r($params, true)));
     wc_gateway_ppec_log(sprintf('%s: %s: %s', __FUNCTION__, 'Response for the IPN request', print_r($response, true)));
     if (is_wp_error($response)) {
         throw new Exception($response->get_error_message());
     }
     return $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED');
 }
function rcp_validate_captcha($data)
{
    global $rcp_options;
    if (!isset($rcp_options['enable_recaptcha']) || empty($rcp_options['recaptcha_public_key']) || empty($rcp_options['recaptcha_private_key'])) {
        return;
    }
    if (empty($data['g-recaptcha-response']) || empty($data['g-recaptcha-remoteip'])) {
        rcp_errors()->add('invalid_recaptcha', __('Please verify that you are not a robot', 'rcp'), 'register');
        return;
    }
    $verify = wp_safe_remote_post('https://www.google.com/recaptcha/api/siteverify', array('body' => array('secret' => trim($rcp_options['recaptcha_private_key']), 'response' => $data['g-recaptcha-response'], 'remoteip' => $data['g-recaptcha-remoteip'])));
    $verify = json_decode(wp_remote_retrieve_body($verify));
    if (empty($verify->success) || true !== $verify->success) {
        rcp_errors()->add('invalid_recaptcha', __('Please verify that you are not a robot', 'rcp'), 'register');
    }
}
 public function verify($response_token)
 {
     $is_human = false;
     if (empty($response_token)) {
         return $is_human;
     }
     $url = self::VERIFY_URL;
     $sitekey = $this->get_sitekey();
     $secret = $this->get_secret($sitekey);
     $response = wp_safe_remote_post($url, array('body' => array('secret' => $secret, 'response' => $response_token, 'remoteip' => $_SERVER['REMOTE_ADDR'])));
     if (200 != wp_remote_retrieve_response_code($response)) {
         return $is_human;
     }
     $response = wp_remote_retrieve_body($response);
     $response = json_decode($response, true);
     $is_human = isset($response['success']) && true == $response['success'];
     return $is_human;
 }
Exemple #16
0
 /**
  * IDX API Request
  */
 public function idx_api($method, $apiversion = Initiate_Plugin::IDX_API_DEFAULT_VERSION, $level = 'clients', $params = array(), $expiration = 7200, $request_type = 'GET', $json_decode_type = false)
 {
     $cache_key = 'idx_' . $method . '_cache';
     if ($this->get_transient($cache_key) !== false) {
         $data = $this->get_transient($cache_key);
         return $data;
     }
     $headers = array('Content-Type' => 'application/x-www-form-urlencoded', 'accesskey' => $this->api_key, 'outputtype' => 'json', 'apiversion' => $apiversion, 'pluginversion' => \Idx_Broker_Plugin::IDX_WP_PLUGIN_VERSION);
     if (function_exists('equity')) {
         if ($level === 'equity') {
             $equity_api_key = get_option('equity_api_key');
             $domain = site_url();
             $equity_headers = array('equitykey' => $equity_api_key, 'domain' => apply_filters('equity_idx_api_domain', $domain));
             $headers = array_merge($headers, $equity_headers);
         }
     }
     $params = array_merge(array('timeout' => 120, 'sslverify' => false, 'headers' => $headers), $params);
     $url = Initiate_Plugin::IDX_API_URL . '/' . $level . '/' . $method;
     if ($request_type === 'POST') {
         $response = wp_safe_remote_post($url, $params);
     } else {
         $response = wp_remote_get($url, $params);
     }
     $response = (array) $response;
     extract($this->apiResponse($response));
     // get code and error message if any, assigned to vars $code and $error
     if (isset($error) && $error !== false) {
         if ($code == 401) {
             $this->delete_transient($cache_key);
         }
         if ($level === 'equity' && $code == 401) {
             $equity_401_message = 'Also confirm you are using the same domain as on your IDX Broker account.';
             return new \WP_Error("idx_api_error", __("Error {$code}: {$error} {$equity_401_message}"));
         }
         return new \WP_Error("idx_api_error", __("Error {$code}: {$error}"));
     } else {
         $data = (array) json_decode((string) $response['body'], $json_decode_type);
         if ($request_type !== 'POST') {
             $this->set_transient($cache_key, $data, $expiration);
         }
         return $data;
     }
 }
 /**
  * @param  $mail
  * @param  $data
  * @return mixed
  */
 public function mwform_admin_mail($mail, $data)
 {
     if (empty($this->option['api']) && empty($this->option['room'])) {
         return $mail;
     }
     $mwwpform = get_post_meta($this->option['form'], 'mw-wp-form');
     $subject = $mail->subject !== '' ? $mail->subject : __('メールを受信しました。', $this->mo);
     $message[] = '===< Sender >=====================';
     $message[] = $mail->sender . ' < ' . $mail->from . ' >' . PHP_EOL;
     $message[] = '===<  Body  >=====================';
     $message[] = $mail->body !== '' ? $mail->body : __('なし(管理者宛メール設定が未設定な可能性があります。)', $this->mo);
     $message[] = '================================' . PHP_EOL;
     if (isset($mwwpform[0]['usedb']) && (int) $mwwpform[0]['usedb'] === 1) {
         $message[] = admin_url('/edit.php?post_type=mwf_' . $this->option['form']);
     }
     $message = sprintf('[info][title]%s[/title]%s[/info]', $subject, implode(PHP_EOL, $message));
     $args = array('headers' => array('X-ChatWorkToken' => $this->option['api']), 'body' => array('body' => $message));
     $remote = wp_safe_remote_post('https://api.chatwork.com/v1/rooms/' . $this->option['room'] . '/messages', $args);
     return $mail;
 }
 /**
  * Validate a PDT transaction to ensure its authentic.
  * @param  string $transaction
  * @return bool|array False or result array
  */
 protected function validate_transaction($transaction)
 {
     $pdt = array('body' => array('cmd' => '_notify-synch', 'tx' => $transaction, 'at' => $this->identity_token), 'timeout' => 60, 'httpversion' => '1.1', 'user-agent' => 'WooCommerce/' . WC_VERSION);
     // Post back to get a response.
     $response = wp_safe_remote_post($this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $pdt);
     if (is_wp_error($response) || !strpos($response['body'], "SUCCESS") === 0) {
         return false;
     }
     // Parse transaction result data
     $transaction_result = array_map('wc_clean', array_map('urldecode', explode("\n", $response['body'])));
     $transaction_results = array();
     foreach ($transaction_result as $line) {
         $line = explode("=", $line);
         $transaction_results[$line[0]] = isset($line[1]) ? $line[1] : '';
     }
     if (!empty($transaction_results['charset']) && function_exists('iconv')) {
         foreach ($transaction_results as $key => $value) {
             $transaction_results[$key] = iconv($transaction_results['charset'], 'utf-8', $value);
         }
     }
     return $transaction_results;
 }
 /**
  * Send the request to Stripe's API
  *
  * @param array $request
  * @param string $api
  * @return array|WP_Error
  */
 public static function request($request, $api = 'charges', $method = 'POST')
 {
     WC_Stripe::log("{$api} request: " . print_r($request, true));
     $response = wp_safe_remote_post(self::ENDPOINT . $api, array('method' => $method, 'headers' => array('Authorization' => 'Basic ' . base64_encode(self::get_secret_key() . ':'), 'Stripe-Version' => '2016-03-07'), 'body' => apply_filters('woocommerce_stripe_request_body', $request, $api), 'timeout' => 70, 'user-agent' => 'WooCommerce ' . WC()->version));
     if (is_wp_error($response) || empty($response['body'])) {
         WC_Stripe::log("Error Response: " . print_r($response, true));
         return new WP_Error('stripe_error', __('There was a problem connecting to the payment gateway.', 'woocommerce-gateway-stripe'));
     }
     $parsed_response = json_decode($response['body']);
     // Handle response
     if (!empty($parsed_response->error)) {
         if (!empty($parsed_response->error->param)) {
             $code = $parsed_response->error->param;
         } elseif (!empty($parsed_response->error->code)) {
             $code = $parsed_response->error->code;
         } else {
             $code = 'stripe_error';
         }
         return new WP_Error($code, $parsed_response->error->message);
     } else {
         return $parsed_response;
     }
 }
 /**
  * Check PayPal IPN validity
  */
 public function validate_ipn()
 {
     WC_Gateway_Paypal::log('Checking IPN response is valid');
     // Get received values from post data
     $validate_ipn = array('cmd' => '_notify-validate');
     $validate_ipn += wp_unslash($_POST);
     // Send back post vars to paypal
     $params = array('body' => $validate_ipn, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => 'WooCommerce/' . WC()->version);
     // Post back to get a response
     $response = wp_safe_remote_post($this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
     WC_Gateway_Paypal::log('IPN Request: ' . print_r($params, true));
     WC_Gateway_Paypal::log('IPN Response: ' . print_r($response, true));
     // check to see if the request was valid
     if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
         WC_Gateway_Paypal::log('Received valid response from PayPal');
         return true;
     }
     WC_Gateway_Paypal::log('Received invalid response from PayPal');
     if (is_wp_error($response)) {
         WC_Gateway_Paypal::log('Error response: ' . $response->get_error_message());
     }
     return false;
 }
Exemple #21
0
 public function toHTML()
 {
     global $wpdb, $guiform;
     echo '<div id="guiform-manager" class="wrap extension clearfix metabox-holder">';
     // data to send in our API request
     $this->navigation->toHTML();
     $output = get_transient('guiform_extension_content');
     if (!$output) {
         $api_params = array('content' => true, 'sslverify' => true, 'package' => GuiForm_Plugin::PACKAGE, 'version' => GuiForm_Plugin::VERSION, 'content' => 'extensions');
         // Call the custom API.
         $response = wp_safe_remote_post(GuiForm_Plugin::SERVER . "?api&", array('timeout' => 30, 'sslverify' => true, 'body' => $api_params));
         if (is_wp_error($response)) {
             delete_transient('guiform_extension_content');
         } else {
             $data = wp_remote_retrieve_body($response);
             set_transient('guiform_extension_content', $data, HOUR_IN_SECONDS);
             echo $data;
         }
     } else {
         echo $output;
     }
     echo '</div>';
 }
 /**
  * Decide whether to send tracking data or not
  *
  * @param boolean $override
  */
 public static function send_tracking_data($override = false)
 {
     // Dont trigger this on AJAX Requests
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!apply_filters('woocommerce_tracker_send_override', $override)) {
         // Send a maximum of once per week by default.
         $last_send = self::get_last_send_time();
         if ($last_send && $last_send > apply_filters('woocommerce_tracker_last_send_interval', strtotime('-1 week'))) {
             return;
         }
     } else {
         // Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links.
         $last_send = self::get_last_send_time();
         if ($last_send && $last_send > strtotime('-1 hours')) {
             return;
         }
     }
     // Update time first before sending to ensure it is set
     update_option('woocommerce_tracker_last_send', time());
     $params = self::get_tracking_data();
     $response = wp_safe_remote_post(self::$api_url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => false, 'headers' => array('user-agent' => 'WooCommerceTracker/' . md5(esc_url(home_url('/'))) . ';'), 'body' => json_encode($params), 'cookies' => array()));
 }
 /**
  * parse_gateway_notification method, receives data from the payment gateway
  * @access private
  */
 function parse_gateway_notification()
 {
     /// PayPal first expects the IPN variables to be returned to it within 30 seconds, so we do this first.
     $paypal_url = get_option('paypal_multiple_url');
     $received_values = array();
     $received_values['cmd'] = '_notify-validate';
     $received_values += stripslashes_deep($_POST);
     $options = array('timeout' => 20, 'body' => $received_values, 'httpversion' => '1.1', 'user-agent' => 'WP eCommerce/' . WPSC_PRESENTABLE_VERSION);
     $response = wp_safe_remote_post($paypal_url, $options);
     if (strpos($response['body'], 'VERIFIED') !== false) {
         $this->paypal_ipn_values = $received_values;
         $this->session_id = $received_values['invoice'];
     } else {
         exit("IPN Request Failure");
     }
 }
 /**
  * Send a test ping to the delivery URL, sent when the webhook is first created
  *
  * @since 2.2
  */
 public function deliver_ping()
 {
     $args = array('user-agent' => sprintf('WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version']), 'body' => "webhook_id={$this->id}");
     wp_safe_remote_post($this->get_delivery_url(), $args);
 }
/**
 * Send a Trackback.
 *
 * Updates database when sending trackback to prevent duplicates.
 *
 * @since 0.71
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $trackback_url URL to send trackbacks.
 * @param string $title Title of post.
 * @param string $excerpt Excerpt of post.
 * @param int $ID Post ID.
 * @return int|false|void Database query from update.
 */
function trackback($trackback_url, $title, $excerpt, $ID)
{
    global $wpdb;
    if (empty($trackback_url)) {
        return;
    }
    $options = array();
    $options['timeout'] = 10;
    $options['body'] = array('title' => $title, 'url' => get_permalink($ID), 'blog_name' => get_option('blogname'), 'excerpt' => $excerpt);
    $response = wp_safe_remote_post($trackback_url, $options);
    if (is_wp_error($response)) {
        return;
    }
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID));
    return $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID));
}
    $posting['gzip']['success'] = false;
    $posting['gzip']['note'] = sprintf(__('Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce'), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>');
}
// Multibyte String.
$posting['mbstring']['name'] = 'Multibyte String';
$posting['mbstring']['help'] = wc_help_tip(__('Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce'));
if (extension_loaded('mbstring')) {
    $posting['mbstring']['success'] = true;
} else {
    $posting['mbstring']['success'] = false;
    $posting['mbstring']['note'] = sprintf(__('Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce'), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>');
}
// WP Remote Post Check.
$posting['wp_remote_post']['name'] = __('Remote Post', 'woocommerce');
$posting['wp_remote_post']['help'] = wc_help_tip(__('PayPal uses this method of communicating when sending back transaction information.', 'woocommerce'));
$response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array('timeout' => 60, 'user-agent' => 'WooCommerce/' . WC()->version, 'httpversion' => '1.1', 'body' => array('cmd' => '_notify-validate')));
if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
    $posting['wp_remote_post']['success'] = true;
} else {
    $posting['wp_remote_post']['note'] = __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider.', 'woocommerce');
    if (is_wp_error($response)) {
        $posting['wp_remote_post']['note'] .= ' ' . sprintf(__('Error: %s', 'woocommerce'), wc_clean($response->get_error_message()));
    } else {
        $posting['wp_remote_post']['note'] .= ' ' . sprintf(__('Status code: %s', 'woocommerce'), wc_clean($response['response']['code']));
    }
    $posting['wp_remote_post']['success'] = false;
}
// WP Remote Get Check.
$posting['wp_remote_get']['name'] = __('Remote Get', 'woocommerce');
$posting['wp_remote_get']['help'] = wc_help_tip(__('WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce'));
$response = wp_safe_remote_get('https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . (is_multisite() ? '1' : '0'));
Exemple #27
0
    function view()
    {
        echo '<h2>' . __("Technical Information", "sp-cdm") . '</h2>' . sp_client_upload_nav_menu() . '';
        ?>
        
   <div class="sp-cdm-status-report">     
<div class="updated Client Document Manager-message">
	<p><?php 
        _e('Please copy and paste this information in your ticket when contacting support:', "sp-cdm");
        ?>
 </p>
	<p class="submit"><a href="#" class="button-primary debug-report"><?php 
        _e('Get System Report', "sp-cdm");
        ?>
</a>
</p>
	<div id="debug-report" style="display:none">
		<textarea readonly style="width:100%;height:400px"></textarea>
		<p class="submit"><button id="copy-for-support" class="button-primary" href="#" data-tip="<?php 
        _e('Copied!', "sp-cdm");
        ?>
"><?php 
        _e('Copy for Support', "sp-cdm");
        ?>
</button></p>
	</div>
</div>
<br/>
<table class="wc_status_table widefat" cellspacing="0" id="status">
	<thead>
		<tr>
			<th colspan="3" data-export-label="WordPress Environment"><?php 
        _e('WordPress Environment', "sp-cdm");
        ?>
</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td data-export-label="Home URL"><?php 
        _e('Home URL', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The URL of your site\'s homepage.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        form_option('home');
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Site URL"><?php 
        _e('Site URL', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The root URL of your site.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        form_option('siteurl');
        ?>
</td>
		</tr>
        		<tr>
			<td data-export-label="WP Version"><?php 
        _e('WP Version', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The version of WordPress installed on your site.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        bloginfo('version');
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="CDM Version"><?php 
        _e('CDM Version', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The version of Client Document Manager installed on your site.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo esc_html(get_option('sp_client_upload'));
        ?>
</td>
		</tr>
        <?php 
        if (get_option('sp_client_upload_premium') != false) {
            ?>
        <tr>
			<td data-export-label="CDM Premium Version"><?php 
            _e('CDM Premium Version', "sp-cdm");
            ?>
:</td>
			<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The version of Client Document Manager that the database is formatted for. This should be the same as your Client Document Manager Version.', "sp-cdm") . '"></a>';
            ?>
</td>
			<td><?php 
            echo esc_html(get_option('sp_client_upload_premium'));
            ?>
</td>
		</tr>
        <?php 
        }
        ?>
		
		<tr>
			<td data-export-label="Uploads Folder Writeable?"><?php 
        _e('Uploads Folder Writeable?', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('If your folder is not writable files will never make it to the server.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        if (@fopen(SP_CDM_UPLOADS_DIR . 'test-log.log', 'a')) {
            echo '<mark class="yes">' . 'Yes <code>' . SP_CDM_UPLOADS_DIR . ' is Writable!</code></mark> ';
        } else {
            printf('<mark class="error">' . '&#10005; ' . __('To upload properly, make <code>%s</code> writable or define a custom <code>SP_CDM_UPLOADS_DIR</code>.', "sp-cdm") . '</mark>', SP_CDM_UPLOADS_DIR);
        }
        ?>
</td>
		</tr>

		<tr>
			<td data-export-label="WP Multisite"><?php 
        _e('WP Multisite', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('Whether or not you have WordPress Multisite enabled.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        if (is_multisite()) {
            echo 'Yes';
        } else {
            echo 'No';
        }
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="WP Memory Limit"><?php 
        _e('WP Memory Limit', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The maximum amount of memory (RAM) that your site can use at one time.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        $memory = $this->let_to_num(WP_MEMORY_LIMIT);
        if ($memory < 67108864) {
            echo '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', "sp-cdm"), size_format($memory), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP') . '</mark>';
        } else {
            echo '<mark class="yes">' . size_format($memory) . '</mark>';
        }
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="WP Debug Mode"><?php 
        _e('WP Debug Mode', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('Displays whether or not WordPress is in Debug Mode.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        if (defined('WP_DEBUG') && WP_DEBUG) {
            echo '<mark class="yes">' . 'Yes' . '</mark>';
        } else {
            echo '<mark class="no">' . 'No' . '</mark>';
        }
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Language"><?php 
        _e('Language', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The current language used by WordPress. Default = English', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo get_locale();
        ?>
</td>
		</tr>
	</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0" id="status">
	<thead>
		<tr>
			<th colspan="3" data-export-label="Server Environment"><?php 
        _e('Server Environment', "sp-cdm");
        ?>
</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td data-export-label="Server Info"><?php 
        _e('Server Info', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('Information about the web server that is currently hosting your site.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo esc_html($_SERVER['SERVER_SOFTWARE']);
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="PHP Version"><?php 
        _e('PHP Version', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The version of PHP installed on your hosting server.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        // Check if phpversion function exists
        if (function_exists('phpversion')) {
            $php_version = phpversion();
            if (version_compare($php_version, '5.4', '<')) {
                echo '<mark class="error">' . sprintf(__('%s - We recommend a minimum PHP version of 5.4. See: <a href="%s" target="_blank">How to update your PHP version</a>', "sp-cdm"), esc_html($php_version), 'http://docs.woothemes.com/document/how-to-update-your-php-version/') . '</mark>';
            } else {
                echo '<mark class="yes">' . esc_html($php_version) . '</mark>';
            }
        } else {
            _e("Couldn't determine PHP version because phpversion() doesn't exist.", "sp-cdm");
        }
        ?>
</td>
		</tr>
		<?php 
        if (function_exists('ini_get')) {
            ?>
			<tr>
				<td data-export-label="PHP Post Max Size"><?php 
            _e('PHP Post Max Size', "sp-cdm");
            ?>
:</td>
				<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The largest filesize that can be contained in one post.', "sp-cdm") . '"></a>';
            ?>
</td>
				<td><?php 
            echo size_format($this->let_to_num(ini_get('post_max_size')));
            ?>
</td>
			</tr>
			<tr>
				<td data-export-label="PHP Time Limit"><?php 
            _e('PHP Time Limit', "sp-cdm");
            ?>
:</td>
				<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The amount of time (in seconds) that your site will spend on a single operation before timing out (to avoid server lockups)', "sp-cdm") . '"></a>';
            ?>
</td>
				<td><?php 
            echo ini_get('max_execution_time');
            ?>
</td>
			</tr>
			<tr>
				<td data-export-label="PHP Max Input Vars"><?php 
            _e('PHP Max Input Vars', "sp-cdm");
            ?>
:</td>
				<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The maximum number of variables your server can use for a single function to avoid overloads.', "sp-cdm") . '"></a>';
            ?>
</td>
				<td><?php 
            echo ini_get('max_input_vars');
            ?>
</td>
			</tr>
			<tr>
				<td data-export-label="SUHOSIN Installed"><?php 
            _e('SUHOSIN Installed', "sp-cdm");
            ?>
:</td>
				<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('Suhosin is an advanced protection system for PHP installations. It was designed to protect your servers on the one hand against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself. If enabled on your server, Suhosin may need to be configured to increase its data submission limits.', "sp-cdm") . '"></a>';
            ?>
</td>
				<td><?php 
            echo extension_loaded('suhosin') ? 'Yes' : 'No';
            ?>
</td>
			</tr>
		<?php 
        }
        ?>
		<tr>
			<td data-export-label="MySQL Version"><?php 
        _e('MySQL Version', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The version of MySQL installed on your hosting server.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td>
				<?php 
        /** @global wpdb $wpdb */
        global $wpdb;
        echo $wpdb->db_version();
        ?>
			</td>
		</tr>
		<tr>
			<td data-export-label="Max Upload Size"><?php 
        _e('Max Upload Size', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The largest filesize that can be uploaded to your WordPress installation.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo size_format(wp_max_upload_size());
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Default Timezone is UTC"><?php 
        _e('Default Timezone is UTC', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The default timezone for your server.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        $default_timezone = date_default_timezone_get();
        if ('UTC' !== $default_timezone) {
            echo '<mark class="error">' . '&#10005; ' . sprintf(__('Default timezone is %s - it should be UTC', "sp-cdm"), $default_timezone) . '</mark>';
        } else {
            echo '<mark class="yes">' . 'Yes' . '</mark>';
        }
        ?>
			</td>
		</tr>
		<?php 
        $posting = array();
        // fsockopen/cURL
        $posting['fsockopen_curl']['name'] = 'fsockopen/cURL';
        $posting['fsockopen_curl']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', "sp-cdm") . '"></a>';
        if (function_exists('fsockopen') || function_exists('curl_init')) {
            $posting['fsockopen_curl']['success'] = true;
        } else {
            $posting['fsockopen_curl']['success'] = false;
            $posting['fsockopen_curl']['note'] = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', "sp-cdm") . '</mark>';
        }
        // SOAP
        $posting['soap_client']['name'] = 'SoapClient';
        $posting['soap_client']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', "sp-cdm") . '"></a>';
        if (class_exists('SoapClient')) {
            $posting['soap_client']['success'] = true;
        } else {
            $posting['soap_client']['success'] = false;
            $posting['soap_client']['note'] = sprintf(__('Your server does not have the <a href="%s">SOAP Client</a> class enabled - some gateway plugins which use SOAP may not work as expected.', "sp-cdm"), 'http://php.net/manual/en/class.soapclient.php') . '</mark>';
        }
        // DOMDocument
        $posting['dom_document']['name'] = 'DOMDocument';
        $posting['dom_document']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', "sp-cdm") . '"></a>';
        if (class_exists('DOMDocument')) {
            $posting['dom_document']['success'] = true;
        } else {
            $posting['dom_document']['success'] = false;
            $posting['dom_document']['note'] = sprintf(__('Your server does not have the <a href="%s">DOMDocument</a> class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', "sp-cdm"), 'http://php.net/manual/en/class.domdocument.php') . '</mark>';
        }
        // GZIP
        $posting['gzip']['name'] = 'GZip';
        $posting['gzip']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('GZip (gzopen) is used to open the GEOIP database from MaxMind.', "sp-cdm") . '"></a>';
        if (is_callable('gzopen')) {
            $posting['gzip']['success'] = true;
        } else {
            $posting['gzip']['success'] = false;
            $posting['gzip']['note'] = sprintf(__('Your server does not support the <a href="%s">gzopen</a> function - this is required to use the GeoIP database from MaxMind. The API fallback will be used instead for geolocation.', "sp-cdm"), 'http://php.net/manual/en/zlib.installation.php') . '</mark>';
        }
        // WP Remote Post Check
        $posting['wp_remote_post']['name'] = __('Remote Post', "sp-cdm");
        $posting['wp_remote_post']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('PayPal uses this method of communicating when sending back transaction information.', "sp-cdm") . '"></a>';
        $response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array('timeout' => 60, 'user-agent' => 'Client Document Manager/', 'body' => array('cmd' => '_notify-validate')));
        if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
            $posting['wp_remote_post']['success'] = true;
        } else {
            $posting['wp_remote_post']['note'] = __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider.', "sp-cdm");
            if (is_wp_error($response)) {
                $posting['wp_remote_post']['note'] .= ' ' . sprintf(__('Error: %s', "sp-cdm"), wc_clean($response->get_error_message()));
            } else {
                $posting['wp_remote_post']['note'] .= ' ' . sprintf(__('Status code: %s', "sp-cdm"), wc_clean($response['response']['code']));
            }
            $posting['wp_remote_post']['success'] = false;
        }
        // WP Remote Get Check
        $posting['wp_remote_get']['name'] = __('Remote Get', "sp-cdm");
        $posting['wp_remote_get']['help'] = '<a href="#" class="help_tip" data-tip="' . esc_attr__('Client Document Manager plugins may use this method of communication when checking for plugin updates.', "sp-cdm") . '"></a>';
        $response = wp_safe_remote_get('http://www.woothemes.com/wc-api/product-key-api?request=ping&network=' . (is_multisite() ? '1' : '0'));
        if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
            $posting['wp_remote_get']['success'] = true;
        } else {
            $posting['wp_remote_get']['note'] = __('wp_remote_get() failed. The Client Document Manager plugin updater won\'t work with your server. Contact your hosting provider.', "sp-cdm");
            if (is_wp_error($response)) {
                $posting['wp_remote_get']['note'] .= ' ' . sprintf(__('Error: %s', "sp-cdm"), wc_clean($response->get_error_message()));
            } else {
                $posting['wp_remote_get']['note'] .= ' ' . sprintf(__('Status code: %s', "sp-cdm"), wc_clean($response['response']['code']));
            }
            $posting['wp_remote_get']['success'] = false;
        }
        $posting = apply_filters('Client Document Manager_debug_posting', $posting);
        foreach ($posting as $post) {
            $mark = !empty($post['success']) ? 'yes' : 'error';
            ?>
				<tr>
					<td data-export-label="<?php 
            echo esc_html($post['name']);
            ?>
"><?php 
            echo esc_html($post['name']);
            ?>
:</td>
					<td class="help"><?php 
            echo isset($post['help']) ? $post['help'] : '';
            ?>
</td>
					<td>
						<mark class="<?php 
            echo $mark;
            ?>
">
							<?php 
            echo !empty($post['success']) ? 'Yes' : 'No';
            ?>
							<?php 
            echo !empty($post['note']) ? wp_kses_data($post['note']) : '';
            ?>
						</mark>
					</td>
				</tr>
				<?php 
        }
        ?>
	</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0" id="status">
	<thead>
		<tr>
			<th colspan="3" data-export-label="Active Plugins (<?php 
        echo count((array) get_option('active_plugins'));
        ?>
)"><?php 
        _e('Active Plugins', "sp-cdm");
        ?>
 (<?php 
        echo count((array) get_option('active_plugins'));
        ?>
)</th>
		</tr>
	</thead>
	<tbody>
		<?php 
        $active_plugins = (array) get_option('active_plugins', array());
        if (is_multisite()) {
            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
        }
        foreach ($active_plugins as $plugin) {
            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
            $dirname = dirname($plugin);
            $version_string = '';
            $network_string = '';
            if (!empty($plugin_data['Name'])) {
                // link the plugin name to the plugin url if available
                $plugin_name = esc_html($plugin_data['Name']);
                if (!empty($plugin_data['PluginURI'])) {
                    $plugin_name = '<a href="' . esc_url($plugin_data['PluginURI']) . '" title="' . __('Visit plugin homepage', "sp-cdm") . '" target="_blank">' . $plugin_name . '</a>';
                }
                if (strstr($dirname, 'Client Document Manager-')) {
                    if (false === ($version_data = get_transient(md5($plugin) . '_version_data'))) {
                        $changelog = wp_safe_remote_get('http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt');
                        $cl_lines = explode("\n", wp_remote_retrieve_body($changelog));
                        if (!empty($cl_lines)) {
                            foreach ($cl_lines as $line_num => $cl_line) {
                                if (preg_match('/^[0-9]/', $cl_line)) {
                                    $date = str_replace('.', '-', trim(substr($cl_line, 0, strpos($cl_line, '-'))));
                                    $version = preg_replace('~[^0-9,.]~', '', stristr($cl_line, "version"));
                                    $update = trim(str_replace("*", "", $cl_lines[$line_num + 1]));
                                    $version_data = array('date' => $date, 'version' => $version, 'update' => $update, 'changelog' => $changelog);
                                    set_transient(md5($plugin) . '_version_data', $version_data, DAY_IN_SECONDS);
                                    break;
                                }
                            }
                        }
                    }
                    if (!empty($version_data['version']) && version_compare($version_data['version'], $plugin_data['Version'], '>')) {
                        $version_string = ' No <strong style="color:red;">' . esc_html(sprintf(_x('%s is available', 'Version info', "sp-cdm"), $version_data['version'])) . '</strong>';
                    }
                    if ($plugin_data['Network'] != false) {
                        $network_string = ' No <strong style="color:black;">' . __('Network enabled', "sp-cdm") . '</strong>';
                    }
                }
                ?>
				<tr>
					<td><?php 
                echo $plugin_name;
                ?>
</td>
					<td class="help">&nbsp;</td>
					<td><?php 
                echo sprintf(_x('by %s', 'by author', "sp-cdm"), $plugin_data['Author']) . ' No ' . esc_html($plugin_data['Version']) . $version_string . $network_string;
                ?>
</td>
				</tr>
				<?php 
            }
        }
        ?>
	</tbody>
</table>

<table class="wc_status_table widefat" cellspacing="0" id="status">
	<thead>
		<tr>
			<th colspan="3" data-export-label="Theme"><?php 
        _e('Theme', "sp-cdm");
        ?>
</th>
		</tr>
	</thead>
		<?php 
        $active_theme = wp_get_theme();
        if ($active_theme->{'Author URI'} == 'http://www.woothemes.com') {
            $theme_dir = substr(strtolower(str_replace(' ', '', $active_theme->Name)), 0, 45);
            if (false === ($theme_version_data = get_transient($theme_dir . '_version_data'))) {
                $theme_changelog = wp_safe_remote_get('http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt');
                $cl_lines = explode("\n", wp_remote_retrieve_body($theme_changelog));
                if (!empty($cl_lines)) {
                    foreach ($cl_lines as $line_num => $cl_line) {
                        if (preg_match('/^[0-9]/', $cl_line)) {
                            $theme_date = str_replace('.', '-', trim(substr($cl_line, 0, strpos($cl_line, '-'))));
                            $theme_version = preg_replace('~[^0-9,.]~', '', stristr($cl_line, "version"));
                            $theme_update = trim(str_replace("*", "", $cl_lines[$line_num + 1]));
                            $theme_version_data = array('date' => $theme_date, 'version' => $theme_version, 'update' => $theme_update, 'changelog' => $theme_changelog);
                            set_transient($theme_dir . '_version_data', $theme_version_data, DAY_IN_SECONDS);
                            break;
                        }
                    }
                }
            }
        }
        ?>
	<tbody>
		<tr>
			<td data-export-label="Name"><?php 
        _e('Name', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The name of the current active theme.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo $active_theme->Name;
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Version"><?php 
        _e('Version', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The installed version of the current active theme.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo $active_theme->Version;
        if (!empty($theme_version_data['version']) && version_compare($theme_version_data['version'], $active_theme->Version, '!=')) {
            echo ' No <strong style="color:red;">' . $theme_version_data['version'] . ' ' . __('is available', "sp-cdm") . '</strong>';
        }
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Author URL"><?php 
        _e('Author URL', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The theme developers URL.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo $active_theme->{'Author URI'};
        ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Child Theme"><?php 
        _e('Child Theme', "sp-cdm");
        ?>
:</td>
			<td class="help"><?php 
        echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('Displays whether or not the current theme is a child theme.', "sp-cdm") . '"></a>';
        ?>
</td>
			<td><?php 
        echo is_child_theme() ? '<mark class="yes">' . 'Yes' . '</mark>' : '&#10005; No ' . sprintf(__('If you\'re modifying Client Document Manager or a parent theme you didn\'t build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', "sp-cdm"), 'http://codex.wordpress.org/Child_Themes');
        ?>
</td>
		</tr>
		<?php 
        if (is_child_theme()) {
            $parent_theme = wp_get_theme($active_theme->Template);
            ?>
		<tr>
			<td data-export-label="Parent Theme Name"><?php 
            _e('Parent Theme Name', "sp-cdm");
            ?>
:</td>
			<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The name of the parent theme.', "sp-cdm") . '"></a>';
            ?>
</td>
			<td><?php 
            echo $parent_theme->Name;
            ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Parent Theme Version"><?php 
            _e('Parent Theme Version', "sp-cdm");
            ?>
:</td>
			<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The installed version of the parent theme.', "sp-cdm") . '"></a>';
            ?>
</td>
			<td><?php 
            echo $parent_theme->Version;
            ?>
</td>
		</tr>
		<tr>
			<td data-export-label="Parent Theme Author URL"><?php 
            _e('Parent Theme Author URL', "sp-cdm");
            ?>
:</td>
			<td class="help"><?php 
            echo '<a href="#" class="help_tip" data-tip="' . esc_attr__('The parent theme developers URL.', "sp-cdm") . '"></a>';
            ?>
</td>
			<td><?php 
            echo $parent_theme->{'Author URI'};
            ?>
</td>
		</tr>
		<?php 
        }
        ?>
		
	</tbody>
</table>
<?php 
        do_action('Client Document Manager_system_status_report');
        ?>

<script type="text/javascript">

	jQuery( 'a.help_tip' ).click( function() {
		return false;
	});

	jQuery( 'a.debug-report' ).click( function() {

		var report = '';

		jQuery( '#status thead, #status tbody' ).each(function(){

			if ( jQuery( this ).is('thead') ) {

				var label = jQuery( this ).find( 'th:eq(0)' ).data( 'export-label' ) || jQuery( this ).text();
				report = report + "\n### " + jQuery.trim( label ) + " ###\n\n";

			} else {

				jQuery('tr', jQuery( this ) ).each(function(){

					var label       = jQuery( this ).find( 'td:eq(0)' ).data( 'export-label' ) || jQuery( this ).find( 'td:eq(0)' ).text();
					var the_name    = jQuery.trim( label ).replace( /(<([^>]+)>)/ig, '' ); // Remove HTML
					var the_value   = jQuery.trim( jQuery( this ).find( 'td:eq(2)' ).text() );
					var value_array = the_value.split( ', ' );

					if ( value_array.length > 1 ) {

						// If value have a list of plugins ','
						// Split to add new line
						var output = '';
						var temp_line ='';
						jQuery.each( value_array, function( key, line ){
							temp_line = temp_line + line + '\n';
						});

						the_value = temp_line;
					}

					report = report + '' + the_name + ': ' + the_value + "\n";
				});

			}
		});

			jQuery( "#debug-report" ).slideDown();
			jQuery( "#debug-report textarea" ).val( report ).focus().select();
			jQuery( this ).fadeOut();
			return false;

		return false;
	});

	jQuery( document ).ready( function ( $ ) {
		$( '#copy-for-support' ).tipTip({
			'attribute':  'data-tip',
			'activation': 'click',
			'fadeIn':     50,
			'fadeOut':    50,
			'delay':      0
		});

		$( 'body' ).on( 'copy', '#copy-for-support', function ( e ) {
			e.clipboardData.clearData();
			e.clipboardData.setData( 'text/plain', $( '#debug-report textarea' ).val() );
			e.preventDefault();
		});

	});

</script>
</div>
        
        <?php 
    }
 /**
  * Get array of environment information. Includes thing like software
  * versions, and various server settings.
  *
  * @return array
  */
 public function get_environment_info()
 {
     global $wpdb;
     // Figure out cURL version, if installed.
     $curl_version = '';
     if (function_exists('curl_version')) {
         $curl_version = curl_version();
         $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
     }
     // WP memory limit
     $wp_memory_limit = wc_let_to_num(WP_MEMORY_LIMIT);
     if (function_exists('memory_get_usage')) {
         $wp_memory_limit = max($wp_memory_limit, wc_let_to_num(@ini_get('memory_limit')));
     }
     // Test POST requests
     $post_response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array('timeout' => 60, 'user-agent' => 'WooCommerce/' . WC()->version, 'httpversion' => '1.1', 'body' => array('cmd' => '_notify-validate')));
     $post_response_successful = false;
     if (!is_wp_error($post_response) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300) {
         $post_response_successful = true;
     }
     // Test GET requests
     $get_response = wp_safe_remote_get('https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . (is_multisite() ? '1' : '0'));
     $get_response_successful = false;
     if (!is_wp_error($post_response) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300) {
         $get_response_successful = true;
     }
     // Return all environment info. Described by JSON Schema.
     return array('home_url' => get_option('home'), 'site_url' => get_option('siteurl'), 'version' => WC()->version, 'log_directory' => WC_LOG_DIR, 'log_directory_writable' => @fopen(WC_LOG_DIR . 'test-log.log', 'a') ? true : false, 'wp_version' => get_bloginfo('version'), 'wp_multisite' => is_multisite(), 'wp_memory_limit' => $wp_memory_limit, 'wp_debug_mode' => defined('WP_DEBUG') && WP_DEBUG, 'wp_cron' => !(defined('DISABLE_WP_CRON') && DISABLE_WP_CRON), 'language' => get_locale(), 'server_info' => $_SERVER['SERVER_SOFTWARE'], 'php_version' => phpversion(), 'php_post_max_size' => wc_let_to_num(ini_get('post_max_size')), 'php_max_execution_time' => ini_get('max_execution_time'), 'php_max_input_vars' => ini_get('max_input_vars'), 'curl_version' => $curl_version, 'suhosin_installed' => extension_loaded('suhosin'), 'max_upload_size' => wp_max_upload_size(), 'mysql_version' => !empty($wpdb->is_mysql) ? $wpdb->db_version() : '', 'default_timezone' => date_default_timezone_get(), 'fsockopen_or_curl_enabled' => function_exists('fsockopen') || function_exists('curl_init'), 'soapclient_enabled' => class_exists('SoapClient'), 'domdocument_enabled' => class_exists('DOMDocument'), 'gzip_enabled' => is_callable('gzopen'), 'mbstring_enabled' => extension_loaded('mbstring'), 'remote_post_successful' => $post_response_successful, 'remote_post_response' => is_wp_error($post_response) ? $post_response->get_error_message() : $post_response['response']['code'], 'remote_get_successful' => $get_response_successful, 'remote_get_response' => is_wp_error($get_response) ? $get_response->get_error_message() : $get_response['response']['code']);
 }
 /**
  * Send a test ping to the delivery URL, sent when the webhook is first created.
  *
  * @since 2.2
  * @return bool|WP_Error
  */
 public function deliver_ping()
 {
     $args = array('user-agent' => sprintf('WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version']), 'body' => "webhook_id={$this->id}");
     $test = wp_safe_remote_post($this->get_delivery_url(), $args);
     $response_code = wp_remote_retrieve_response_code($test);
     if (is_wp_error($test)) {
         return new WP_Error('error', sprintf(__('Error: Delivery URL cannot be reached: %s', 'woocommerce'), $test->get_error_message()));
     }
     if (200 !== $response_code) {
         return new WP_Error('error', sprintf(__('Error: Delivery URL returned response code: %s', 'woocommerce'), absint($response_code)));
     }
     return true;
 }
 /**
  * Retrive the temp filename
  *
  * @param string $url      The package url
  * @param string $body     The post data fields
  * @param int    $timeout  Execution timeout (default: 300)
  *
  * @return string | The temp filename
  *
  * @since    1.0
  * @see      wp-admin/includes/class-wp-upgrader.php
  * @access  protected
  * @author   Andrea Grillo <*****@*****.**>
  */
 protected function _download_url($url, $body, $timeout = 300)
 {
     //WARNING: The file is not automatically deleted, The script must unlink() the file.
     if (!$url) {
         return new WP_Error('http_no_url', __('Invalid URL Provided.', 'yit'));
     }
     $tmpfname = wp_tempnam($url);
     $args = array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname, 'body' => $body);
     if (!$tmpfname) {
         return new WP_Error('http_no_file', __('Could not create Temporary file.', 'yit'));
     }
     $response = wp_safe_remote_post($url, $args);
     if (is_wp_error($response)) {
         unlink($tmpfname);
         return $response;
     }
     if (200 != wp_remote_retrieve_response_code($response)) {
         unlink($tmpfname);
         return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
     }
     $content_md5 = wp_remote_retrieve_header($response, 'content-md5');
     if ($content_md5) {
         $md5_check = verify_file_md5($tmpfname, $content_md5);
         if (is_wp_error($md5_check)) {
             unlink($tmpfname);
             return $md5_check;
         }
     }
     return $tmpfname;
 }