* \endcode * * @param array $attributes Additional attributes to be added to the input * @return string the HTML snippet containing the input element */ public static function tokenTag(array $attributes = []) { $attributes = array_merge($attributes, [ 'name' => self::TOKEN, 'value' => self::token(), ]); return sprintf( '', arrayToHtmlAttributes($attributes) ); } /** * returns a random string token for XSRF prevention * the string is stored in the session * * @static * @return string */ public static function sessionticket() { $storage = &self::getStorage(); if (empty($storage['studipticket'])) { $storage['studipticket'] = md5(uniqid('studipticket', 1)); } return $storage['studipticket']; } /** * checks the given string token against the one stored * in the session * * @static * @param string $studipticket * @return bool */ public static function verifySessionticket($studipticket) { $storage = &self::getStorage(); $check = (isset($storage['studipticket']) && $storage['studipticket'] === $studipticket); $storage['studipticket'] = null; return $check; } }