Exemple #1
0
 /**
  * Clean up old session data etc
  * @param int $maxlifetime - maximum old sesion lifetime in seconds
  * @return bool - true on success
  */
 public function gc($maxlifetime)
 {
     // destroy any abandoned sessions after $maxlifetime in seconds
     // create delete query
     $query = "delete from " . $this->cfg->sessionTable . " where " . $this->db->qt("SessionTime") . " < ?";
     $values = array(time() - $maxlifetime);
     $this->db->query($query, $values, "SSP Session: Clean up old sessions");
     // clean up token table
     SSP_CleanToken();
     SSP_ResponseClean();
     return true;
 }
Exemple #2
0
/**
 * Checks that the token supplied by the form is valid
 * @param string $token - token to be checked
 * @param string $id - id of form from which the token comes
 * @return bool - true on match
 */
function SSP_TokenCheck($token, $id)
{
    $SSP_Config = Configuration::getConfiguration();
    $SSP_DB = SspDb::getConnection();
    $tokenOk = false;
    // check is hex token
    $check = new \w34u\ssp\CheckData();
    if ($check->check('hex', $token) !== 0) {
        return false;
    }
    SSP_CleanToken();
    // Form token field exists
    $where = array("token" => $token, "id" => $id);
    $SSP_DB->delete($SSP_Config->tokenTable, $where, "SSP Functions: Deleting token");
    if ($SSP_DB->affectedRows()) {
        // token found and deleted
        $tokenOk = true;
    }
    return $tokenOk;
}