]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
CSRF protection in user registration
[quix0rs-gnu-social.git] / lib / util.php
index e14cc36aced85fec86ac35dd6aac3fe55a6c444f..f06f49d71be682e9660a962237a646ddc9115b3a 100644 (file)
@@ -173,6 +173,8 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=
 
        # FIXME: correct language for interface
 
+       $language = common_language();
+       
        common_element_start('html', array('xmlns' => 'http://www.w3.org/1999/xhtml',
                                                                           'xml:lang' => $language,
                                                                           'lang' => $language));
@@ -1475,3 +1477,11 @@ function common_canonical_sms($sms) {
        preg_replace('/\D/', '', $sms);
        return $sms;
 }
+
+function common_session_token() {
+       common_ensure_session();
+       if (!array_key_exists('token', $_SESSION)) {
+               $_SESSION['token'] = common_good_rand(64);
+       }
+       return $_SESSION['token'];
+}