Remove all the {{{ and }}} folding

This commit is contained in:
2022-11-25 20:34:27 +01:00
parent b723f47a44
commit 2d6df0d5f0
35 changed files with 0 additions and 1124 deletions

View File

@@ -30,7 +30,6 @@ class Csrf
/** Manage the singleton
*/
public function __construct ()
// {{{
{
if (isset ($GLOBALS["domframework"]["csrf"]))
{
@@ -43,13 +42,11 @@ class Csrf
$GLOBALS["domframework"]["csrf"] = $this;
}
}
// }}}
/** Get / Set the status of the CSRF protection
* @param boolean|null $val The value to set/get if null
*/
public function csrfState ($val = null)
// {{{
{
if ($val === null)
return $this->csrf;
@@ -57,13 +54,11 @@ class Csrf
$GLOBALS["domframework"]["csrf"] = $this;
return $this;
}
// }}}
/** Get / Set the name of the field in HTML
* @param string|null $val The value to set/get if null
*/
public function field ($val = null)
// {{{
{
if ($val === null)
return $this->field;
@@ -71,12 +66,10 @@ class Csrf
$GLOBALS["domframework"]["csrf"] = $this;
return $this;
}
// }}}
/** This function return the token
*/
public function createToken ()
// {{{
{
$l = 30; // Number of chars in token
$c = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -88,14 +81,12 @@ class Csrf
$GLOBALS["domframework"]["csrf"] = $this;
return $this->csrfToken;
}
// }}}
/** Check if the provided token is the right token, defined last displayed
* page
* @param string $tokenFromUser The value csrf the user's token
*/
public function checkToken ($tokenFromUser)
// {{{
{
if ($this->csrf === FALSE )
return TRUE;
@@ -135,12 +126,10 @@ class Csrf
}
return TRUE;
}
// }}}
/** Return the CSRF token in a hidden field
*/
public function displayFormCSRF ()
// {{{
{
if ($this->csrfToken == "")
$this->createToken ();
@@ -148,40 +137,33 @@ class Csrf
$res .= "value='$this->csrfToken'/>\n";
return $res;
}
// }}}
/** Return the token if exists or create a new one if needed
*/
public function getToken ()
// {{{
{
if ($this->csrfToken === "")
$this->createToken ();
return $this->csrfToken;
}
// }}}
/** Add more time to existing CSRF token
* @param string $tokenFromUser The existing token
*/
public function extendToken ($tokenFromUser)
// {{{
{
$this->checkToken ($tokenFromUser);
$_SESSION["domframework"]["csrf"][$tokenFromUser] = microtime (TRUE);
return true;
}
// }}}
/** Check an existing token, then delete it
* @param string $tokenFromUser The existing token
*/
public function checkThenDeleteToken ($tokenFromUser)
// {{{
{
$this->checkToken ($tokenFromUser);
unset ($_SESSION["domframework"]["csrf"][$tokenFromUser]);
return true;
}
// }}}
}