Exemplo n.º 1
0
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function create_software_api_url($args)
 {
     $api_url = esc_url_raw(add_query_arg('wc-api', 'am-software-api', MainWP_Api_Manager::instance()->getUpgradeUrl()));
     $query_url = '';
     foreach ($args as $key => $value) {
         $query_url .= $key . '=' . urlencode($value) . '&';
     }
     $query_url = rtrim($query_url, '&');
     return $api_url . '&' . $query_url;
 }
 private function create_upgrade_api_url($args)
 {
     $upgrade_url = esc_url_raw(add_query_arg('wc-api', 'upgrade-api', MainWP_Api_Manager::instance()->getUpgradeUrl()));
     $query_url = '';
     foreach ($args as $key => $value) {
         $query_url .= $key . '=' . urlencode($value) . '&';
     }
     $query_url = rtrim($query_url, '&');
     return $upgrade_url . '&' . $query_url;
     //http_build_query( $args );
 }
Exemplo n.º 4
0
 public static function getPluginInformation($pSlug)
 {
     $extensions = MainWP_Extensions::loadExtensions();
     $rslt = null;
     if (is_array($extensions)) {
         foreach ($extensions as $ext) {
             if ($pSlug == $ext['api'] && isset($ext['apiManager']) && !empty($ext['apiManager'])) {
                 $args = array();
                 $args['plugin_name'] = $ext['api'];
                 $args['version'] = $ext['version'];
                 $args['product_id'] = $ext['product_id'];
                 $args['api_key'] = $ext['api_key'];
                 $args['activation_email'] = $ext['activation_email'];
                 $args['instance'] = $ext['instance_id'];
                 $args['software_version'] = $ext['software_version'];
                 $rslt = MainWP_Api_Manager::instance()->request_plugin_information($args);
                 break;
             }
         }
     }
     return $rslt;
 }
Exemplo n.º 5
0
 public static function getPurchasedExts()
 {
     $username = trim($_POST['username']);
     $password = trim($_POST['password']);
     if ($username == '' || $password == '') {
         die(json_encode(array('error' => __('Login Invalid.', 'mainwp'))));
     }
     $data = MainWP_Api_Manager::instance()->get_purchased_software($username, $password);
     $result = json_decode($data, true);
     $return = array();
     if (is_array($result)) {
         if (isset($result['success']) && $result['success']) {
             $all_available_exts = array();
             $map_extensions_group = array();
             $free_group = array();
             foreach (MainWP_Extensions_View::getAvailableExtensions() as $ext) {
                 $all_available_exts[$ext['product_id']] = $ext;
                 $map_extensions_group[$ext['product_id']] = current($ext['group']);
                 // first group
                 if (isset($ext['free']) && !empty($ext['free'])) {
                     $free_group[] = $ext['product_id'];
                 }
             }
             self::loadExtensions();
             $installed_softwares = array();
             if (is_array(self::$extensions)) {
                 foreach (self::$extensions as $extension) {
                     if (isset($extension['product_id']) && !empty($extension['product_id'])) {
                         $installed_softwares[$extension['product_id']] = $extension['product_id'];
                     }
                 }
             }
             $purchased_data = isset($result['purchased_data']) && is_array($result['purchased_data']) ? $result['purchased_data'] : array();
             $not_purchased_exts = array_diff_key($all_available_exts, $purchased_data);
             $installing_exts = array_diff_key($purchased_data, $installed_softwares);
             //todo update to coding standards
             $all_groups = MainWP_Extensions_View::getExtensionGroups();
             $grouped_exts = array();
             foreach ($installing_exts as $product_id => $product_info) {
                 $item_html = '';
                 $software_title = isset($all_available_exts[$product_id]) ? $all_available_exts[$product_id]['title'] : $product_id;
                 if (isset($product_info['error']) && $product_info['error'] == 'download_revoked') {
                     $item_html = '<div><input type="checkbox" disabled="disabled"> <span class="name"><strong>' . $software_title . "</strong></span> <span style=\"color: red;\"><strong>Error</strong> " . MainWP_Api_Manager::instance()->download_revoked_error_notice($software_title) . '</span></div>';
                 } else {
                     if (isset($product_info['package']) && !empty($product_info['package'])) {
                         $package_url = apply_filters('mainwp_api_manager_upgrade_url', $product_info['package']);
                         $item_html = '<div class="extension_to_install" download-link="' . $package_url . '" product-id="' . $product_id . '"><input type="checkbox" status="queue" checked="true"> <span class="name"><strong>' . $software_title . "</strong></span> " . '<span class="ext_installing" status="queue"><i class="fa fa-spinner fa-pulse hidden" style="display: none;"></i> <span class="status hidden"><i class="fa fa-clock-o"></i> ' . __('Queued', 'mainwp') . '</span></span></div>';
                     }
                 }
                 $group_id = isset($map_extensions_group[$product_id]) ? $map_extensions_group[$product_id] : false;
                 if (!empty($group_id) && isset($all_groups[$group_id])) {
                     $grouped_exts[$group_id] .= $item_html;
                 } else {
                     $grouped_exts['others'] .= $item_html;
                 }
             }
             foreach ($not_purchased_exts as $product_id => $ext) {
                 $item_html = '<div class="extension_not_purchased" product-id="' . $product_id . '"><input type="checkbox" disabled="disabled"> <span class="name"><strong>' . $ext['title'] . '</strong></span> ' . __('Extension not purchased.', 'mainwp') . ' <a href="' . $ext['link'] . '" target="_blank">' . __('Get it here!', 'mainwp') . '</a>' . (in_array($product_id, $free_group) ? " <em>" . __('It\'s free.', 'mainwp') . "</em>" : '') . '</div>';
                 $group_id = isset($map_extensions_group[$product_id]) ? $map_extensions_group[$product_id] : false;
                 if (!empty($group_id) && isset($all_groups[$group_id])) {
                     $grouped_exts[$group_id] .= $item_html;
                 } else {
                     $grouped_exts['others'] .= $item_html;
                 }
             }
             //todo update coding standards
             $html = '<div class="inside">';
             $html .= '<h2>' . __('Install Purchased Extensions', 'mainwp') . '</h2>';
             $html .= '<div class="mainwp_extension_installing">';
             if (empty($installing_exts)) {
                 $html .= '<p>' . __('All purchased extensions are Installed', 'mainwp') . '</p>';
             } else {
                 $html .= '<p><span class="description">' . __('You have access to all purchased Extensions but you DO NOT need to install all off them. We recommend adding them one at a time, as you need them, so you do not experience information overload. Uncheck any Extension you do not want to install', 'mainwp') . '</span></p>';
                 $html .= '<div><a id="mainwp-check-all-ext" href="javascript:void(0);"><i class="fa fa-check-square-o"></i> ' . __('Select All', 'mainwp') . '</a> | <a id="mainwp-uncheck-all-ext" href="javascript:void(0);"><i class="fa fa-square-o"></i> ' . __('Select None', 'mainwp') . '</a></div>';
             }
             foreach ($all_groups as $gr_id => $gr_name) {
                 if (isset($grouped_exts[$gr_id])) {
                     $html .= '<h3>' . $gr_name . '</h3>';
                     $html .= $grouped_exts[$gr_id];
                 }
             }
             if (isset($grouped_exts['others'])) {
                 $html .= '<h3>Others</h3>';
                 $html .= $grouped_exts['others'];
             }
             $html .= '</div>';
             $html .= '</div>';
             if (!empty($installing_exts)) {
                 $html .= '<p>
                             <span class="extension_api_loading">
                                 <input type="button" class="mainwp-upgrade-button button-primary" id="mainwp-extensions-installnow" value="' . __('Install Selected Extensions', 'mainwp') . '">
                                 <i class="fa fa-spinner fa-pulse" style="display: none;"></i><span class="status hidden"></span>
                             </span>
                         </p> ';
             }
             $html .= '<p><div id="extBulkActivate"><i class="fa fa-spinner fa-pulse hidden" style="display: none"></i> <span class="status hidden"></span></div></p>';
             $return = array('result' => 'SUCCESS', 'data' => $html);
         } else {
             if (isset($result['error'])) {
                 $return = array('error' => $result['error']);
             }
         }
     } else {
         $apisslverify = get_option('mainwp_api_sslVerifyCertificate');
         if ($apisslverify == 1) {
             MainWP_Utility::update_option('mainwp_api_sslVerifyCertificate', 0);
             $return['retry_action'] = 1;
         }
     }
     die(json_encode($return));
 }
Exemplo n.º 6
0
 public static function ajax_grab_api_key()
 {
     $enscrypt_u = get_option('mainwp_extensions_api_username');
     $enscrypt_p = get_option('mainwp_extensions_api_password');
     $username = !empty($enscrypt_u) ? MainWP_Api_Manager_Password_Management::decrypt_string($enscrypt_u) : "";
     $password = !empty($enscrypt_p) ? MainWP_Api_Manager_Password_Management::decrypt_string($enscrypt_p) : "";
     $api = dirname($_POST['slug']);
     $result = MainWP_Api_Manager::instance()->grab_license_key($api, $username, $password);
     die(json_encode($result));
 }