本文整理汇总了PHP中c_ws_plugin__s2member_utils_strings::random_str_gen方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_strings::random_str_gen方法的具体用法?PHP c_ws_plugin__s2member_utils_strings::random_str_gen怎么用?PHP c_ws_plugin__s2member_utils_strings::random_str_gen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c_ws_plugin__s2member_utils_strings
的用法示例。
在下文中一共展示了c_ws_plugin__s2member_utils_strings::random_str_gen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: encrypt
/**
* RIJNDAEL 256: two-way encryption/decryption, with a URL-safe base64 wrapper.
*
* Falls back on XOR encryption/decryption when/if mcrypt is not possible.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param str $string A string of data to encrypt.
* @param str $key Optional. Key used for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: ``wp_salt()``.
* @param bool $w_md5_cs Optional. Defaults to true. When true, an MD5 checksum is used in the encrypted string *(recommended)*.
* @return str Encrypted string.
*/
public static function encrypt($string = FALSE, $key = FALSE, $w_md5_cs = TRUE)
{
if (function_exists("mcrypt_encrypt") && in_array("rijndael-256", mcrypt_list_algorithms()) && in_array("cbc", mcrypt_list_modes())) {
$string = is_string($string) ? $string : "";
$string = strlen($string) ? "~r2|" . $string : "";
$key = c_ws_plugin__s2member_utils_encryption::key($key);
$key = substr($key, 0, mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
$iv = c_ws_plugin__s2member_utils_strings::random_str_gen(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), false);
if (strlen($string) && is_string($e = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv)) && strlen($e)) {
$e = "~r2:" . $iv . ($w_md5_cs ? ":" . md5($e) : "") . "|" . $e;
}
return isset($e) && is_string($e) && strlen($e) ? $base64 = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($e) : "";
} else {
// Fallback on XOR encryption.
return c_ws_plugin__s2member_utils_encryption::xencrypt($string, $key, $w_md5_cs);
}
}
示例2: __construct
public function __construct()
{
echo '<div class="wrap ws-menu-page">' . "\n";
echo '<div class="ws-menu-page-toolbox">' . "\n";
c_ws_plugin__s2member_menu_pages_tb::display();
echo '</div>' . "\n";
echo '<h2>General Options</h2>' . "\n";
echo '<table class="ws-menu-page-table">' . "\n";
echo '<tbody class="ws-menu-page-table-tbody">' . "\n";
echo '<tr class="ws-menu-page-table-tr">' . "\n";
echo '<td class="ws-menu-page-table-l">' . "\n";
echo '<form method="post" name="ws_plugin__s2member_options_form" id="ws-plugin--s2member-options-form">' . "\n";
echo '<input type="hidden" name="ws_plugin__s2member_options_save" id="ws-plugin--s2member-options-save" value="' . esc_attr(wp_create_nonce("ws-plugin--s2member-options-save")) . '" />' . "\n";
echo '<input type="hidden" name="ws_plugin__s2member_configured" id="ws-plugin--s2member-configured" value="1" />' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_before_left_sections", get_defined_vars());
if (apply_filters("ws_plugin__s2member_during_gen_ops_page_during_left_sections_display_uninstall", !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || is_super_admin(), get_defined_vars())) {
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_before_uninstall", get_defined_vars());
echo '<div class="ws-menu-page-group" title="Plugin Deletion Safeguards"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_uninstall_routines"] ? ' default-state="open"' : '') . '>' . "\n";
echo '<div class="ws-menu-page-section ws-plugin--s2member-uninstall-section">' . "\n";
echo '<h3>Plugin Deletion Safeguards (highly recommended)</h3>' . "\n";
echo '<p>By default, s2Member will retain all of it\'s Roles, Capabilities, and your Configuration Options when/if you delete s2Member from the Plugins Menu in WordPress. However, if you would like for s2Member to erase itself completely, please choose: <code>No (upon deletion, erase all data/options)</code>.</p>';
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_uninstall", get_defined_vars());
echo '<table class="form-table">' . "\n";
echo '<tbody>' . "\n";
echo '<tr>' . "\n";
echo '<th>' . "\n";
echo '<label for="ws-plugin--s2member-run-uninstall-routines">' . "\n";
echo 'Safeguard s2Member Data/Options?' . "\n";
echo '</label>' . "\n";
echo '</th>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<select name="ws_plugin__s2member_run_uninstall_routines" id="ws-plugin--s2member-run-uninstall-routines">' . "\n";
echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_uninstall_routines"] ? ' selected="selected"' : '') . '>Yes (safeguard all data/options)</option>' . "\n";
echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["run_uninstall_routines"] ? ' selected="selected"' : '') . '>No (upon deletion, erase all data/options)</option>' . "\n";
echo '</select><br />' . "\n";
echo 'Recommended setting: (<code>Yes, safeguard all data/options</code>)' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</tbody>' . "\n";
echo '</table>' . "\n";
echo '</div>' . "\n";
echo '</div>' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_after_uninstall", get_defined_vars());
}
if (apply_filters("ws_plugin__s2member_during_gen_ops_page_during_left_sections_display_security", TRUE, get_defined_vars())) {
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_before_security", get_defined_vars());
echo '<div class="ws-menu-page-group" title="Security Encryption Key">' . "\n";
echo '<div class="ws-menu-page-section ws-plugin--s2member-security-section">' . "\n";
echo '<img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]) . '/images/large-icon.png" title="s2Member (a Membership management system for WordPress)" alt="" style="float:right; margin:0 0 0 25px; border:0;" />' . "\n";
echo '<h3>Security Encryption Key (optional, for tighter security)</h3>' . "\n";
echo '<p>Just like WordPress, s2Member is open-source software. Which is wonderful. However, this also makes it possible for anyone to grab a copy of the software, and try to learn their way around its security measures. In order to keep your installation of s2Member unique/secure, you should configure a Security Encryption Key. s2Member will use your Security Encryption Key to protect itself against hackers. It does this by encrypting all sensitive information with your Key. A Security Encryption Key is unique to your installation.</p>' . "\n";
echo '<p>Once you configure this, you do NOT want to change it; not ever. In fact, it is a VERY good idea to keep this backed up in a safe place, just in case you need to move your site, or re-install s2Member in the future. Some of the sensitive data that s2Member stores, will be encrypted with this Key. If you change it, that data can no longer be read, even by s2Member itself. In other words, don\'t use s2Member for six months, then decide to change your Key. That would break your installation.</p>' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_security", get_defined_vars());
echo '<table class="form-table">' . "\n";
echo '<tbody>' . "\n";
echo '<tr>' . "\n";
echo '<th>' . "\n";
echo '<label for="ws-plugin--s2member-sec-encryption-key">' . "\n";
echo 'Security Encryption Key (at least 60 chars)' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] ? ' <a href="#" onclick="ws_plugin__s2member_enableSecurityKey(); return false;" title="(not recommended)">edit key</a>' : ' <a href="#" onclick="ws_plugin__s2member_generateSecurityKey(); return false;" title="Insert an auto-generated Key. (recommended)">auto-generate</a>') . "\n";
echo '</label>' . "\n";
echo '</th>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<input type="text" maxlength="256" autocomplete="off" name="ws_plugin__s2member_sec_encryption_key" id="ws-plugin--s2member-sec-encryption-key" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) . '"' . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] ? ' disabled="disabled"' : '') . ' />' . "\n";
echo !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"] ? '<br />This may contain letters, numbers, spaces; even punctuation. Up to 256 characters.<br /><em>Ex: <code>' . esc_html(strtoupper(c_ws_plugin__s2member_utils_strings::random_str_gen(64))) . '</code></em>' . "\n" : '';
echo count($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) > 1 ? '<br /><a href="#" onclick="ws_plugin__s2member_securityKeyHistory(); return false;">Click here</a> for a history of your last 10 Encryption Keys.<div id="ws-plugin--s2member-sec-encryption-key-history" style="display:none;"><code>' . implode('</code><br /><code>', $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key_history"]) . '</code></div>' . "\n" : '';
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</tbody>' . "\n";
echo '</table>' . "\n";
echo '<div class="ws-menu-page-hr"></div>' . "\n";
echo '<h3>Additional Details Regarding this Key:</h3>' . "\n";
echo '<p>Your Security Encryption Key is used throughout s2Member\'s source code for many different things. However, MOST (not all, but most) uses of this Key are related to transactional processing within a particular session; so changing the Key won\'t really impact these scenarios in any significant way. Your Security Encryption Key is simply there to enhance security of data that is being transmitted in these cases.</p>' . "\n";
echo '<p>That said, there are a few scenarios where use of your Security Encryption Key is more long-term. These include: Specific Post/Page Access Links, Registration Access Links, and it can also have a long-term impact on IPN communication because some data analyzed by s2Member includes a checksum that depends on your Key. If the Key changes, it could cause future IPN data (i.e. data from your payment gateway) to fail validation.</p>' . "\n";
echo '</div>' . "\n";
echo '</div>' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_after_security", get_defined_vars());
}
if (apply_filters("ws_plugin__s2member_during_gen_ops_page_during_left_sections_display_localhost_info", !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || is_super_admin(), get_defined_vars())) {
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_before_localhost_info", get_defined_vars());
echo '<div class="ws-menu-page-group" title="Localhost WAMP/MAMP Developers">' . "\n";
echo '<div class="ws-menu-page-section ws-plugin--s2member-localhost-info-section">' . "\n";
echo '<h3>Localhost WAMP/MAMP Installs (are you a developer?)</h3>' . "\n";
echo '<p>If you\'re developing your site in a <code>localhost</code> environment, running something like WAMP/MAMP, or <a href="http://www.easyphp.org/" target="_blank" rel="external">EasyPHP</a>, please add this line to your <code>/wp-config.php</code> file: <code><span style="color:#0000BB;">define</span><span style="color:#007700;">(</span><span style="color:#DD0000;">"LOCALHOST"</span>, <span style="color:#0000BB;">true</span><span style="color:#007700;">);</span></code>.</p>' . "\n";
echo '<p>This lets s2Member know definitively that your site is in a <code>localhost</code> environment. s2Member will adjust itself accordingly, maximizing functionality during your developement. s2Member can usually auto-detect this, but in cases where your <code>localhost</code> installation runs on something other than <code>127.0.0.1/localhost</code>, you need to tell s2Member definitively, by adding that line to your <code>/wp-config.php</code> file. For instance, s2Member needs to know when your server IP is the same as all User IPs.</p>' . "\n";
echo '<p><em>Once your site goes live, please remove the line. If you\'re already on a live server connected to the web, please ignore this section.</em></p>' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_during_localhost_info", get_defined_vars());
echo '</div>' . "\n";
echo '</div>' . "\n";
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_after_localhost_info", get_defined_vars());
}
if (apply_filters("ws_plugin__s2member_during_gen_ops_page_during_left_sections_display_lazy_load", !is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || is_super_admin(), get_defined_vars())) {
do_action("ws_plugin__s2member_during_gen_ops_page_during_left_sections_before_lazy_load", get_defined_vars());
echo '<div class="ws-menu-page-group" title="CSS/JS Lazy Loading">' . "\n";
echo '<div class="ws-menu-page-section ws-plugin--s2member-lazy-load-section">' . "\n";
echo '<h3>CSS/JS Lazy Loading (Client-Side Libraries)</h3>' . "\n";
echo '<p>By default, s2Member will load it\'s CSS/JS libraries on every page of your site. However, you may wish to enable lazy-loading here (e.g. only load when absolutely necessary).</p>' . "\n";
//.........这里部分代码省略.........
示例3: encrypt
/**
* RIJNDAEL 256: two-way encryption/decryption, with a URL-safe base64 wrapper.
*
* Falls back on XOR encryption/decryption when/if mcrypt is not possible.
*
* @package s2Member\Utilities
* @since 3.5
*
* @param string $string A string of data to encrypt.
* @param string $key Optional. Key used for encryption. Defaults to the one configured for s2Member. Short of that, defaults to: ``wp_salt()``.
* @param bool $w_md5_cs Optional. Defaults to true. When true, an MD5 checksum is used in the encrypted string *(recommended)*.
*
* @return string Encrypted string.
*/
public static function encrypt($string = '', $key = '', $w_md5_cs = TRUE)
{
if (function_exists('mcrypt_encrypt') && in_array('rijndael-256', mcrypt_list_algorithms()) && in_array('cbc', mcrypt_list_modes())) {
$string = is_string($string) ? $string : '';
$string = isset($string[0]) ? '~r2|' . $string : '';
$key = c_ws_plugin__s2member_utils_encryption::key($key);
$key = substr($key, 0, mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
$iv = c_ws_plugin__s2member_utils_strings::random_str_gen(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), FALSE);
if (isset($string[0]) && is_string($e = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv)) && isset($e[0])) {
$e = '~r2:' . $iv . ($w_md5_cs ? ':' . md5($e) : '') . '|' . $e;
}
return isset($e) && is_string($e) && isset($e[0]) ? $base64 = c_ws_plugin__s2member_utils_strings::base64_url_safe_encode($e) : '';
// Default to empty string.
}
return c_ws_plugin__s2member_utils_encryption::xencrypt($string, $key, $w_md5_cs);
}