From: arno Date: Thu, 20 Aug 2009 09:30:24 +0000 (+0200) Subject: fixe setcookie calls for php < 5.2.0 X-Git-Tag: v0.3b_thomas~7 X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=commitdiff_plain;h=756e90840f47c110d346c863238375bb59a10475 fixe setcookie calls for php < 5.2.0 --- diff --git a/api.php b/api.php index 9b268dc..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) { diff --git a/logout.php b/logout.php index 25d55a9..037252c 100644 --- a/logout.php +++ b/logout.php @@ -6,7 +6,12 @@ if (!@include_once ("./inc/settings.php")) { header ('Location: index.php'); } -setcookie (sprintf ("%sauth", DBPREFIX), "", time () - 3600, "" , "",false, true); -setcookie (sprintf ("%suser", DBPREFIX), "", time () - 3600, "" , "",false, true); +if (version_compare (PHP_VERSION, '5.2.0', '>=')) { + setcookie (sprintf ("%sauth", DBPREFIX), "", time () - 3600, "" , "",false, true); + setcookie (sprintf ("%suser", DBPREFIX), "", time () - 3600, "" , "",false, true); +} else { + setcookie (sprintf ("%sauth", DBPREFIX), "", time () - 3600, "" , "",false); + setcookie (sprintf ("%suser", DBPREFIX), "", time () - 3600, "" , "",false); +} header ('Location: index.php'); ?>