aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorHenry Sudhof <kellanved@phpbb.com>2008-08-21 15:50:21 +0000
committerHenry Sudhof <kellanved@phpbb.com>2008-08-21 15:50:21 +0000
commit3a3b9eb8efe08f086bcbd1d88a34355e31df7650 (patch)
tree08305a29fb8ea7fac59c507187243436ac2827b4 /phpBB/includes/functions.php
parent76a542a03e11db7fbe61e8c151f0d7f8124fd7d1 (diff)
downloadforums-3a3b9eb8efe08f086bcbd1d88a34355e31df7650.tar
forums-3a3b9eb8efe08f086bcbd1d88a34355e31df7650.tar.gz
forums-3a3b9eb8efe08f086bcbd1d88a34355e31df7650.tar.bz2
forums-3a3b9eb8efe08f086bcbd1d88a34355e31df7650.tar.xz
forums-3a3b9eb8efe08f086bcbd1d88a34355e31df7650.zip
merge
git-svn-id: file:///svn/phpbb/trunk@8776 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 15936d2091..427c372957 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2014,6 +2014,37 @@ function meta_refresh($time, $url)
//Form validation
+
+/**
+* Add a secret hash for use in links/GET requests
+* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply
+* @param int $length The length of the key to generate
+* @return sting the hash
+
+*/
+function generate_link_hash($link_name)
+{
+ global $user;
+ if (!isset($user->data["hash_$link_name"]))
+ {
+ $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8);
+ }
+ return $user->data["hash_$link_name"];
+}
+
+
+/**
+* checks a link hash - for GET requests
+* @param string $token the submitted token
+* @param string $link_name The name of the link; has to match the name used in check_form_key, otherwise no restrictions apply
+* @param int $length The length of the key to check
+* @return boolean true if all is fine
+*/
+function check_link_hash($token, $link_name)
+{
+ return $token === generate_link_hash($link_name);
+}
+
/**
* Add a secret token to the form (requires the S_FORM_TOKEN template variable)
* @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply