diff options
| author | Savetheinternet <savetheinternet@tinyboard.org> | 2011-06-03 17:36:36 +1000 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@tinyboard.org> | 2011-06-03 17:36:36 +1000 |
| commit | 6ce881284330487fe3dff3cf740f6befc49914de (patch) | |
| tree | 53985d09464f740fcb67ecb7b64292aa9c660d34 | |
| parent | 399a5ab5d10d7db4083c4af62326f3f4e6c97280 (diff) | |
safer IP address decryption (KU_RANDOMSEED)
| -rwxr-xr-x | kusabax.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kusabax.php b/kusabax.php index 9f6ea7a5..6b17499a 100755 --- a/kusabax.php +++ b/kusabax.php @@ -188,7 +188,14 @@ } // IP - $query->bindValue(':ip', md5_decrypt($post['ip'], $kusabaxc['randomseed']), PDO::PARAM_STR); + $ip = md5_decrypt($post['ip'], $kusabaxc['randomseed']); + if(!preg_match('/^\d+\.\d+\.\d+\.\d+$/', $ip)) { + // Invalid IP address. Wrong KU_RANDOMSEED? + + $log[] = 'Invalid IP address returned after decryption. Wrong KU_RANDOMSEED?'; + $ip = '0.0.0.0'; // just set it to something valid and continue + } + $query->bindValue(':ip', $ip, PDO::PARAM_STR); // Time (`timestamp`) $query->bindValue(':time', $post['timestamp'], PDO::PARAM_INT); |
