示例#1
0
 public static function get_plugin_information($path)
 {
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     $details = Ithemes_Updater_Packages::get_full_details();
     if (!isset($details['packages'][$path])) {
         return false;
     }
     $package = $details['packages'][$path];
     require_once $GLOBALS['ithemes_updater_path'] . '/functions.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/information.php';
     $changelog = Ithemes_Updater_API::get_package_changelog($package['package'], $details['packages'][$path]['installed']);
     $info = array('name' => Ithemes_Updater_Functions::get_package_name($package['package']), 'slug' => dirname($path), 'version' => $package['available'], 'author' => '<a href="http://ithemes.com/">iThemes</a>', 'download_link' => $package['package-url'], 'sections' => array('changelog' => $changelog));
     return (object) $info;
 }
示例#2
0
 public static function run_update()
 {
     // Prevent the code from running if the code was loaded by an older updater version.
     if (!isset($GLOBALS['ithemes_updater_path'])) {
         return;
     }
     require_once $GLOBALS['ithemes_updater_path'] . '/api.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/keys.php';
     $keys = Ithemes_Updater_Keys::get();
     $legacy_keys = Ithemes_Updater_Keys::get_legacy();
     if (empty($keys) && empty($legacy_keys)) {
         return;
     }
     Ithemes_Updater_API::get_package_details(false);
 }
示例#3
0
 public static function get_full_details($response = false)
 {
     if (false === $response) {
         require_once $GLOBALS['ithemes_updater_path'] . '/api.php';
         $response = Ithemes_Updater_API::get_package_details();
     }
     $packages = self::get_local_details();
     if (is_wp_error($response)) {
         $expiration = time() + 600;
         foreach ($packages as $path => $data) {
             $packages[$path]['status'] = 'error';
             $packages[$path]['error'] = array('code' => 'unknown', 'type' => $response->get_error_code(), 'message' => $response->get_error_message());
         }
     } else {
         $expiration = time() + 12 * 3600;
         foreach ($packages as $path => $data) {
             if (empty($response['packages'][$data['package']])) {
                 continue;
             }
             $package = $response['packages'][$data['package']];
             if (!empty($package['error'])) {
                 if (in_array($package['error']['type'], array('ITXAPI_License_Key_Unknown', 'ITXAPI_Updater_Missing_Legacy_Key'))) {
                     $packages[$path]['status'] = 'unlicensed';
                 } else {
                     $packages[$path]['status'] = 'error';
                     $packages[$path]['error'] = $package['error'];
                 }
                 continue;
             }
             $key_map = array('status' => 'status', 'link' => 'package-url', 'ver' => 'available', 'used' => 'used', 'total' => 'total', 'user' => 'user', 'sub_expire' => 'expiration', 'upgrade' => 'upgrade');
             foreach ($key_map as $old => $new) {
                 if (isset($package[$old])) {
                     $packages[$path][$new] = $package[$old];
                 } else {
                     $packages[$path][$new] = null;
                 }
             }
             if (isset($package['link_expire'])) {
                 $expiration = min($expiration, $package['link_expire']);
             }
         }
     }
     $details = compact('packages', 'expiration');
     return $details;
 }
示例#4
0
 public static function get_plugin_information($path)
 {
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     $details = Ithemes_Updater_Packages::get_full_details();
     if (!isset($details['packages'][$path])) {
         return false;
     }
     $package = $details['packages'][$path];
     $url = "http://package-info.ithemes.com/{$package['package']}/information.json";
     $response = wp_remote_get($url);
     if (!is_wp_error($response) && isset($response['body'])) {
         $info = json_decode($response['body']);
         if (is_object($info) && !empty($info->name) && !empty($info->version)) {
             $info->slug = dirname($path);
             $info->download_link = $package['package-url'];
             return $info;
         }
     }
     require_once $GLOBALS['ithemes_updater_path'] . '/functions.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/information.php';
     $changelog = Ithemes_Updater_API::get_package_changelog($package['package'], $details['packages'][$path]['installed']);
     $info = array('name' => Ithemes_Updater_Functions::get_package_name($package['package']), 'slug' => dirname($path), 'version' => $package['available'], 'author' => '<a href="http://ithemes.com/">iThemes</a>', 'download_link' => $package['package-url'], 'sections' => array('changelog' => $changelog));
     return (object) $info;
 }
示例#5
0
 private function unlicense_packages($data)
 {
     check_admin_referer('unlicense_packages', 'ithemes_updater_nonce');
     if (empty($data['username']) && empty($data['password'])) {
         $this->errors[] = __('You must supply an iThemes membership username and password in order to remove licenses.', 'it-l10n-ithemes-sync');
     } else {
         if (empty($data['username'])) {
             $this->errors[] = __('You must supply an iThemes membership username in order to remove licenses.', 'it-l10n-ithemes-sync');
         } else {
             if (empty($data['password'])) {
                 $this->errors[] = __('You must supply an iThemes membership password in order to remove licenses.', 'it-l10n-ithemes-sync');
             } else {
                 if (empty($data['packages'])) {
                     $this->errors[] = __('You must select at least one license to remove. Ensure that you select the licenses that you wish to remove in the listing below.', 'it-l10n-ithemes-sync');
                 }
             }
         }
     }
     if (!empty($this->errors)) {
         return;
     }
     $response = Ithemes_Updater_API::deactivate_package($data['username'], $data['password'], $data['packages']);
     if (is_wp_error($response)) {
         $this->errors[] = $this->get_error_explanation($response);
         return;
     }
     if (empty($response['packages'])) {
         $this->errors[] = __('An unknown server error occurred. Please try to remove licenses from your products again at another time.', 'it-l10n-ithemes-sync');
         return;
     }
     uksort($response['packages'], 'strnatcasecmp');
     $success = array();
     $fail = array();
     foreach ($response['packages'] as $package => $data) {
         if (preg_match('/ \\|\\|\\| \\d+$/', $package)) {
             continue;
         }
         $name = Ithemes_Updater_Functions::get_package_name($package);
         if (isset($data['status']) && 'inactive' == $data['status']) {
             $success[] = $name;
         } else {
             if (isset($data['error']) && isset($data['error']['message'])) {
                 $fail[$name] = $data['error']['message'];
             } else {
                 $fail[$name] = __('Unknown server error.', 'it-l10n-ithemes-sync');
             }
         }
     }
     if (!empty($success)) {
         $this->messages[] = wp_sprintf(_n('Successfully removed license from %l.', 'Successfully removed licenses from %l.', count($success), 'it-l10n-ithemes-sync'), $success);
     }
     if (!empty($fail)) {
         foreach ($fail as $name => $reason) {
             $this->errors[] = sprintf(__('Unable to remove license from %1$s. Reason: %2$s', 'it-l10n-ithemes-sync'), $name, $reason);
         }
     }
 }