/** * Create a member login cookie. * * @param MEMBER The member id * @param ?SHORT_TEXT The username (NULL: lookup) * @param string The password */ function forum_create_cookie($id, $name, $password) { unset($name); unset($password); list($stub, ) = explode(':', get_member_cookie()); if (!$GLOBALS['SMF_NEW'] || !function_exists('sha1')) { $row = $this->get_member_row($id); $_password = $this->forum_md5($row['passwd'], 'ys'); $bits = explode('::', $_password); $_password = $bits[0]; } elseif (function_exists('sha1')) { $row = $this->get_member_row($id); $_password = sha1($row['passwd'] . $row['passwordSalt']); } $data = array($id, $_password, time() + get_cookie_days() * 24 * 60 * 60, 3); ocp_setcookie($stub, serialize($data)); $_COOKIE[$stub] = strval($id); }
/** * Create a cookie, inside ocPortal's cookie environment. * * @param string The name of the cookie * @param string The value to store in the cookie * @param boolean Whether it is a session cookie (gets removed once the browser window closes) * @param boolean Whether the cookie should not be readable by Javascript * @return boolean The result of the PHP setcookie command */ function ocp_setcookie($name, $value, $session = false, $http_only = false) { if ($GLOBALS['DEBUG_MODE'] && !running_script('occle') && get_forum_type() == 'ocf' && get_param_integer('keep_debug_has_cookies', 0) == 0) { return true; } $cookie_domain = get_cookie_domain(); $path = get_cookie_path(); if ($path == '') { $base_url = get_base_url(); $pos = strpos($base_url, '/'); if ($pos === false) { $path = '/'; } else { $path = substr($base_url, $pos) . '/'; } } $time = $session ? NULL : time() + get_cookie_days() * 24 * 60 * 60; if ($cookie_domain == '') { $output = @setcookie($name, $value, $time, $path); } else { if (!$http_only) { $output = @setcookie($name, $value, $time, $path, $cookie_domain); } else { if (PHP_VERSION < 5.2) { $output = @setcookie($name, $value, $time, $path, $cookie_domain . '; HttpOnly'); } else { $output = @call_user_func_array('setcookie', array($name, $value, $time, $path, $cookie_domain, 0, true)); // For Phalanger //$output=@setcookie($name,$value,$time,$path,$cookie_domain,0,true); } } } if ($name != 'has_cookies') { $_COOKIE[$name] = get_magic_quotes_gpc() ? addslashes($value) : $value; } return $output; }