X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=code%2Fconfig.php;h=32d8076e4f8249e718ac98f5d9269b0d0da8511e;hb=ee6685eef368fdd21c4916b32a0ad26880146cce;hp=60d5c1f40916c84910572dd6b21e98ede8aeb35f;hpb=1bcde3c6ba88a93deaa0848df4de0b0857d9bf49;p=contractor-progress.git diff --git a/code/config.php b/code/config.php index 60d5c1f..32d8076 100644 --- a/code/config.php +++ b/code/config.php @@ -20,3 +20,37 @@ function logged_in_as_admin() { function logged_in_as_contractor() { return logged_in_as_admin(); } + +function enc_money($float) { + return format_money($float, $cents = true); +} + +function logged_in() { + return session_exists_and_authed(); +} + +# 1st arg: the correct encrypted password +# 2nd arg: clear-text password entered by someone +function check_password($encrypted, $pass) { + if(strpos($encrypted, ':') !== 32) { + die("password field corrupted"); + } + + list($md5, $salt) = explode(':', $encrypted); + + if(md5($salt . $pass) == $md5) { + return true; + } + + return false; +} + +function encrypt_password($plain) { + $password = ''; + + $salt = substr(md5(rand() . "f"), 0, 2); # FIXME make this more effecient and clear + + $password = md5($salt . $plain) . ':' . $salt; + + return $password; +}