本文整理汇总了PHP中get_site_secret函数的典型用法代码示例。如果您正苦于以下问题:PHP get_site_secret函数的具体用法?PHP get_site_secret怎么用?PHP get_site_secret使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_site_secret函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gdocs_file_previewer_get_token
function gdocs_file_previewer_get_token($file, $timestamp)
{
if (!elgg_instanceof($file) || !is_numeric($timestamp)) {
return false;
}
$secret = get_site_secret();
return sha1($file->guid . $secret . $timestamp);
}
示例2: get_token
function get_token($url)
{
if (elgg_get_config('image_proxy_secret')) {
$site_secret = elgg_get_config('image_proxy_secret');
} else {
$site_secret = get_site_secret();
}
return md5($site_secret . $url);
}
示例3: acount_removal_generate_confirm_token
/**
* Generate a validation token
*
* @param string $type what kind of token
* @param int $user_guid the user_guid to generate for
*
* @return bool|string
*/
function acount_removal_generate_confirm_token($type, $user_guid)
{
$result = false;
if (!empty($user_guid) && ($user = get_user($user_guid)) && in_array($type, array("remove", "disable"))) {
$site_secret = get_site_secret();
$user_salt = $user->salt;
$result = md5($site_secret . $user_guid . $type . $user_salt);
}
return $result;
}
示例4: admin_tools_make_switch_admin_secret
/**
* Create a secret code to toggle admin/normal user
*
* @param ElggUser $user the user to create the secret for (default: current user)
*
* @return false|string
*/
function admin_tools_make_switch_admin_secret(ElggUser $user = null)
{
// no param, check current logged in user
if (empty($user)) {
$user = elgg_get_logged_in_user_entity();
}
// no user to check
if (!$user instanceof ElggUser) {
return false;
}
return hash_hmac('sha256', $user->time_created, get_site_secret());
}
示例5: getStrength
/**
* Get the strength of the site secret
*
* @return string "strong", "moderate", or "weak"
* @access private
*/
function getStrength()
{
$secret = get_site_secret();
if ($secret[0] !== 'z') {
$rand_max = getrandmax();
if ($rand_max < pow(2, 16)) {
return 'weak';
}
if ($rand_max < pow(2, 32)) {
return 'moderate';
}
}
return 'strong';
}
示例6: getThumbUrl
public function getThumbUrl($url = '', $handle = null)
{
$data = $this->resourceCache->get($url, $handle);
if (!empty($data['thumb_cache'])) {
$uid = md5($url);
$path = "scraper_cache/thumbs/{$uid}.{$handle}.jpg";
$dir = elgg_get_site_entity()->guid;
$dir_tc = elgg_get_site_entity()->time_created;
$query = serialize(array('uid' => $uid, 'path' => $path, 'd' => $dir, 'dts' => $dir_tc, 'ts' => $data['thumb_cache'], 'mac' => hash_hmac('sha256', $uid . $path, get_site_secret())));
$icon_url = elgg_http_add_url_query_elements('/mod/hypeApps/servers/icon.php', array('q' => base64_encode($query)));
} else {
if (!empty($data['thumbnail_url'])) {
$icon_url = $data['thumbnail_url'];
} else {
$icon_url = '/mod/hypeScraper/graphics/placeholder.png';
}
}
return elgg_normalize_url($icon_url);
}
示例7: group_tools_invite_email
function group_tools_invite_email(ElggGroup $group, $email, $text = "", $resend = false)
{
$result = false;
if (!empty($group) && $group instanceof ElggGroup && !empty($email) && is_email_address($email) && ($loggedin_user = elgg_get_logged_in_user_entity())) {
// get site secret
$site_secret = get_site_secret();
// generate invite code
$invite_code = md5($site_secret . $email . $group->getGUID());
if (!group_tools_check_group_email_invitation($invite_code, $group->getGUID()) || $resend) {
// make site email
$site = elgg_get_site_entity();
if (!empty($site->email)) {
if (!empty($site->name)) {
$site_from = $site->name . " <" . $site->email . ">";
} else {
$site_from = $site->email;
}
} else {
// no site email, so make one up
if (!empty($site->name)) {
$site_from = $site->name . " <noreply@" . get_site_domain($site->getGUID()) . ">";
} else {
$site_from = "noreply@" . get_site_domain($site->getGUID());
}
}
if (!$resend) {
// register invite with group
$group->annotate("email_invitation", $invite_code, ACCESS_LOGGED_IN, $group->getGUID());
}
// make subject
$subject = elgg_echo("group_tools:groups:invite:email:subject", array($group->name));
// make body
$body = elgg_echo("group_tools:groups:invite:email:body", array($loggedin_user->name, $group->name, $site->name, $text, $site->name, elgg_get_site_url() . "register", elgg_get_site_url() . "groups/invitations/?invitecode=" . $invite_code, $invite_code));
$result = elgg_send_email($site_from, $email, $subject, $body);
} else {
$result = null;
}
}
return $result;
}
示例8: registration_randomizer_generate_token
/**
* Hashes the site secret, UA, and a ts.
*
* @return mixed A token if time or req is passed, and array of info if not
*/
function registration_randomizer_generate_token($passed_time = null, $passed_req = null)
{
if ($passed_time === null) {
$ts = time();
} else {
$ts = $passed_time;
}
if ($passed_req === null) {
$req = $_SERVER;
} else {
$req = $passed_req;
}
$str = get_site_secret();
$str .= filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');
$str .= filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
$str .= $ts;
$token = md5($str);
if ($passed_time === null && $passed_req === null) {
return array('ts' => $ts, 'token' => $token, 'req' => $req);
} else {
return $token;
}
}
示例9: siteaccess_generate_captcha
function siteaccess_generate_captcha($num)
{
global $CONFIG;
$date = date("F j");
$tmp = hexdec(md5($num . $date . $CONFIG->site->url . get_site_secret()));
$code = substr($tmp, 4, 6);
return $code;
}
示例10: generate_action_token
/**
* Generate an action token.
*
* Action tokens are based on timestamps as returned by {@link time()}.
* They are valid for one hour.
*
* Action tokens should be passed to all actions name __elgg_ts and __elgg_token.
*
* @warning Action tokens are required for all actions.
*
* @param int $timestamp Unix timestamp
*
* @see @elgg_view input/securitytoken
* @see @elgg_view input/form
* @example actions/manual_tokens.php
*
* @return string|false
* @access private
*/
function generate_action_token($timestamp)
{
$site_secret = get_site_secret();
$session_id = session_id();
// Session token
$st = $_SESSION['__elgg_session'];
if ($site_secret && $session_id) {
return md5($site_secret . $timestamp . $session_id . $st);
}
return FALSE;
}
示例11: tidypics_ajax_session_handler
/**
* Work around for Flash/session issues
*
* Catches Elgg attempting to forward the Flash uploader because it doesn't
* have a session cookie. Instead manually runs the action.
*
* @param string $hook The name of the hook
* @param string $type The type of the hook
* @param string $value Location being forwarded to
* @param array $params Parameters related to the forward() call
* @return void
*/
function tidypics_ajax_session_handler($hook, $type, $value, $params)
{
$www_root = elgg_get_config('wwwroot');
$url = $params['current_url'];
if ($url !== "{$www_root}action/photos/image/ajax_upload") {
return;
}
if (elgg_get_logged_in_user_guid() != 0) {
return;
}
// action_gatekeeper rejected ajax call from Flash due to session issue
// Validate token
$token = get_input('__elgg_token');
$ts = get_input('__elgg_ts');
$session_id = get_input('Elgg');
$session_token = get_input('session_token');
$tidypics_token = get_input('tidypics_token');
$user_guid = get_input('user_guid');
$user = get_user($user_guid);
$timeout = elgg_get_config('action_token_timeout');
if (!$timeout) {
$timeout = 2;
}
if (!$user) {
trigger_error('Tidypics warning: failed to get user in flash uploader', E_USER_WARNING);
return;
}
if (!$token || !$ts || !$session_id || !$tidypics_token) {
trigger_error('Tidypics warning: token information missing in flash uploader', E_USER_WARNING);
return;
}
$hour = 60 * 60;
$now = time();
if ($ts < $now - $hour || $ts > $now + $hour) {
trigger_error('Tidypics warning: failed time check in flash uploader', E_USER_WARNING);
return;
}
$generated_token = md5($session_id . get_site_secret() . $ts . $user->salt);
if ($tidypics_token !== $generated_token) {
trigger_error('Tidypics warning: token check failed in flash uploader', E_USER_WARNING);
return;
}
// passed token test, so login and process action
login($user);
$actions = elgg_get_config('actions');
include $actions['photos/image/ajax_upload']['file'];
exit;
}
示例12: generateCode
private function generateCode($userGuid, $email, $date)
{
return md5($userGuid . $email . $date . elgg_get_site_url() . get_site_secret());
}
示例13: uservalidationbyemail_generate_code
/**
* Generate an email activation code.
*
* @param int $user_guid The guid of the user
* @param string $email_address Email address
* @return string
*/
function uservalidationbyemail_generate_code($user_guid, $email_address)
{
global $CONFIG;
// Note I bind to site URL, this is important on multisite!
return md5($user_guid . $email_address . $CONFIG->site->url . get_site_secret());
}
示例14: group_tools_generate_email_invite_code
/**
* Generate a unique code to be used in email invitations
*
* @param int $group_guid the group GUID
* @param string $email the email address
*
* @return boolean|string the invite code, or false on failure
*/
function group_tools_generate_email_invite_code($group_guid, $email)
{
$result = false;
if (!empty($group_guid) && !empty($email)) {
// get site secret
$site_secret = get_site_secret();
// generate code
$result = md5($site_secret . strtolower($email) . $group_guid);
}
return $result;
}
示例15: notifyOnRsvp
/**
* Notifies an user of the RSVP
*
* @param string $type type of the RSVP
* @param string $to guid of the user
*
* @return void
*/
public function notifyOnRsvp($type, $to = null)
{
$ia = elgg_set_ignore_access(true);
if ($to === null) {
$to = elgg_get_logged_in_user_guid();
}
$to_entity = get_entity($to);
if (empty($to_entity)) {
elgg_set_ignore_access($ia);
return;
}
// can we make nice links in the emails
$html_email_handler_enabled = elgg_is_active_plugin("html_email_handler");
// do we have a registration link
$registrationLink = "";
$unsubscribeLink = "";
if ($type == EVENT_MANAGER_RELATION_ATTENDING) {
if ($this->registration_needed) {
$link = elgg_get_site_url() . 'events/registration/view/?guid=' . $this->getGUID() . '&u_g=' . $to . '&k=' . md5($this->time_created . get_site_secret() . $to);
$registrationLink = PHP_EOL . PHP_EOL;
$registrationLink .= elgg_echo('event_manager:event:registration:notification:program:linktext');
$registrationLink .= PHP_EOL . PHP_EOL;
if ($html_email_handler_enabled) {
$registrationLink .= elgg_view("output/url", array("text" => $link, "href" => $link));
} else {
$registrationLink .= $link;
}
}
if ($this->register_nologin) {
$link = elgg_get_site_url() . "events/unsubscribe/" . $this->getGUID() . "/" . elgg_get_friendly_title($this->title) . "?e=" . $to_entity->email;
$unsubscribeLink = PHP_EOL . PHP_EOL;
$unsubscribeLink .= elgg_echo('event_manager:event:registration:notification:unsubscribe:linktext');
$unsubscribeLink .= PHP_EOL . PHP_EOL;
if ($html_email_handler_enabled) {
$unsubscribeLink .= elgg_view("output/url", array("text" => $link, "href" => $link));
} else {
$unsubscribeLink .= $link;
}
}
}
// make the event title for in the e-mail
if ($html_email_handler_enabled) {
$event_title_link = elgg_view("output/url", array("text" => $this->title, "href" => $this->getURL()));
} else {
$event_title_link = $this->title;
}
// notify the owner of the event
$this->notifyOwnerOnRSVP($type, $to_entity, $event_title_link, $registrationLink);
// notify the attending user
$user_subject = elgg_echo('event_manager:event:registration:notification:user:subject');
$user_message = elgg_echo('event_manager:event:registration:notification:user:text:' . $type, array($to_entity->name, $event_title_link));
$user_message .= $registrationLink;
$user_message .= $unsubscribeLink;
if ($to_entity instanceof ElggUser) {
// use notification system for real users
notify_user($to, $this->getOwnerGUID(), $user_subject, $user_message);
} else {
// send e-mail for non users
$to_email = $to_entity->name . "<" . $to_entity->email . ">";
$site = elgg_get_site_entity($this->site_guid);
if ($site->email) {
if ($site->name) {
$site_from = $site->name . " <" . $site->email . ">";
} else {
$site_from = $site->email;
}
} else {
// no site email, so make one up
if ($site->name) {
$site_from = $site->name . " <noreply@" . $site->getDomain() . ">";
} else {
$site_from = "noreply@" . $site->getDomain();
}
}
elgg_send_email($site_from, $to_email, $user_subject, $user_message);
}
elgg_set_ignore_access($ia);
}