| @@ -16,8 +16,12 @@ | ||
| 16 | 16 | $this->secret = $secret; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public static function find($settings, $public) { |
| 20 | + if (!is_string($public)) { | |
| 21 | + return null; | |
| 22 | + } | |
| 23 | + | |
| 20 | 24 | $accounts = self::allAccounts($settings); |
| 21 | 25 | if (array_key_exists($public, $accounts) && isset($accounts[$public]['secret'])) { |
| 22 | 26 | $secret = $accounts[$public]['secret']; |
| 23 | 27 | } |
| @@ -42,14 +46,18 @@ | ||
| 42 | 46 | |
| 43 | 47 | $str = ""; |
| 44 | 48 | $size = strlen($chars); |
| 45 | 49 | for( $i = 0; $i < $length; $i++ ) { |
| 46 | - $str .= $chars[rand(0, $size - 1)]; | |
| 50 | + $str .= $chars[random_int(0, $size - 1)]; | |
| 47 | 51 | } |
| 48 | 52 | return $str; |
| 49 | 53 | } |
| 50 | 54 | |
| 51 | 55 | public static function sanitizeKey($key) { |
| 56 | + if (!is_string($key)) { | |
| 57 | + return ''; | |
| 58 | + } | |
| 59 | + | |
| 52 | 60 | return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
| 53 | 61 | } |
| 54 | 62 | |
| 55 | 63 | public static function apiPublicAccount($settings) { |
| @@ -236,5 +244,5 @@ | ||
| 236 | 244 | $accounts = self::allAccounts($settings); |
| 237 | 245 | return array_key_exists($pubkey, $accounts); |
| 238 | 246 | } |
| 239 | 247 | } |
| 240 | -endif; | |
| 248 | +endif; | |