1 | <?php |
||
4 | class CSRFToken Extends Base { |
||
5 | public $valid = 0; |
||
6 | /** |
||
7 | * Gets a basic csrf token |
||
8 | * @param string $user user or IP/host address |
||
9 | * @param string $type page name or other unique per-page identifier |
||
10 | */ |
||
11 | public function getBasic($user, $type) { |
||
17 | |||
18 | /** |
||
19 | * Returns +1 min up to +15 min rollovers hashes |
||
20 | * @param string $user user or IP/host address |
||
21 | * @param string $type page name or other unique per-page identifier |
||
22 | * @return array 1 minute ago up to 15 minute ago hashes |
||
23 | */ |
||
24 | |||
25 | public function checkAdditional($user, $type) { |
||
36 | |||
37 | /** |
||
38 | * Builds a seed with the given data |
||
39 | * @param string $data |
||
40 | * @param int $year |
||
41 | * @param int $month |
||
42 | * @param int $day |
||
43 | * @param int $hour |
||
44 | * @param int $minute |
||
45 | * @return string seed |
||
46 | */ |
||
47 | private function buildSeed($data, $year, $month, $day, $hour, $minute) { |
||
50 | |||
51 | /** |
||
52 | * Checks if the token is correct as is, if not checks for rollovers with checkAdditional() |
||
53 | * @param string $user user or IP/host address |
||
54 | * @param string $type page name or other unique per-page identifier |
||
55 | * @param string $token token to check against |
||
56 | * @return boolean |
||
57 | */ |
||
58 | public function checkBasic($user, $type, $token) { |
||
72 | |||
73 | /** |
||
74 | * Convenience method to get a token expired message with a token type, and ? image with description |
||
75 | * @param string $tokentype if you want a specific tokentype, set it here |
||
76 | * @param string $dowhat What will be put in the string "Simply $dowhat again to...", default is try |
||
77 | */ |
||
78 | public static function getErrorWithDescriptionHTML($tokentype="", $dowhat="try") { |
||
81 | |||
82 | /** |
||
83 | * Gets the HTML image (?) with short csrf description for users for the incorrect token error message |
||
84 | * @param dowhat string What will be put in the string "Simply $dowhat again to...", default is try |
||
85 | * @return string HTML image with description |
||
86 | */ |
||
87 | public static function getDescriptionImageHTML($dowhat="try") { |
||
94 | |||
95 | private function getHash($string) { |
||
98 | } |
||
99 | |||
110 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: