/** * Decrypt encrypted text. * * If a key is not provided, it is assumed that this is a private key decryption * and the plugin's internal private key will be used. Otherwise, the provided * key is assumed to be a public key. * * Any value that will work with openssl_public_decrypt will work for the $key * argument. See http://us3.php.net/manual/en/openssl.certparams.php for more * information. * * Returns the decrypted text on success, false on failure. * * @link http://us3.php.net/manual/en/openssl.certparams.php Key parameter details. * @param string $encrypted_text The text to be decrypted. * @param mixed $key False to use the internal private key, an OpenSSL key value otherwise * @return boolean */ public static function decrypt($encrypted_text, $key = false) { if (!$key) { $key = WP_MSM_Options::instance()->privateSignature; $worked = openssl_private_decrypt($encrypted_text, $decrypted_text, $key); if ($worked) { return $decrypted_text; } return false; } $worked = openssl_public_decrypt($encrypted_text, $decrypted_text, $key); if ($worked) { return $decrypted_text; } return false; }
/** * Update a profile in the manager. * * If the profile doesn't exist, it'll update it. If the profile is a default profile * it will not update. * * @param string $name * @param WP_MSM_Profile $profile */ public function update_profile($name, WP_MSM_Profile $profile) { if (in_array($name, self::$defaultProfiles)) { return; } if (isset(self::$profiles[$name])) { unset(self::$profiles[$name]); } $newName = $name == $profile->name ? $name : $profile->name; self::$profiles[$newName] = $profile; $options = WP_MSM_Options::instance(); if (isset($options->customProfiles[$name])) { unset($options->customProfiles[$name]); $options->customProfiles[$newName] = $profile->_toArray(); $options->update(); } }
private static function _render_settings() { $profileManager = new WP_MSM_Profile_Manager(); $currentProfile = WP_MSM_Options::instance()->profile; $profiles = $profileManager->get_all_profile_names(); ?> <form method="post" action=""> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><label for="wpmsm_settings_profile">Please select a server profile</label></th> <td> <select id="wpmsm_settings_profile" name="wpmsm_settings[profile]"> <?php foreach ($profiles as $profile) { $profile = $profileManager->get_profile($profile); ?> <option value="<?php echo esc_attr($profile->name); ?> "<?php selected($profile->name, $currentProfile); ?> > <?php echo esc_html($profile->displayName); ?> </option> <?php } ?> </select> </td> </tr> </tbody> </table> </form> <?php }
public function get_columns() { return array('cb' => empty(WP_MSM_Options::instance()->customProfiles) ? '' : '', 'name' => __('Name', 'WordPress-MultiServer-Migration'), 'description' => __('Description', 'WordPress-MultiServer-Migration'), 'tables' => __('Tables to Exclude', 'WordPress-MultiServer-Migration')); }