Fix bug #2834111: Patch to detect if cookies are enabled
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@345 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
362ebe90ea
commit
14f617d641
2 changed files with 47 additions and 4 deletions
|
@ -24,6 +24,7 @@ class UserService {
|
||||||
$this->sessionkey = INSTALLATION_ID.'-currentuserid';
|
$this->sessionkey = INSTALLATION_ID.'-currentuserid';
|
||||||
$this->cookiekey = INSTALLATION_ID.'-login';
|
$this->cookiekey = INSTALLATION_ID.'-login';
|
||||||
$this->profileurl = createURL('profile', '%2$s');
|
$this->profileurl = createURL('profile', '%2$s');
|
||||||
|
$this->updateSessionStability();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _checkdns($host) {
|
function _checkdns($host) {
|
||||||
|
@ -54,11 +55,14 @@ class UserService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row =& $this->db->sql_fetchrow($dbresult))
|
$row =& $this->db->sql_fetchrow($dbresult);
|
||||||
|
$this->db->sql_freeresult($dbresult);
|
||||||
|
if ($row) {
|
||||||
return $row;
|
return $row;
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function & getUsers($nb=0) {
|
function & getUsers($nb=0) {
|
||||||
$query = 'SELECT * FROM '. $this->getTableName() .' ORDER BY `uId` DESC';
|
$query = 'SELECT * FROM '. $this->getTableName() .' ORDER BY `uId` DESC';
|
||||||
|
@ -313,6 +317,7 @@ class UserService {
|
||||||
|
|
||||||
$arrWatch = array();
|
$arrWatch = array();
|
||||||
if ($this->db->sql_numrows($dbresult) == 0) {
|
if ($this->db->sql_numrows($dbresult) == 0) {
|
||||||
|
$this->db->sql_freeresult($dbresult);
|
||||||
return $arrWatch;
|
return $arrWatch;
|
||||||
}
|
}
|
||||||
while ($row =& $this->db->sql_fetchrow($dbresult)) {
|
while ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||||
|
@ -504,6 +509,38 @@ class UserService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a session variable.
|
||||||
|
* Updates it when it is already set.
|
||||||
|
* This is used to detect if cookies work.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @see isSessionStable()
|
||||||
|
*/
|
||||||
|
function updateSessionStability() {
|
||||||
|
//find out if we have cookies enabled
|
||||||
|
if (!isset($_SESSION['sessionStable']))) {
|
||||||
|
$_SESSION['sessionStable'] = 0;
|
||||||
|
} else {
|
||||||
|
$_SESSION['sessionStable'] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells you if the session is fresh or old.
|
||||||
|
* If the session is fresh, it's the first page
|
||||||
|
* call with that session id. If the session is old,
|
||||||
|
* we know that cookies (or session persistance) works
|
||||||
|
*
|
||||||
|
* @return boolean True if the
|
||||||
|
*
|
||||||
|
* @see updateSessionStability()
|
||||||
|
*/
|
||||||
|
function isSessionStable() {
|
||||||
|
return $_SESSION['sessionStable'] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
function getTableName() { return $this->tablename; }
|
function getTableName() { return $this->tablename; }
|
||||||
function setTableName($value) { $this->tablename = $value; }
|
function setTableName($value) { $this->tablename = $value; }
|
||||||
|
|
|
@ -8,6 +8,12 @@ window.onload = function() {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (!$userservice->isSessionStable()) {
|
||||||
|
echo '<p class="error">'.T_('Please activate cookies').'</p>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<form action="<?php echo $formaction; ?>" method="post">
|
<form action="<?php echo $formaction; ?>" method="post">
|
||||||
<div><input type="hidden" name="query" value="<?php echo $querystring; ?>" /></div>
|
<div><input type="hidden" name="query" value="<?php echo $querystring; ?>" /></div>
|
||||||
<table>
|
<table>
|
||||||
|
|
Loading…
Reference in a new issue