Version 1.2 ()
------------------------------------------------------------------------
+ * Support shared http/https sessions. Performing admin actions will
+ only be allowed (through tokens) on the protocol that was used for
+ login. Patch by Rob Richards
+ (http://board.s9y.org/viewtopic.php?p=49276)
+
* Added PDO:PostgreSQL support (Theo Schlossnagle)
* Dutch translation update with many fixes by Sam Geeraerts
return $cookie;
}
+function serendipity_setAuthorToken() {
+ $hash = sha1(uniqid(rand(), true));
+ serendipity_setCookie('author_token', $hash);
+ $_SESSION['author_token'] = $hash;
+}
+
/**
* Perform user authentication routine
*
$row =& serendipity_db_query($query, true, 'assoc');
if (is_array($row)) {
- serendipity_setCookie('old_session', session_id());
+ serendipity_setCookie('old_session', session_id(), false);
+ if (!$is_md5) {
+ serendipity_setAuthorToken();
+ }
$_SESSION['serendipityUser'] = $serendipity['serendipityUser'] = $username;
$_SESSION['serendipityRealname'] = $serendipity['serendipityRealname'] = $row['realname'];
$_SESSION['serendipityPassword'] = $serendipity['serendipityPassword'] = $password;
* @param string The contents of the cookie variable
* @return null
*/
-function serendipity_setCookie($name,$value) {
+function serendipity_setCookie($name, $value, $securebyprot = true) {
global $serendipity;
- $secure = (strtolower($_SERVER['HTTPS']) == 'on') ? true : false;
+ if ($securebyprot) {
+ $secure = (strtolower($_SERVER['HTTPS']) == 'on') ? true : false;
+ } else {
+ $secure = false;
+ }
setcookie("serendipity[$name]", $value, time()+60*60*24*30, $serendipity['serendipityHTTPPath'], $_SERVER['HTTP_HOST'], $secure);
$_COOKIE[$name] = $value;
$serendipity['COOKIE'][$name] = $value;
if (isset($_REQUEST['user_template']) && (in_array($_REQUEST['user_template'], serendipity_fetchTemplates())) ) {
$_SESSION['serendipityUseTemplate'] = $_REQUEST['user_template'];
- serendipity_setCookie('user_template', $_REQUEST['user_template']);
+ serendipity_setCookie('user_template', $_REQUEST['user_template'], false);
}
if (isset($_SESSION['serendipityUseTemplate']) ) {
case 'atom1.0':
// For people wanting extra RFC compliance
- // header('Content-Type: application/atom+xml; charset=utf8');
+ // header('Content-Type: application/atom+xml; charset=utf-8');
$namespace_hook = 'frontend_display:atom-1.0:namespace';
break;
}
if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'logout') {
serendipity_logout();
} else {
- if (IS_installed === true && !serendipity_userLoggedIn()) {
- // Try again to log in, this time with enabled external authentication event hook
- serendipity_login(true);
+ if (IS_installed === true) {
+ /* Check author token to insure session not hijacked */
+ if (!isset($_SESSION['author_token']) || !isset($serendipity['COOKIE']['author_token']) ||
+ ($_SESSION['author_token'] !== $serendipity['COOKIE']['author_token'])) {
+ $_SESSION['serendipityAuthedUser'] = false;
+ @session_destroy();
+ }
+ if (!serendipity_userLoggedIn()) {
+ // Try again to log in, this time with enabled external authentication event hook
+ serendipity_login(true);
+ }
}
}
@define('S9Y_FRAMEWORK', true);
if (!headers_sent()) {
- if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
- @ini_set('session.name', 'SSLSID');
- @ini_set('session.cookie_secure', '1');
- }
session_start();
}