public function __construct() { self::$apisslverify = get_option('mainwp_api_sslVerifyCertificate') === false || get_option('mainwp_api_sslVerifyCertificate') == 1 ? 1 : 0; }
public function grab_license_key($api, $username, $password) { $options = get_option($api . "_APIManAdder"); if (!is_array($options)) { $options = array(); } $activation_status = isset($options['activated_key']) ? $options['activated_key'] : ""; $api_key = isset($options['api_key']) ? $options['api_key'] : ""; $api_email = isset($options['activation_email']) ? $options['activation_email'] : ""; if ($activation_status == 'Deactivated' || $activation_status == '' || $api_key == '' || $api_email == '') { $return = array(); if ($username != '' && $password != '') { $args = array('username' => $username, 'password' => $password, 'product_id' => $options['product_id'], 'instance' => $options['instance_id'], 'software_version' => $options['software_version'], 'platform' => $this->domain); $activate_results = json_decode(MainWPApiManagerKey::instance()->grabapikey($args), true); $options['api_key'] = ''; $options['activation_email'] = ''; $options['activated_key'] = 'Deactivated'; if (is_array($activate_results) && $activate_results['activated'] == true && !empty($activate_results['api_key'])) { $return['result'] = 'SUCCESS'; $mess = isset($activate_results['message']) ? $activate_results['message'] : ""; $return['message'] = __('Plugin activated. ', 'mainwp') . $mess; $options['api_key'] = $return['api_key'] = $activate_results['api_key']; $options['activation_email'] = $return['activation_email'] = $activate_results['activation_email']; $options['activated_key'] = 'Activated'; $options['deactivate_checkbox'] = 'off'; } else { if ($activate_results == false) { $return['error'] = __('Connection failed to the License Key API server. Try again later.', "mainwp"); } else { if (empty($activate_results['api_key'])) { $return['error'] = __('License key is empty.', "mainwp"); } else { $return['error'] = __('Undefined error.', "mainwp"); } } } if (isset($activate_results['code'])) { switch ($activate_results['code']) { case '100': case '101': case '102': case '103': case '104': case '105': case '106': $error = isset($activate_results['error']) ? $activate_results['error'] : ""; $info = isset($activate_results['additional info']) ? ' ' . $activate_results['additional info'] : ""; $return['error'] = $error . $info; break; } } MainWPUtility::update_option($api . "_APIManAdder", $options); return $return; } else { return array('error' => __('Username and Password is required to grab Extension API Key.', 'mainwp')); } } return array('result' => 'SUCCESS'); }