X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=api.php;h=bb89c55d924e572ae048d443e89f739738683991;hp=fda62ff32389e1a630759a43e5d3643b9b44d29e;hb=756e90840f47c110d346c863238375bb59a10475;hpb=939514b912738c5784b04a0d207db1afd918eb69 diff --git a/api.php b/api.php index fda62ff..bb89c55 100644 --- a/api.php +++ b/api.php @@ -192,8 +192,14 @@ function setcookies ($user, $pwd) { // cookie will be valid for 2 weeks. I've chosen that value // arbitrarily, and it may change in the future. $time = time () + 14 * 60 * 24 * 60; - setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false, true); - setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false, true); + if (version_compare (PHP_VERSION, '5.2.0', '>=')) { + setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false, true); + setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false, true); + } else { + setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false); + setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false); + } + } function check_auth ($con, $user, $pwd, $auth_only) { @@ -239,7 +245,7 @@ function main ($con) { if (!isset ($feature)) { error_unreferenced ($id); } - if ($feature->user != $user) { + if (($feature->user != $user) && ($user != "admin")) { error_unauthorized (); }