• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_hash函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_hash函数的具体用法?PHP wp_hash怎么用?PHP wp_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_hash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wp_verify_nonce

 /**
  * Verify that correct nonce was used with time limit.
  *
  * The user is given an amount of time to use the token, so therefore, since the
  * UID and $action remain the same, the independent variable is the time.
  *
  * @since 2.0.3
  *
  * @param string $nonce Nonce that was used in the form to verify
  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
  *
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
  */
 function wp_verify_nonce($nonce, $action = -1)
 {
     $nonce = (string) $nonce;
     $user = wp_get_current_user();
     $uid = (int) $user->ID;
     if (!$uid) {
         /**
          * Filter whether the user who generated the nonce is logged out.
          *
          * @since 3.5.0
          *
          * @param int $uid ID of the nonce-owning user.
          * @param string $action The nonce action.
          */
         $uid = apply_filters('nonce_user_logged_out', $uid, $action);
     }
     if (empty($nonce)) {
         die('<mainwp>' . base64_encode(json_encode(array('error' => 'You dont send nonce: ' . $action))) . '</mainwp>');
     }
     $token = wp_get_session_token();
     $i = wp_nonce_tick();
     // Nonce generated 0-12 hours ago
     $expected = substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
     if (hash_equals($expected, $nonce)) {
         return 1;
     }
     // Nonce generated 12-24 hours ago
     $expected = substr(wp_hash($i - 1 . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
     if (hash_equals($expected, $nonce)) {
         return 2;
     }
     // Invalid nonce
     die('<mainwp>' . base64_encode(json_encode(array('error' => 'Invalid nonce. Try use: ' . $action))) . '</mainwp>');
 }
开发者ID:jexmex,项目名称:mainwp-child,代码行数:48,代码来源:class-mainwp-child.php


示例2: validate_token

	/**
	 * Validate the user token.
	 *
	 * @since 0.1-dev
	 *
	 * @param int    $user_id User ID.
	 * @param string $token User token.
	 * @return boolean
	 */
	public function validate_token( $user_id, $token ) {
		$hashed_token = get_user_meta( $user_id, self::TOKEN_META_KEY, true );
		if ( wp_hash( $token ) !== $hashed_token ) {
			$this->delete_token( $user_id );
			return false;
		}
		return true;
	}
开发者ID:helloworld-digital,项目名称:insightvision,代码行数:17,代码来源:class.two-factor-email.php


示例3: get_chunk_nonce

 /**
  * Creates a custom nonce in order to secure feed
  * retrieval requests.
  */
 public function get_chunk_nonce()
 {
     $nonce = wp_hash(time());
     pf_log('Create the retrieval nonce: ');
     pf_log($nonce);
     update_option('chunk_nonce', $nonce);
     return $nonce;
 }
开发者ID:joffcrabtree,项目名称:pressforward,代码行数:12,代码来源:slurp.php


示例4: recaptcha_wp_hash_comment

function recaptcha_wp_hash_comment($id)
{
    global $recaptcha_opt;
    if (function_exists('wp_hash')) {
        return wp_hash(RECAPTCHA_WP_HASH_COMMENT . $id);
    } else {
        return md5(RECAPTCHA_WP_HASH_COMMENT . $recaptcha_opt['privkey'] . $id);
    }
}
开发者ID:iamascii247,项目名称:recaptcha,代码行数:9,代码来源:recaptcha.php


示例5: get_temporary_file_path

 private function get_temporary_file_path($filename)
 {
     $uploads_dir = $this->settings->get_runtime_option('awpcp-uploads-dir');
     $tempory_dir_path = implode(DIRECTORY_SEPARATOR, array($uploads_dir, 'tmp'));
     $pathinfo = awpcp_utf8_pathinfo($filename);
     $new_name = wp_hash($pathinfo['basename']) . '.' . $pathinfo['extension'];
     $unique_filename = wp_unique_filename($tempory_dir_path, $new_name);
     return $tempory_dir_path . DIRECTORY_SEPARATOR . $unique_filename;
 }
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:9,代码来源:class-file-uploader.php


示例6: wptouch_create_anonymous_nonce

function wptouch_create_anonymous_nonce($action)
{
    // Creates a valid WordPress nonce for anonymous requests.
    $uid = 0;
    $token = '';
    $i = wp_nonce_tick();
    $nonce = substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
    return $nonce;
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:9,代码来源:wptouch-admin-upgrade-license.php


示例7: get_image_uri

 function get_image_uri($image, $params)
 {
     $params['image'] = $image;
     $uri = $this->object->get_uri_from_params($params);
     if (substr($uri, -1) != '/') {
         $uri .= '/';
     }
     $uri .= wp_hash($uri) . '/';
     return $uri;
 }
开发者ID:ayoayco,项目名称:upbeat,代码行数:10,代码来源:class.dynamic_thumbnails_manager.php


示例8: verify_nonce

 public function verify_nonce($nonce, $action)
 {
     $i = wp_nonce_tick();
     if (substr(wp_hash($i . $action, 'nonce'), -12, 10) === $nonce) {
         return true;
     }
     if (substr(wp_hash($i - 1 . $action, 'nonce'), -12, 10) === $nonce) {
         return true;
     }
     return false;
 }
开发者ID:jeanpage,项目名称:ca_learn,代码行数:11,代码来源:authentication.php


示例9: wp_create_nonce

function wp_create_nonce($action = -1)
{
    $user = wp_get_current_user();
    $uid = (int) $user->ID;
    if (!$uid) {
        /** This filter is documented in wp-includes/pluggable.php */
        $uid = apply_filters('nonce_user_logged_out', $uid, $action);
    }
    $token = wp_get_session_token();
    $i = wp_nonce_tick();
    return substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:12,代码来源:pluggable.php


示例10: process_form

 static function process_form()
 {
     // Invoked at init via add_action
     // Do we process one of our forms now?
     if (isset($_POST['si_contact_action']) && 'send' == $_POST['si_contact_action'] && isset($_POST['form_id']) && is_numeric($_POST['form_id'])) {
         self::$form_id_num = (int) $_POST['form_id'];
     } else {
         // Error: no form id in $_POST
         return;
     }
     // prevent double action
     if (self::$form_processed) {
         return;
     }
     // begin logic that redirects on forged form token.
     $token = 'ok';
     if (!isset($_POST['fs_postonce_' . self::$form_id_num]) || empty($_POST['fs_postonce_' . self::$form_id_num]) || strpos($_POST['fs_postonce_' . self::$form_id_num], ',') === false) {
         $token = 'bad';
     }
     $vars = explode(',', $_POST['fs_postonce_' . self::$form_id_num]);
     if (empty($vars[0]) || empty($vars[1]) || !preg_match("/^[0-9]+\$/", $vars[1])) {
         $token = 'bad';
     }
     if (wp_hash($vars[1]) != $vars[0]) {
         $token = 'bad';
     }
     if ($token == 'bad') {
         // forgery token was no good,  so redirect and blank the form
         self::$form_action_url = FSCF_Display::get_form_action_url();
         wp_redirect(self::$form_action_url);
         exit;
     }
     self::$global_options = FSCF_Util::get_global_options();
     self::$form_options = FSCF_Util::get_form_options(self::$form_id_num, $use_defauilts = true);
     // Do some security checks
     self::check_security();
     self::validate_data();
     self::$form_processed = true;
     if (empty(self::$form_errors)) {
         // Send the email, cleanup attachments, redirect.
         self::prepare_email();
         if (self::$form_options['email_keep_attachments'] != 'true') {
             self::email_sent_cleanup_attachments();
         }
         self::email_sent_redirect();
     }
     if (!empty(self::$uploaded_files)) {
         // unlink (delete) attachment temp files
         foreach ((array) self::$uploaded_files as $path) {
             @unlink($path);
         }
     }
 }
开发者ID:GnaritasInc,项目名称:gnlms,代码行数:53,代码来源:class-fscf-process.php


示例11: verifyNonce

 /**
  * Local nonce verification.
  * WordPress uses the UID and sometimes I don't want that
  * Verify that correct nonce was used with time limit.
  *
  * The user is given an amount of time to use the token, so therefore, since the
  * $action remain the same, the independent variable is the time.
  *
  * @param string     $nonce  Nonce that was used in the form to verify
  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
  *
  * @return bool Whether the nonce check passed or failed.
  */
 public static function verifyNonce($nonce, $action = -1)
 {
     $r = false;
     $i = wp_nonce_tick();
     // Nonce generated 0-12 hours ago
     if (substr(wp_hash($i . $action, 'nonce'), -12, 10) == $nonce) {
         $r = 1;
     } elseif (substr(wp_hash($i - 1 . $action, 'nonce'), -12, 10) == $nonce) {
         // Nonce generated 12-24 hours ago
         $r = 2;
     }
     return $r;
 }
开发者ID:Nanotraktor,项目名称:AVH-First-Defense-Against-Spam,代码行数:26,代码来源:avh-security.php


示例12: __construct

 public function __construct()
 {
     global $woocommerce;
     $this->token = sanitize_file_name(wp_hash(VINDI_IDENTIFIER));
     $this->init_form_fields();
     $this->init_settings();
     $this->debug = $this->get_option('debug') == 'yes' ? true : false;
     $this->logger = new Vindi_Logger(VINDI_IDENTIFIER, $this->debug);
     $this->api = new Vindi_API($this->get_api_key(), $this->logger);
     $this->woocommerce = $woocommerce;
     add_filter('woocommerce_payment_gateways', array(&$this, 'add_gateway'));
     add_action('admin_notices', array(&$this, 'manual_renew_is_deactivated'));
     add_action('admin_notices', array(&$this, 'allow_switching_is_activated'));
     if (is_admin()) {
         add_filter('woocommerce_settings_tabs_array', array(&$this, 'add_settings_tab'), 50);
         add_action('woocommerce_settings_tabs_settings_vindi', array(&$this, 'settings_tab'));
         add_action('woocommerce_update_options_settings_vindi', array(&$this, 'process_admin_options'));
     }
 }
开发者ID:vindi,项目名称:vindi-woocommerce-subscriptions,代码行数:19,代码来源:class-vindi-settings.php


示例13: private_unique_post_slug

 /**
  * Filter the unique post slug.
  *
  * @param string $slug          The post slug.
  * @param int    $post_ID       Post ID.
  * @param string $post_status   The post status.
  * @param string $post_type     Post type.
  * @param int    $post_parent   Post parent ID
  * @param string $original_slug The original post slug.
  */
 public static function private_unique_post_slug($slug, $post_ID, $post_status, $post_type)
 {
     $hashed_post_slug = wp_hash($slug . microtime());
     // Change every post that has auto-draft
     if (false !== strpos($slug, 'auto-draft')) {
         return $hashed_post_slug;
         // add microtime to be unique
     }
     // don't change on front-end edits.
     if (in_array($post_status, array(SI_Estimate::STATUS_PENDING, SI_Estimate::STATUS_APPROVED, SI_Estimate::STATUS_DECLINED))) {
         return $slug;
     }
     // make sure it's a new post
     if ((!isset($_POST['post_name']) || $_POST['post_name'] == '') && $post_type == SI_Estimate::POST_TYPE) {
         return $hashed_post_slug;
         // add microtime to be unique
     }
     return $slug;
 }
开发者ID:danielbachhuber,项目名称:marcgratch.com,代码行数:29,代码来源:Estimates_Premium.php


示例14: bp_autologin_on_activation

function bp_autologin_on_activation($user_id, $key, $user)
{
    global $bp, $wpdb;
    //simulate Bp activation
    /* Check for an uploaded avatar and move that to the correct user folder, just do what bp does */
    if (is_multisite()) {
        $hashed_key = wp_hash($key);
    } else {
        $hashed_key = wp_hash($user_id);
    }
    /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
    if (file_exists(BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key)) {
        @rename(BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key, BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id);
    }
    bp_core_add_message(__('Your account is now active!', 'buddypress'));
    $bp->activation_complete = true;
    //now login and redirect
    wp_set_auth_cookie($user_id, true, false);
    bp_core_redirect(apply_filters("bpdev_autoactivate_redirect_url", bp_core_get_user_domain($user_id), $user_id));
}
开发者ID:hscale,项目名称:webento,代码行数:20,代码来源:bp-autologin-on-activation.php


示例15: __construct

 function __construct()
 {
     global $table_prefix, $wpdb;
     $rand = substr(wp_hash(DB_PASSWORD), 0, 16);
     global $wpdbb_content_dir, $wpdbb_content_url;
     $wpdbb_content_dir = defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : ABSPATH . 'wp-content';
     $wpdbb_content_url = defined('WP_CONTENT_URL') ? WP_CONTENT_URL : get_option('siteurl') . '/wp-content';
     if (!defined('WP_BACKUP_DIR')) {
         define('WP_BACKUP_DIR', $wpdbb_content_dir . '/backup-' . $rand . '/');
     }
     if (!defined('WP_BACKUP_URL')) {
         define('WP_BACKUP_URL', $wpdbb_content_url . '/backup-' . $rand . '/');
     }
     if (!defined('ROWS_PER_SEGMENT')) {
         define('ROWS_PER_SEGMENT', 2000);
     }
     $datum = date("Ymd_B");
     $this->backup_filename = DB_NAME . "_{$table_prefix}{$datum}." . substr(wp_hash(DB_NAME . "_{$table_prefix}{$datum}"), 0, 8) . ".sql";
     $this->backup_dir = trailingslashit(WP_BACKUP_DIR);
     $this->basename = 'wp-db-backup';
     $this->referer_check_key = $this->basename . '-download_' . DB_NAME;
 }
开发者ID:uglmee,项目名称:kikiku.com,代码行数:22,代码来源:db-backup.php


示例16: index_action

 function index_action()
 {
     $dynthumbs = $this->get_registry()->get_utility('I_Dynamic_Thumbnails_Manager');
     $uri = $_SERVER['REQUEST_URI'];
     $params = $dynthumbs->get_params_from_uri($uri);
     $request_params = $params;
     if ($params != null) {
         $storage = $this->get_registry()->get_utility('I_Gallery_Storage');
         // Note, URLs should always include quality setting when returned by Gallery Storage component
         // this sanity check is mostly for manually testing URLs
         if (!isset($params['quality'])) {
             // Note: there's a problem when doing this as using the same set of parameters to *retrieve* the image path/URL will lead to a different filename than the one tha was used to *generate* it (which went through here)
             // The statement above about URLs always containing quality setting is not true anymore, this is because we need to retrieve default quality from the imgQuality and thumbquality settings, depending on "full" or "thumbnail" request in the ngglegacy storage
             //$params['quality'] = 100;
         }
         $image_id = $params['image'];
         $size = $dynthumbs->get_size_name($params);
         $abspath = $storage->get_image_abspath($image_id, $size, true);
         $valid = true;
         // Render invalid image if hash check fails
         if ($abspath == null) {
             $uri_plain = $dynthumbs->get_uri_from_params($request_params);
             $hash = wp_hash($uri_plain);
             if (strpos($uri, $hash) === false) {
                 $valid = false;
                 $filename = $this->object->find_static_file('invalid_image.png');
                 $this->set_content_type('image/png');
                 readfile($filename);
                 $this->render();
             }
         }
         if ($valid) {
             $storage->render_image($image_id, $size);
         }
     }
 }
开发者ID:ayoayco,项目名称:upbeat,代码行数:36,代码来源:class.dynamic_thumbnails_controller.php


示例17: failed_state_validation

 public static function failed_state_validation($form_id, $field, $value)
 {
     global $_gf_state;
     //if field can be populated dynamically, disable state validation
     if ($field->allowsPrepopulate) {
         return false;
     } else {
         if (!GFCommon::is_product_field($field->type) && $field->type != 'donation') {
             return false;
         } else {
             if (!in_array($field->inputType, array('singleshipping', 'singleproduct', 'hiddenproduct', 'checkbox', 'radio', 'select'))) {
                 return false;
             }
         }
     }
     if (!isset($_gf_state)) {
         $state = json_decode(base64_decode($_POST["state_{$form_id}"]), true);
         if (!$state || sizeof($state) != 2) {
             return true;
         }
         //making sure state wasn't tampered with by validating checksum
         $checksum = wp_hash(crc32($state[0]));
         if ($checksum !== $state[1]) {
             return true;
         }
         $_gf_state = json_decode($state[0], true);
     }
     if (!is_array($value)) {
         $value = array($field->id => $value);
     }
     foreach ($value as $key => $input_value) {
         $state = isset($_gf_state[$key]) ? $_gf_state[$key] : false;
         //converting price to a number for single product fields and single shipping fields
         if (in_array($field->inputType, array('singleproduct', 'hiddenproduct')) && $key == $field->id . '.2' || $field->inputType == 'singleshipping') {
             $input_value = GFCommon::to_number($input_value);
         }
         $sanitized_input_value = wp_kses($input_value, wp_kses_allowed_html('post'));
         $hash = wp_hash($input_value);
         $sanitized_hash = wp_hash($sanitized_input_value);
         $fails_hash = strlen($input_value) > 0 && $state !== false && (is_array($state) && !in_array($hash, $state) || !is_array($state) && $hash != $state);
         $fails_sanitized_hash = strlen($sanitized_input_value) > 0 && $state !== false && (is_array($state) && !in_array($sanitized_hash, $state) || !is_array($state) && $sanitized_hash != $state);
         if ($fails_hash && $fails_sanitized_hash) {
             return true;
         }
     }
     return false;
 }
开发者ID:timk85,项目名称:DIT,代码行数:47,代码来源:form_display.php


示例18: wc_get_log_file_path

/**
 * Get a log file path
 *
 * @since 2.2
 * @param string $handle name
 * @return string the log file path
 */
function wc_get_log_file_path($handle)
{
    return trailingslashit(WC_LOG_DIR) . $handle . '-' . sanitize_file_name(wp_hash($handle)) . '.log';
}
开发者ID:slavic18,项目名称:cats,代码行数:11,代码来源:wc-core-functions.php


示例19: showReadme

 /**
  * @param string $readmePath
  * @return bool
  */
 public static function showReadme($readmePath = null)
 {
     if ($readmePath === null) {
         $readmePath = ABSPATH . 'readme.html';
     }
     $readmePathInfo = pathinfo($readmePath);
     require_once ABSPATH . WPINC . '/pluggable.php';
     $hiddenReadmeFile = $readmePathInfo['dirname'] . '/' . $readmePathInfo['filename'] . '.' . wp_hash('readme') . '.' . $readmePathInfo['extension'];
     if (file_exists($hiddenReadmeFile)) {
         return @rename($hiddenReadmeFile, $readmePath);
     }
     return false;
 }
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:17,代码来源:wfUtils.php


示例20: wp_create_nonce

 function wp_create_nonce($action = -1)
 {
     $user = wp_get_current_user();
     $uid = (int) $user->id;
     $i = ceil(time() / 43200);
     return substr(wp_hash($i . $action . $uid), -12, 10);
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:7,代码来源:pluggable-functions.php



注:本文中的wp_hash函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_hash_password函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_handler函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap