summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes97
-rw-r--r--action.php36
-rw-r--r--admin_media.php3
-rw-r--r--admin_pgv_to_wt.php44
-rw-r--r--admin_site_access.php2
-rw-r--r--admin_site_change.php3
-rw-r--r--admin_site_logs.php3
-rw-r--r--admin_trees_download.php2
-rw-r--r--app/Auth.php15
-rw-r--r--app/Controller/AjaxController.php4
-rw-r--r--app/Controller/BaseController.php5
-rw-r--r--app/Controller/IndividualController.php4
-rw-r--r--app/Controller/LifespanController.php10
-rw-r--r--app/Controller/PageController.php5
-rw-r--r--app/Controller/SearchController.php6
-rw-r--r--app/Filter.php10
-rw-r--r--app/FlashMessages.php23
-rw-r--r--app/HitCounter.php18
-rw-r--r--app/I18N.php6
-rw-r--r--app/Module/ClippingsCart/ClippingsCart.php36
-rw-r--r--app/Module/ClippingsCartModule.php39
-rw-r--r--app/Module/DescendancyModule.php3
-rw-r--r--app/Module/FamiliesSidebarSidebarModule.php3
-rw-r--r--app/Module/GoogleMapsModule.php2
-rw-r--r--app/Module/IndividualSidebarModule.php3
-rw-r--r--app/Module/InteractiveTreeModule.php4
-rw-r--r--app/Module/SiteMapModule.php3
-rw-r--r--app/Session.php110
-rw-r--r--app/Theme/BaseTheme.php17
-rw-r--r--app/Theme/ColorsTheme.php4
-rw-r--r--autocomplete.php5
-rw-r--r--edit_interface.php22
-rw-r--r--expand_view.php4
-rw-r--r--fanchart.php3
-rw-r--r--gedrecord.php3
-rw-r--r--hourglass_ajax.php4
-rw-r--r--includes/functions/functions_print.php6
-rw-r--r--includes/php_53_compatibility.php7
-rw-r--r--includes/session.php58
-rw-r--r--index_edit.php11
-rw-r--r--login.php20
-rw-r--r--mediafirewall.php4
-rw-r--r--message.php15
-rw-r--r--setup.php12
-rw-r--r--site-offline.php5
-rw-r--r--site-unavailable.php3
-rw-r--r--statistics.php7
-rw-r--r--vendor/composer/autoload_classmap.php1
48 files changed, 324 insertions, 386 deletions
diff --git a/.gitattributes b/.gitattributes
index 22943b5421..ee62d723e5 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,52 +7,53 @@ Makefile export-ignore
build/ export-ignore
js/*.patch export-ignore
phpunit.xml export-ignore
-library/bombayworks/zendframework1/library/Zend/Acl/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Amf/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Application/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Auth/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Barcode/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Captcha/ export-ignore
-library/bombayworks/zendframework1/library/Zend/CodeGenerator/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Console/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Config/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Crypt/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Currency/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Date/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Db/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Dojo/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Dom/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Feed/ export-ignore
-library/bombayworks/zendframework1/library/Zend/File/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Form/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Gdata/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Infocard/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Json/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Locale/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Layout/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Ldap/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Log/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Markup/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Measure/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Memory/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Navigation/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Oauth/ export-ignore
-library/bombayworks/zendframework1/library/Zend/OpenId/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Paginator/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Pdf/ export-ignore
-library/bombayworks/zendframework1/library/Zend/ProgressBar/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Queue/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Reflection/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Rest/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Search/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Serializer/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Service/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Soap/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Test/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Text/ export-ignore
-library/bombayworks/zendframework1/library/Zend/TimeSync/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Tool/ export-ignore
-library/bombayworks/zendframework1/library/Zend/View/ export-ignore
-library/bombayworks/zendframework1/library/Zend/Wildfire/ export-ignore
-library/bombayworks/zendframework1/library/Zend/XmlRpc/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Acl/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Amf/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Application/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Auth/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Barcode/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Captcha/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/CodeGenerator/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Console/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Config/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Crypt/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Currency/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Date/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Db/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Dojo/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Dom/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Feed/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/File/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Form/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Gdata/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Infocard/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Json/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Locale/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Layout/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Ldap/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Log/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Markup/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Measure/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Memory/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Navigation/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Oauth/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/OpenId/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Paginator/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Pdf/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/ProgressBar/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Queue/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Reflection/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Rest/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Search/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Serializer/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Service/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Session/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Soap/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Test/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Text/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/TimeSync/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Tool/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/View/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/Wildfire/ export-ignore
+vendor/bombayworks/zendframework1/library/Zend/XmlRpc/ export-ignore
tests/ export-ignore
diff --git a/action.php b/action.php
index 3c2a7eed00..b3aab03175 100644
--- a/action.php
+++ b/action.php
@@ -16,16 +16,12 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-use Zend_Session_Namespace;
-
/**
* Defined in session.php
*
- * @global Zend_Session_Namespace $WT_SESSION
- * @global Tree $WT_TREE
+ * @global Tree $WT_TREE
*/
-global $WT_SESSION, $WT_TREE;
+global $WT_TREE;
define('WT_SCRIPT_NAME', 'action.php');
require './includes/session.php';
@@ -33,7 +29,6 @@ require './includes/session.php';
header('Content-type: text/html; charset=UTF-8');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
http_response_code(406);
return;
@@ -71,18 +66,20 @@ case 'copy-fact':
$type = $record::RECORD_TYPE; // paste only to the same record type
break;
}
- if (!is_array($WT_SESSION->clipboard)) {
- $WT_SESSION->clipboard = array();
+ $clipboard = Session::get('clipboard');
+ if (!is_array($clipboard)) {
+ $clipboard = array();
}
- $WT_SESSION->clipboard[$fact_id] = array(
+ $clipboard[$fact_id] = array(
'type' =>$type,
'factrec'=>$fact->getGedcom(),
'fact' =>$fact->getTag()
);
// The clipboard only holds 10 facts
- while (count($WT_SESSION->clipboard) > 10) {
- array_shift($WT_SESSION->clipboard);
+ while (count($clipboard) > 10) {
+ array_shift($clipboard);
}
+ Session::put('clipboard', $clipboard);
FlashMessages::addMessage(I18N::translate('The record has been copied to the clipboard.'));
break 2;
}
@@ -92,13 +89,13 @@ case 'copy-fact':
case 'paste-fact':
// Paste a fact from the clipboard
- $xref = Filter::post('xref', WT_REGEX_XREF);
- $fact_id = Filter::post('fact_id');
-
- $record = GedcomRecord::getInstance($xref, $WT_TREE);
+ $xref = Filter::post('xref', WT_REGEX_XREF);
+ $fact_id = Filter::post('fact_id');
+ $record = GedcomRecord::getInstance($xref, $WT_TREE);
+ $clipboard = Session::get('clipboard');
- if ($record && $record->canEdit() && isset($WT_SESSION->clipboard[$fact_id])) {
- $record->createFact($WT_SESSION->clipboard[$fact_id]['factrec'], true);
+ if ($record && $record->canEdit() && isset($clipboard[$fact_id])) {
+ $record->createFact($clipboard[$fact_id]['factrec'], true);
}
break;
@@ -226,7 +223,7 @@ case 'theme':
// Change the current theme
$theme = Filter::post('theme');
if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
- $WT_SESSION->theme_id = $theme;
+ Session::put('theme_id', $theme);
// Remember our selection
Auth::user()->setPreference('theme', $theme);
} else {
@@ -235,4 +232,3 @@ case 'theme':
}
break;
}
-Zend_Session::writeClose();
diff --git a/admin_media.php b/admin_media.php
index f8b7d62521..d58342aa6e 100644
--- a/admin_media.php
+++ b/admin_media.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
define('WT_SCRIPT_NAME', 'admin_media.php');
require './includes/session.php';
@@ -85,7 +83,6 @@ if ($delete_file) {
switch ($action) {
case 'load_json':
- Zend_Session::writeClose();
$search = Filter::get('search');
$search = $search['value'];
$start = Filter::getInteger('start');
diff --git a/admin_pgv_to_wt.php b/admin_pgv_to_wt.php
index 0914df0a5f..a1c9e276c1 100644
--- a/admin_pgv_to_wt.php
+++ b/admin_pgv_to_wt.php
@@ -18,15 +18,13 @@ namespace Fisharebest\Webtrees;
use PDO;
use PDOException;
-use Zend_Session_Namespace;
/**
* Defined in session.php
*
- * @global Zend_Session_Namespace $WT_SESSION
- * @global Tree $WT_TREE
+ * @global Tree $WT_TREE
*/
-global $WT_SESSION, $WT_TREE;
+global $WT_TREE;
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
@@ -47,24 +45,24 @@ $error = false;
$PGV_PATH = Filter::post('PGV_PATH');
// We read these variables from PhpGedView's config.php, and set them here in case any are missing.
-$INDEX_DIRECTORY = '';
-$DBHOST = '';
-$DBNAME = '';
-$TBLPREFIX = '';
-$PGV_SCHEMA_VERSION = '';
-$USE_REGISTRATION_MODULE = '';
-$ALLOW_USER_THEMES = '';
-$ALLOW_CHANGE_GEDCOM = '';
-$PGV_SESSION_TIME = '';
-$PGV_SMTP_ACTIVE = '';
-$PGV_SMTP_HOST = '';
-$PGV_SMTP_HELO = '';
-$PGV_SMTP_PORT = '';
-$PGV_SMTP_AUTH = '';
-$PGV_SMTP_AUTH_USER = '';
-$PGV_SMTP_AUTH_PASS = '';
-$PGV_SMTP_SSL = '';
-$PGV_SMTP_FROM_NAME = '';
+$INDEX_DIRECTORY = '';
+$DBHOST = '';
+$DBNAME = '';
+$TBLPREFIX = '';
+$PGV_SCHEMA_VERSION = '';
+$USE_REGISTRATION_MODULE = '';
+$ALLOW_USER_THEMES = '';
+$ALLOW_CHANGE_GEDCOM = '';
+$PGV_SESSION_TIME = '';
+$PGV_SMTP_ACTIVE = '';
+$PGV_SMTP_HOST = '';
+$PGV_SMTP_HELO = '';
+$PGV_SMTP_PORT = '';
+$PGV_SMTP_AUTH = '';
+$PGV_SMTP_AUTH_USER = '';
+$PGV_SMTP_AUTH_PASS = '';
+$PGV_SMTP_SSL = '';
+$PGV_SMTP_FROM_NAME = '';
if ($PGV_PATH) {
if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH . '/config.php')) {
@@ -121,7 +119,7 @@ if ($PGV_PATH) {
if ($PGV_PATH) {
// The account we are using is about to be deleted.
- $WT_SESSION->wt_user = null;
+ Session::forget('wt_user');
}
$controller->pageHeader();
diff --git a/admin_site_access.php b/admin_site_access.php
index 833785624c..52aafe3a90 100644
--- a/admin_site_access.php
+++ b/admin_site_access.php
@@ -18,7 +18,6 @@ namespace Fisharebest\Webtrees;
use PDO;
use Zend_Controller_Request_Http;
-use Zend_Session;
/**
* Defined in session.php
@@ -137,7 +136,6 @@ $controller
$action = Filter::get('action');
switch ($action) {
case 'load':
- Zend_Session::writeClose();
// AJAX callback for datatables
$search = Filter::get('search');
$search = $search['value'];
diff --git a/admin_site_change.php b/admin_site_change.php
index d6e03ae722..8f9d32a6d4 100644
--- a/admin_site_change.php
+++ b/admin_site_change.php
@@ -17,7 +17,6 @@ namespace Fisharebest\Webtrees;
*/
use PDO;
-use Zend_Session;
/**
* Defined in session.php
@@ -121,7 +120,6 @@ case 'delete':
break;
case 'export':
- Zend_Session::writeClose();
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="webtrees-changes.csv"');
$rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll();
@@ -139,7 +137,6 @@ case 'export':
return;
case 'load_json':
- Zend_Session::writeClose();
$start = Filter::getInteger('start');
$length = Filter::getInteger('length');
$order = Filter::getArray('order');
diff --git a/admin_site_logs.php b/admin_site_logs.php
index 9bfeb63955..afb0cec8ab 100644
--- a/admin_site_logs.php
+++ b/admin_site_logs.php
@@ -17,7 +17,6 @@ namespace Fisharebest\Webtrees;
*/
use PDO;
-use Zend_Session;
/**
* Defined in session.php
@@ -108,7 +107,6 @@ case 'delete':
break;
case 'export':
- Zend_Session::writeClose();
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="webtrees-logs.csv"');
$rows = Database::prepare($sql_select . $where . ' ORDER BY log_id')->execute($args)->fetchAll();
@@ -125,7 +123,6 @@ case 'export':
return;
case 'load_json':
- Zend_Session::writeClose();
$start = Filter::getInteger('start');
$length = Filter::getInteger('length');
$order = Filter::getArray('order');
diff --git a/admin_trees_download.php b/admin_trees_download.php
index 2ee25791dd..6c7d8b69da 100644
--- a/admin_trees_download.php
+++ b/admin_trees_download.php
@@ -24,7 +24,6 @@ namespace Fisharebest\Webtrees;
global $WT_TREE;
use PclZip;
-use Zend_Session;
define('WT_SCRIPT_NAME', 'admin_trees_download.php');
require './includes/session.php';
@@ -83,7 +82,6 @@ if ($action === 'download') {
File::delete($temp_dir);
}
} else {
- Zend_Session::writeClose();
header('Content-Type: text/plain; charset=UTF-8');
header('Content-Disposition: attachment; filename="' . $download_filename . '"');
// Stream the GEDCOM file straight to the browser.
diff --git a/app/Auth.php b/app/Auth.php
index 45f3afc791..0bda01a7d1 100644
--- a/app/Auth.php
+++ b/app/Auth.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class Auth - authentication functions
*/
@@ -156,9 +154,7 @@ class Auth {
* @return string|null
*/
public static function id() {
- global $WT_SESSION;
-
- return $WT_SESSION ? $WT_SESSION->wt_user : null;
+ return Session::get('wt_user');
}
/**
@@ -187,17 +183,14 @@ class Auth {
* @param User $user
*/
public static function login(User $user) {
- global $WT_SESSION;
-
- $WT_SESSION->wt_user = $user->getUserId();
- Zend_Session::regenerateId();
+ Session::put('wt_user', $user->getUserId());
+ Session::regenerate(false);
}
/**
* End the session for the current user.
*/
public static function logout() {
- Zend_Session::regenerateId();
- Zend_Session::destroy();
+ Session::regenerate(true);
}
}
diff --git a/app/Controller/AjaxController.php b/app/Controller/AjaxController.php
index d43820e463..b39dd9230b 100644
--- a/app/Controller/AjaxController.php
+++ b/app/Controller/AjaxController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class AjaxController - Base controller for all popup pages
*/
@@ -27,8 +25,6 @@ class AjaxController extends BaseController {
* @return $this
*/
public function pageHeader() {
- // We have finished writing session data, so release the lock
- Zend_Session::writeClose();
// Ajax responses are always UTF8
header('Content-Type: text/html; charset=UTF-8');
$this->page_header = true;
diff --git a/app/Controller/BaseController.php b/app/Controller/BaseController.php
index f7587b0665..53da165b17 100644
--- a/app/Controller/BaseController.php
+++ b/app/Controller/BaseController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class BaseController - Base controller for all other controllers
*/
@@ -130,9 +128,6 @@ class BaseController {
* @return $this
*/
public function pageHeader() {
- // Once we've displayed the header, we should no longer write session data.
- Zend_Session::writeClose();
-
// We've displayed the header - display the footer automatically
$this->page_header = true;
diff --git a/app/Controller/IndividualController.php b/app/Controller/IndividualController.php
index 80623ee95d..9d21a714f3 100644
--- a/app/Controller/IndividualController.php
+++ b/app/Controller/IndividualController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class IndividualController - Controller for the individual page
*/
@@ -106,8 +104,6 @@ class IndividualController extends GedcomRecordController {
header("Content-Type: text/html; charset=UTF-8"); // AJAX calls do not have the meta tag headers and need this set
header("X-Robots-Tag: noindex,follow"); // AJAX pages should not show up in search results, any links can be followed though
- Zend_Session::writeClose();
-
echo $mod->getTabContent();
if (WT_DEBUG_SQL) {
diff --git a/app/Controller/LifespanController.php b/app/Controller/LifespanController.php
index a140491573..628ad738cf 100644
--- a/app/Controller/LifespanController.php
+++ b/app/Controller/LifespanController.php
@@ -64,7 +64,7 @@ class LifespanController extends PageController {
* Startup activity
*/
public function __construct() {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
parent::__construct();
$this->setPageTitle(I18N::translate('Lifespans'));
@@ -105,8 +105,8 @@ class LifespanController extends PageController {
$this->place = $place;
} else {
// Modify an existing list of records
- if (is_array($WT_SESSION->timeline_pids)) {
- $this->pids = $WT_SESSION->timeline_pids;
+ if (is_array(Session::get('timeline_pids'))) {
+ $this->pids = Session::get('timeline_pids');
} else {
$this->pids = array();
}
@@ -122,7 +122,7 @@ class LifespanController extends PageController {
$this->addFamily($this->getSignificantIndividual(), false);
}
}
- $WT_SESSION->timeline_pids = $this->pids;
+ Session::put('timeline_pids', $this->pids);
$this->beginYear = $beginYear;
$this->endYear = $endYear;
@@ -162,7 +162,7 @@ class LifespanController extends PageController {
}
}
}
- $WT_SESSION->timeline_pids = null;
+ Session::forget('timeline_pids');
}
// Sort the array in order of birth year
diff --git a/app/Controller/PageController.php b/app/Controller/PageController.php
index 1832fa9084..560c4b5873 100644
--- a/app/Controller/PageController.php
+++ b/app/Controller/PageController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class PageController Controller for full-page, themed HTML responses
*/
@@ -199,9 +197,6 @@ class PageController extends BaseController {
}
flush();
- // Once we've displayed the header, we should no longer write session data.
- Zend_Session::writeClose();
-
// We've displayed the header - display the footer automatically
$this->page_header = true;
diff --git a/app/Controller/SearchController.php b/app/Controller/SearchController.php
index 324d83c7a8..2113fa9081 100644
--- a/app/Controller/SearchController.php
+++ b/app/Controller/SearchController.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class SearchController - Controller for the search page
*/
@@ -236,7 +234,6 @@ class SearchController extends PageController {
if (count($this->myindilist) == 1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
$indi = $this->myindilist[0];
if ($indi->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $indi->getRawUrl());
exit;
}
@@ -244,7 +241,6 @@ class SearchController extends PageController {
if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
$fam = $this->myfamlist[0];
if ($fam->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $fam->getRawUrl());
exit;
}
@@ -252,7 +248,6 @@ class SearchController extends PageController {
if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
$sour = $this->mysourcelist[0];
if ($sour->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $sour->getRawUrl());
exit;
}
@@ -260,7 +255,6 @@ class SearchController extends PageController {
if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
$note = $this->mynotelist[0];
if ($note->canShowName()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $note->getRawUrl());
exit;
}
diff --git a/app/Filter.php b/app/Filter.php
index 2a5fc13cfb..cbd4ce50e2 100644
--- a/app/Filter.php
+++ b/app/Filter.php
@@ -445,16 +445,16 @@ $_SERVER[$variable]))) {
* @return string
*/
public static function getCsrfToken() {
- global $WT_SESSION;
-
- if ($WT_SESSION->CSRF_TOKEN === null) {
+ if (!Session::has('CSRF_TOKEN')) {
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789';
+ $csrf_token = '';
for ($n = 0; $n < 32; ++$n) {
- $WT_SESSION->CSRF_TOKEN .= substr($charset, mt_rand(0, 61), 1);
+ $csrf_token .= substr($charset, mt_rand(0, 61), 1);
}
+ Session::put('CSRF_TOKEN', $csrf_token);
}
- return $WT_SESSION->CSRF_TOKEN;
+ return Session::get('CSRF_TOKEN');
}
/**
diff --git a/app/FlashMessages.php b/app/FlashMessages.php
index 6456c9a88a..6c804d4b5a 100644
--- a/app/FlashMessages.php
+++ b/app/FlashMessages.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Controller_Action_HelperBroker;
-
/**
* Class FlashMessages - Flash messages allow us to generate messages
* in one context, and display them in another.
@@ -33,9 +31,10 @@ class FlashMessages {
$message = new \stdClass;
$message->text = $text;
$message->status = $status;
- $flash_messenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
- $flash_messenger->addMessage($message);
+ $messages = Session::get('flash_messages', array());
+ $messages[] = $message;
+ Session::put('flash_messages', $messages);
}
/**
@@ -44,20 +43,8 @@ class FlashMessages {
* @return string[]
*/
public static function getMessages() {
- $flash_messenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
-
- $messages = array();
-
- // Get messages from previous requests
- foreach ($flash_messenger->getMessages() as $message) {
- $messages[] = $message;
- }
-
- // Get messages from the current request
- foreach ($flash_messenger->getCurrentMessages() as $message) {
- $messages[] = $message;
- }
- $flash_messenger->clearCurrentMessages();
+ $messages = Session::get('flash_messages', array());
+ Session::forget('flash_messages');
return $messages;
}
diff --git a/app/HitCounter.php b/app/HitCounter.php
index 6e5dff03fa..ffa8f1cf29 100644
--- a/app/HitCounter.php
+++ b/app/HitCounter.php
@@ -30,15 +30,13 @@ class HitCounter {
* @return integer
*/
public static function countHit(Tree $tree, $page, $parameter) {
- global $WT_SESSION;
-
// Don't increment the counter while we stay on the same page.
if (
- $WT_SESSION->last_tree_id === $tree->getTreeId() &&
- $WT_SESSION->last_page === $page &&
- $WT_SESSION->last_parameter === $parameter
+ Session::get('last_tree_id') === $tree->getTreeId() &&
+ Session::get('last_page') === $page &&
+ Session::get('last_parameter') === $parameter
) {
- return $WT_SESSION->last_count;
+ return Session::get('last_count');
}
$page_count = self::getCount($tree, $page, $parameter);
@@ -65,10 +63,10 @@ class HitCounter {
$page_count++;
- $WT_SESSION->last_tree_id = $tree->getTreeId();
- $WT_SESSION->last_page = $page;
- $WT_SESSION->last_parameter = $parameter;
- $WT_SESSION->last_count = $page_count;
+ Session::put('last_tree_id', $tree->getTreeId());
+ Session::put('last_page', $page);
+ Session::put('last_parameter', $parameter);
+ Session::put('last_count', $page_count);
return $page_count;
}
diff --git a/app/I18N.php b/app/I18N.php
index 797aae4dff..a628dd0ea6 100644
--- a/app/I18N.php
+++ b/app/I18N.php
@@ -352,7 +352,7 @@ class I18N {
* @return string $string
*/
public static function init($code = null) {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
if ($code !== null) {
// Create the specified locale
@@ -369,9 +369,9 @@ class I18N {
}
} catch (\Exception $ex) {
}
- } elseif ($WT_SESSION->locale) {
+ } elseif (Session::has('locale')) {
// Previously used
- self::$locale = Locale::create($WT_SESSION->locale);
+ self::$locale = Locale::create(Session::get('locale'));
} else {
// Browser negotiation
$default_locale = new LocaleEnUs;
diff --git a/app/Module/ClippingsCart/ClippingsCart.php b/app/Module/ClippingsCart/ClippingsCart.php
index 1f4923a23d..559514b846 100644
--- a/app/Module/ClippingsCart/ClippingsCart.php
+++ b/app/Module/ClippingsCart/ClippingsCart.php
@@ -17,7 +17,6 @@ namespace Fisharebest\Webtrees;
*/
use PclZip;
-use Zend_Session;
/**
* The clippings cart.
@@ -60,14 +59,12 @@ class ClippingsCart {
* Create the clippings controller
*/
public function __construct() {
- global $WT_TREE, $WT_SESSION;
+ global $WT_TREE;
// Our cart is an array of items in the session
- if (!is_array($WT_SESSION->cart)) {
- $WT_SESSION->cart = array();
- }
- if (!array_key_exists($WT_TREE->getTreeId(), $WT_SESSION->cart)) {
- $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
+ $cart = Session::get('cart', array());
+ if (!array_key_exists($WT_TREE->getTreeId(), $cart)) {
+ $cart[$WT_TREE->getTreeId()] = array();
}
$this->action = Filter::get('action');
@@ -149,12 +146,12 @@ class ClippingsCart {
$this->addFamilyDescendancy($family, $this->level3);
}
}
- uksort($WT_SESSION->cart[$WT_TREE->getTreeId()], __NAMESPACE__ . '\ClippingsCart::compareClippings');
+ uksort($cart[$WT_TREE->getTreeId()], __NAMESPACE__ . '\ClippingsCart::compareClippings');
}
} elseif ($this->action === 'remove') {
- unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$this->id]);
+ unset ($cart[$WT_TREE->getTreeId()][$this->id]);
} elseif ($this->action === 'empty') {
- $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
+ $cart[$WT_TREE->getTreeId()] = array();
} elseif ($this->action === 'download') {
$media = array();
$mediacount = 0;
@@ -194,7 +191,7 @@ class ClippingsCart {
break;
}
- foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
$object = GedcomRecord::getInstance($xref, $WT_TREE);
// The object may have been deleted since we added it to the cart....
if ($object) {
@@ -202,19 +199,19 @@ class ClippingsCart {
// Remove links to objects that aren't in the cart
preg_match_all('/\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
preg_match_all('/\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
preg_match_all('/\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
- if (!array_key_exists($match[1], $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if (!array_key_exists($match[1], $cart[$WT_TREE->getTreeId()])) {
$record = str_replace($match[0], '', $record);
}
}
@@ -259,6 +256,7 @@ class ClippingsCart {
}
}
}
+ Session::put('cart', $cart);
if ($this->IncludeMedia === "yes") {
$this->media_list = $media;
@@ -315,8 +313,6 @@ class ClippingsCart {
* based on the options he or she selected.
*/
function downloadClipping() {
- Zend_Session::writeClose();
-
if ($this->IncludeMedia === 'yes' || $this->Zip === 'yes') {
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="clipping.zip"');
@@ -337,15 +333,15 @@ class ClippingsCart {
* @param GedcomRecord $record
*/
function addClipping(GedcomRecord $record) {
- global $WT_SESSION;
-
if ($record->canShowName()) {
- $WT_SESSION->cart[$record->getTree()->getTreeId()][$record->getXref()] = true;
+ $cart = Session::get('cart');
+ $cart[$record->getTree()->getTreeId()][$record->getXref()] = true;
// Add directly linked records
preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . WT_REGEX_XREF . ')@/', $record->getGedcom(), $matches);
foreach ($matches[1] as $match) {
- $WT_SESSION->cart[$record->getTree()->getTreeId()][$match] = true;
+ $cart[$record->getTree()->getTreeId()][$match] = true;
}
+ Session::put('cart', $cart);
}
}
diff --git a/app/Module/ClippingsCartModule.php b/app/Module/ClippingsCartModule.php
index 66dffedca9..bf5ff3fe7d 100644
--- a/app/Module/ClippingsCartModule.php
+++ b/app/Module/ClippingsCartModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class ClippingsCartModule
*/
@@ -43,15 +41,15 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
switch ($mod_action) {
case 'ajax':
$html = $this->getSidebarAjaxContent();
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
echo $html;
break;
case 'index':
- global $controller, $WT_SESSION, $WT_TREE;
+ global $controller, $WT_TREE;
$MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS');
+ $cart = Session::get('cart');
$clip_ctrl = new ClippingsCart;
$controller = new PageController;
@@ -65,7 +63,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
echo '</script>';
- if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
+ if (!$cart[$WT_TREE->getTreeId()]) {
echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>';
}
@@ -275,7 +273,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
<?php }
}
- if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
+ if (!$cart[$WT_TREE->getTreeId()]) {
if ($clip_ctrl->action != 'add') {
echo I18N::translate('The clippings cart allows you to take extracts (“clippings”) from this family tree and bundle them up into a single file for downloading and subsequent importing into your own genealogy program. The downloadable file is recorded in GEDCOM format.<br><ul><li>How to take clippings?<br>This is really simple. Whenever you see a clickable name (individual, family, or source) you can go to the Details page of that name. There you will see the <b>Add to clippings cart</b> option. When you click that link you will be offered several options to download.</li><li>How to download?<br>Once you have items in your cart, you can download them just by clicking the “Download” link. Follow the instructions and links.</li></ul>');
?>
@@ -416,7 +414,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
<th class="list_label"><?php echo I18N::translate('Remove'); ?></th>
</tr>
<?php
- foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
$record = GedcomRecord::getInstance($xref, $WT_TREE);
if ($record) {
switch ($record::RECORD_TYPE) {
@@ -510,7 +508,9 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
/** {@inheritdoc} */
public function getSidebarAjaxContent() {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
+
+ $cart = Session::get('cart');
$clip_ctrl = new ClippingsCart;
$add = Filter::get('add', WT_REGEX_XREF);
@@ -554,12 +554,15 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
}
}
} elseif ($remove) {
- unset ($WT_SESSION->cart[$WT_TREE->getTreeId()][$remove]);
+ unset ($cart[$WT_TREE->getTreeId()][$remove]);
+ Session::put('cart', $cart);
} elseif (isset($_REQUEST['empty'])) {
- $WT_SESSION->cart[$WT_TREE->getTreeId()] = array();
+ $cart[$WT_TREE->getTreeId()] = array();
+ Session::put('cart', $cart);
} elseif (isset($_REQUEST['download'])) {
return $this->downloadForm($clip_ctrl);
}
+
return $this->getCartList();
}
@@ -569,17 +572,19 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
* @return string
*/
public function getCartList() {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
- // Keep track of the INDI from the parent page, otherwise it will
- // get lost after ajax updates
+ $cart = Session::get('cart', array());
+ if (!array_key_exists($WT_TREE->getTreeId(), $cart)) {
+ $cart[$WT_TREE->getTreeId()] = array();
+ }
$pid = Filter::get('pid', WT_REGEX_XREF);
- if (!$WT_SESSION->cart[$WT_TREE->getTreeId()]) {
+ if (!$cart[$WT_TREE->getTreeId()]) {
$out = I18N::translate('Your clippings cart is empty.');
} else {
$out = '<ul>';
- foreach (array_keys($WT_SESSION->cart[$WT_TREE->getTreeId()]) as $xref) {
+ foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) {
$record = GedcomRecord::getInstance($xref, $WT_TREE);
if ($record instanceof Individual || $record instanceof Family) {
switch ($record::RECORD_TYPE) {
@@ -610,7 +615,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
$out .= '</ul>';
}
- if ($WT_SESSION->cart[$WT_TREE->getTreeId()]) {
+ if ($cart[$WT_TREE->getTreeId()]) {
$out .=
'<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;empty=true&amp;pid=' . $pid . '" class="remove_cart">' .
I18N::translate('Empty the clippings cart') .
@@ -621,7 +626,7 @@ class ClippingsCartModule extends AbstractModule implements ModuleMenuInterface,
'</a>';
}
$record = Individual::getInstance($pid, $WT_TREE);
- if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[$WT_TREE->getTreeId()])) {
+ if ($record && !array_key_exists($record->getXref(), $cart[$WT_TREE->getTreeId()])) {
$out .= '<br><a href="module.php?mod=' . $this->getName() . '&amp;mod_action=ajax&amp;sb_action=clippings&amp;add=' . $pid . '&amp;pid=' . $pid . '" class="add_cart"><i class="icon-clippings"></i> ' . I18N::translate('Add %s to the clippings cart', $record->getFullName()) . '</a>';
}
return $out;
diff --git a/app/Module/DescendancyModule.php b/app/Module/DescendancyModule.php
index 27a3ac277e..0c91123e92 100644
--- a/app/Module/DescendancyModule.php
+++ b/app/Module/DescendancyModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class DescendancyModule
*/
@@ -38,7 +36,6 @@ class DescendancyModule extends AbstractModule implements ModuleSidebarInterface
public function modAction($modAction) {
global $WT_TREE;
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
switch ($modAction) {
diff --git a/app/Module/FamiliesSidebarSidebarModule.php b/app/Module/FamiliesSidebarSidebarModule.php
index 3f678b9b93..a3b2ebd209 100644
--- a/app/Module/FamiliesSidebarSidebarModule.php
+++ b/app/Module/FamiliesSidebarSidebarModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class FamiliesSidebarModule
*/
@@ -36,7 +34,6 @@ class FamiliesSidebarModule extends AbstractModule implements ModuleSidebarInter
public function modAction($modAction) {
switch ($modAction) {
case 'ajax':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
echo $this->getSidebarAjaxContent();
break;
diff --git a/app/Module/GoogleMapsModule.php b/app/Module/GoogleMapsModule.php
index f65de7b409..bf06203da9 100644
--- a/app/Module/GoogleMapsModule.php
+++ b/app/Module/GoogleMapsModule.php
@@ -18,7 +18,6 @@ namespace Fisharebest\Webtrees;
use PDO;
use PDOException;
-use Zend_Session;
/**
* Class GoogleMapsModule
@@ -4110,7 +4109,6 @@ class GoogleMapsModule extends AbstractModule implements ModuleConfigInterface,
$controller->restrictAccess(Auth::isAdmin());
if ($action == 'ExportFile' && Auth::isAdmin()) {
- Zend_Session::writeClose();
$tmp = $this->placeIdToHierarchy($parent);
$maxLevel = $this->getHighestLevel();
if ($maxLevel > 8) $maxLevel = 8;
diff --git a/app/Module/IndividualSidebarModule.php b/app/Module/IndividualSidebarModule.php
index 55a16a5823..e9f4f2ff1e 100644
--- a/app/Module/IndividualSidebarModule.php
+++ b/app/Module/IndividualSidebarModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class IndividualSidebarModule
*/
@@ -36,7 +34,6 @@ class IndividualSidebarModule extends AbstractModule implements ModuleSidebarInt
public function modAction($modAction) {
switch ($modAction) {
case 'ajax':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
echo $this->getSidebarAjaxContent();
break;
diff --git a/app/Module/InteractiveTreeModule.php b/app/Module/InteractiveTreeModule.php
index ea7134cb25..012038c9f0 100644
--- a/app/Module/InteractiveTreeModule.php
+++ b/app/Module/InteractiveTreeModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class InteractiveTreeModule
* Tip : you could change the number of generations loaded before ajax calls both in individual page and in treeview page to optimize speed and server load
@@ -117,7 +115,6 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
break;
case 'getDetails':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$pid = Filter::get('pid', WT_REGEX_XREF);
$i = Filter::get('instance');
@@ -129,7 +126,6 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
break;
case 'getPersons':
- Zend_Session::writeClose();
header('Content-Type: text/html; charset=UTF-8');
$q = Filter::get('q');
$i = Filter::get('instance');
diff --git a/app/Module/SiteMapModule.php b/app/Module/SiteMapModule.php
index 6cba05c33a..3a0dcdee83 100644
--- a/app/Module/SiteMapModule.php
+++ b/app/Module/SiteMapModule.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Class SiteMapModule
*/
@@ -42,7 +40,6 @@ class SiteMapModule extends AbstractModule implements ModuleConfigInterface {
$this->admin();
break;
case 'generate':
- Zend_Session::writeClose();
$this->generate(Filter::get('file'));
break;
default:
diff --git a/app/Session.php b/app/Session.php
new file mode 100644
index 0000000000..499a7ac02e
--- /dev/null
+++ b/app/Session.php
@@ -0,0 +1,110 @@
+<?php
+namespace Fisharebest\Webtrees;
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2015 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Class Session - temporary class to migrate away from Zend_Session
+ * to Symfony-based sessions, which need PHP 5.4
+ */
+class Session {
+ /**
+ * Start a session
+ *
+ * @param array $config
+ */
+ public static function start(array $config = array()) {
+ $default_config = array(
+ 'session.use_cookies' => 1,
+ 'name' => 'WT_SESSION',
+ 'cookie_lifetime' => 0,
+ 'gc_maxlifetime' => 7200,
+ 'gc_probability' => 1,
+ 'gc_divisor' => 100,
+ 'cookie_path' => '',
+ 'cookie_httponly' => true,
+ );
+ session_register_shutdown();
+ foreach ($config + $default_config as $key => $value) {
+ ini_set($key, $value);
+ }
+ session_start();
+ }
+
+ /**
+ * Read a value from the session
+ *
+ * @param string $name
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public static function get($name, $default = null) {
+ if (isset($_SESSION[$name])) {
+ return $_SESSION[$name];
+ } else {
+ return $default;
+ }
+ }
+
+ /**
+ * Write a value to the session
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ public static function put($name, $value) {
+ $_SESSION[$name] = $value;
+ }
+
+ /**
+ * Remove a value from the session
+ *
+ * @param string $name
+ */
+ public static function forget($name) {
+ unset($_SESSION[$name]);
+ }
+
+ /**
+ * Does a session variable exist?
+ *
+ * @param string $name
+ *
+ * @return boolean
+ */
+ public static function has($name) {
+ return array_key_exists($name, $_SESSION);
+ }
+
+ /**
+ * After any change in authentication level, we should use a new session ID.
+ *
+ * @param bool $destroy
+ */
+ public static function regenerate($destroy = false) {
+ session_regenerate_id($destroy);
+ }
+
+ /**
+ * Set an explicit session ID. Typically used for search robots.
+ *
+ * @param string $id
+ */
+ public static function setId($id) {
+ session_id($id);
+ }
+}
diff --git a/app/Theme/BaseTheme.php b/app/Theme/BaseTheme.php
index 3c6b0cc0b0..c7325b45fe 100644
--- a/app/Theme/BaseTheme.php
+++ b/app/Theme/BaseTheme.php
@@ -16,15 +16,10 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session_Namespace;
-
/**
* Class Base - Common functions and interfaces for all themes.
*/
abstract class BaseTheme {
- /** @var Zend_Session_Namespace */
- protected $session;
-
/** @var Tree The current tree */
protected $tree;
@@ -956,21 +951,19 @@ abstract class BaseTheme {
* Initialise the theme. We cannot pass these in a constructor, as the construction
* happens in a theme file, and we need to be able to change it.
*
- * @param Zend_Session_Namespace $session
- * @param Tree|null $tree The current tree (if there is one).
+ * @param Tree|null $tree The current tree (if there is one).
*
* @return void
*/
- final public function init(Zend_Session_Namespace $session, Tree $tree = null) {
- $this->tree = $tree;
- $this->tree_url = $tree ? 'ged=' . $tree->getNameUrl() : '';
- $this->session = $session;
+ final public function init(Tree $tree = null) {
+ $this->tree = $tree;
+ $this->tree_url = $tree ? 'ged=' . $tree->getNameUrl() : '';
$this->hookAfterInit();
}
/**
- * A large webtrees logo, for the footer.
+ * A large webtrees logo, for the header.
*
* @return string
*/
diff --git a/app/Theme/ColorsTheme.php b/app/Theme/ColorsTheme.php
index ba6a054b29..e029ca45b7 100644
--- a/app/Theme/ColorsTheme.php
+++ b/app/Theme/ColorsTheme.php
@@ -86,13 +86,13 @@ class ColorsTheme extends CloudsTheme {
}
unset($_GET['themecolor']);
// Rember that we have selected a value
- $this->session->subColor = $this->palette;
+ Session::set('subColor', $this->palette);
}
// If we are logged in, use our preference
$this->palette = Auth::user()->getPreference('themecolor');
// If not logged in or no preference, use one we selected earlier in the session?
if (!$this->palette) {
- $this->palette = $this->session->subColor;
+ $this->palette = Session::get('subColor');
}
// We haven't selected one this session? Use the site default
if (!$this->palette) {
diff --git a/autocomplete.php b/autocomplete.php
index 54844c7755..5e8f6971cf 100644
--- a/autocomplete.php
+++ b/autocomplete.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Defined in session.php
*
@@ -32,9 +30,6 @@ require './includes/session.php';
header('Content-Type: text/plain; charset=UTF-8');
-// We have finished writing session data, so release the lock
-Zend_Session::writeClose();
-
$term = Filter::get('term'); // we can search on '"><& etc.
$type = Filter::get('field');
diff --git a/edit_interface.php b/edit_interface.php
index 75e102824a..90518d7e5a 100644
--- a/edit_interface.php
+++ b/edit_interface.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Defined in session.php
*
@@ -100,7 +98,6 @@ case 'updateraw':
$fact_ids = Filter::postArray('fact_id');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editraw&xref=' . $xref);
return;
@@ -197,7 +194,6 @@ case 'updaterawfact':
$keep_chan = Filter::postBool('keep_chan');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editrawfact&xref=' . $xref . '&fact_id=' . $fact_id);
return;
@@ -402,7 +398,6 @@ case 'update':
if (!Filter::checkCsrf()) {
$prev_action = Filter::post('prev_action', 'add|edit|addname|editname');
$fact_type = Filter::post('fact_type', WT_REGEX_TAG);
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=' . $prev_action . '&xref=' . $xref . '&fact_id=' . $fact_id . '&fact=' . $fact_type);
return;
@@ -531,7 +526,6 @@ case 'add_child_to_family_action':
if (!Filter::checkCsrf()) {
$gender = Filter::get('gender', '[MFU]', 'U');
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_family&xref=' . $xref . '&gender=' . $gender);
return;
@@ -609,7 +603,6 @@ case 'add_child_to_individual_action':
$islink = Filter::postArray('islink', '[01]');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_individual&xref=' . $xref);
return;
@@ -693,7 +686,6 @@ case 'add_parent_to_individual_action':
if (!Filter::checkCsrf()) {
$gender = Filter::get('gender', '[MFU]', 'U');
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_parent_to_individual&xref=' . $xref . '&gender=' . $gender);
return;
@@ -764,7 +756,6 @@ case 'add_unlinked_indi_action':
$islink = Filter::postArray('islink', '[01]');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_unlinked_indi');
return;
@@ -830,7 +821,6 @@ case 'add_spouse_to_individual_action':
if (!Filter::checkCsrf()) {
$famtag = Filter::get('famtag', 'HUSB|WIFE');
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_individual&xref=' . $xref . '&famtag=' . $famtag);
return;
@@ -923,7 +913,6 @@ case 'add_spouse_to_family_action':
if (!Filter::checkCsrf()) {
$famtag = Filter::get('famtag', 'HUSB|WIFE');
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag);
return;
@@ -1036,7 +1025,6 @@ case 'linkfamaction':
$PEDI = Filter::post('PEDI');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addfamlink&xref=' . $xref);
return;
@@ -1150,7 +1138,6 @@ case 'linkspouseaction':
if (!Filter::checkCsrf()) {
$famtag = Filter::get('famtag', 'HUSB|WIFE');
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=linkspouse&xref=' . $xref . '&famtag=' . $famtag);
return;
@@ -1289,7 +1276,6 @@ case 'addsourceaction':
->pageHeader();
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewsource');
return;
@@ -1395,7 +1381,6 @@ case 'addnoteaction':
->pageHeader();
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote');
return;
@@ -1419,7 +1404,6 @@ case 'addnoteaction_assisted':
->pageHeader();
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote_assisted');
return;
@@ -1505,7 +1489,6 @@ case 'editnoteaction':
$note = Filter::post('NOTE');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editnote&xref=' . $xref);
return;
@@ -1594,7 +1577,6 @@ case 'addnewrepository':
case 'addrepoaction':
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewrepository');
return;
@@ -1785,7 +1767,6 @@ case 'reorder_media_update':
$keep_chan = Filter::postBool('keep_chan');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_media_&xref=' . $xref);
return;
@@ -1896,7 +1877,6 @@ case 'reorder_update':
$keep_chan = Filter::postBool('keep_chan');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_children&xref=' . $xref);
return;
@@ -2092,7 +2072,6 @@ case 'changefamily_update':
$keep_chan = Filter::postBool('keep_chan');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref);
return;
@@ -2260,7 +2239,6 @@ case 'reorder_fams_update':
$keep_chan = Filter::postBool('keep_chan');
if (!Filter::checkCsrf()) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_fams&xref=' . $xref);
return;
diff --git a/expand_view.php b/expand_view.php
index 23691970bd..2b8c842eeb 100644
--- a/expand_view.php
+++ b/expand_view.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Defined in session.php
*
@@ -28,8 +26,6 @@ global $WT_TREE;
define('WT_SCRIPT_NAME', 'expand_view.php');
require './includes/session.php';
-Zend_Session::writeClose();
-
header('Content-Type: text/html; charset=UTF-8');
$individual = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
if (!$individual || !$individual->canShow()) {
diff --git a/fanchart.php b/fanchart.php
index 8bfbac22bd..9361bcba6b 100644
--- a/fanchart.php
+++ b/fanchart.php
@@ -16,15 +16,12 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
define('WT_SCRIPT_NAME', 'fanchart.php');
require './includes/session.php';
$controller = new FanchartController;
if (Filter::getBool('img')) {
- Zend_Session::writeClose();
header('Content-Type: image/png');
echo $controller->generateFanChart('png');
diff --git a/gedrecord.php b/gedrecord.php
index e1e32b69cf..df530ca1b7 100644
--- a/gedrecord.php
+++ b/gedrecord.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Defined in session.php
*
@@ -40,7 +38,6 @@ if (
$obj instanceof Note ||
$obj instanceof Media
) {
- Zend_Session::writeClose();
header('Location: ' . WT_BASE_URL . $obj->getRawUrl());
return;
diff --git a/hourglass_ajax.php b/hourglass_ajax.php
index 1552df4c67..edaf8e9e31 100644
--- a/hourglass_ajax.php
+++ b/hourglass_ajax.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
define('WT_SCRIPT_NAME', 'hourglass_ajax.php');
require './includes/session.php';
@@ -25,8 +23,6 @@ $controller = new HourglassController;
header('Content-type: text/html; charset=UTF-8');
-Zend_Session::writeClose();
-
if (Filter::get('type') === 'desc') {
$controller->printDescendency($controller->root, 1, false);
} else {
diff --git a/includes/functions/functions_print.php b/includes/functions/functions_print.php
index fe979c7903..827c3dff08 100644
--- a/includes/functions/functions_print.php
+++ b/includes/functions/functions_print.php
@@ -583,12 +583,12 @@ function CheckFactUnique($uniquefacts, $recfacts, $type) {
* @param string $type the type of record INDI, FAM, SOUR etc
*/
function print_add_new_fact($id, $usedfacts, $type) {
- global $WT_SESSION, $WT_TREE;
+ global $WT_TREE;
// -- Add from clipboard
- if ($WT_SESSION->clipboard) {
+ if (is_array(Session::get('clipboard'))) {
$newRow = true;
- foreach (array_reverse($WT_SESSION->clipboard, true) as $fact_id=>$fact) {
+ foreach (array_reverse(Session::get('clipboard'), true) as $fact_id=>$fact) {
if ($fact["type"] == $type || $fact["type"] == 'all') {
if ($newRow) {
$newRow = false;
diff --git a/includes/php_53_compatibility.php b/includes/php_53_compatibility.php
index db23a362a8..ac841376b3 100644
--- a/includes/php_53_compatibility.php
+++ b/includes/php_53_compatibility.php
@@ -17,6 +17,13 @@ namespace Fisharebest\Webtrees;
*/
/**
+ * This function was introduced in PHP 5.4
+ */
+function session_register_shutdown() {
+ register_shutdown_function('session_write_close');
+}
+
+/**
* https://php.net/date_default_timezone_get
* Prior to PHP 5.4, this function would attempt to guess the timezone,
* and emit a warning when it did this. Suppresss the warning.
diff --git a/includes/session.php b/includes/session.php
index 50ae6e95b2..41e730b8f3 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -18,8 +18,6 @@ namespace Fisharebest\Webtrees;
use PDOException;
use Zend_Controller_Request_Http;
-use Zend_Session;
-use Zend_Session_Namespace;
/**
* This is the bootstrap script, that is run on every request.
@@ -36,10 +34,9 @@ if (!defined('WT_SCRIPT_NAME')) {
*
* @global boolean $SEARCH_SPIDER
* @global Zend_Controller_Request_Http $WT_REQUEST
- * @global Zend_Session_Namespace $WT_SESSION
* @global Tree $WT_TREE
*/
-global $WT_REQUEST, $WT_SESSION, $WT_TREE, $SEARCH_SPIDER;
+global $WT_REQUEST, $WT_TREE, $SEARCH_SPIDER;
// Identify ourself
define('WT_WEBTREES', 'webtrees');
@@ -344,7 +341,7 @@ case 'robot':
case 'unknown':
// Search engines don’t send cookies, and so create a new session with every visit.
// Make sure they always use the same one
- Zend_Session::setId('search-engine-' . str_replace('.', '-', $WT_REQUEST->getClientIp()));
+ Session::setId('search-engine-' . str_replace('.', '-', $WT_REQUEST->getClientIp()));
$SEARCH_SPIDER = true;
break;
case '':
@@ -398,30 +395,15 @@ session_set_save_handler(
}
);
-// Use the Zend_Session_Namespace object to start the session.
-// This allows all the other Zend Framework components to integrate with the session
-define('WT_SESSION_NAME', 'WT_SESSION');
-$cfg = array(
- 'name' => WT_SESSION_NAME,
- 'cookie_lifetime' => 0,
- 'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
- 'gc_probability' => 1,
- 'gc_divisor' => 100,
- 'cookie_path' => parse_url(WT_BASE_URL, PHP_URL_PATH),
- 'cookie_httponly' => true,
-);
-
-Zend_Session::start($cfg);
-
-// Register a session “namespace” to store session data. This is better than
-// using $_SESSION, as we can avoid clashes with other modules or applications,
-// and problems with servers that have enabled “register_globals”.
-$WT_SESSION = new Zend_Session_Namespace('WEBTREES');
+session_start(array(
+ 'gc_maxlifetime' => Site::getPreference('SESSION_TIME'),
+ 'cookie_path' => parse_url(WT_BASE_URL, PHP_URL_PATH),
+));
-if (!Auth::isSearchEngine() && !$WT_SESSION->initiated) {
+if (!Auth::isSearchEngine() && !Session::get('initiated')) {
// A new session, so prevent session fixation attacks by choosing a new PHPSESSID.
- Zend_Session::regenerateId();
- $WT_SESSION->initiated = true;
+ Session::regenerate(false);
+ Session::put('initiated', true);
} else {
// An existing session
}
@@ -432,10 +414,10 @@ define('WT_USER_ID', Auth::id());
define('WT_USER_NAME', Auth::id() ? Auth::user()->getUserName() : '');
// Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree
-foreach (array(Filter::post('ged'), Filter::get('ged'), $WT_SESSION->GEDCOM, Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) {
+foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) {
$WT_TREE = Tree::findByName($tree_name);
if ($WT_TREE) {
- $WT_SESSION->GEDCOM = $tree_name;
+ Session::put('GEDCOM', $tree_name);
break;
}
}
@@ -448,7 +430,7 @@ if (!$WT_TREE) {
// With no parameters, init() looks to the environment to choose a language
define('WT_LOCALE', I18N::init());
-$WT_SESSION->locale = WT_LOCALE;
+Session::put('locale', WT_LOCALE);
if (empty($WEBTREES_EMAIL)) {
$WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\./i', '', $_SERVER['SERVER_NAME']);
@@ -458,7 +440,7 @@ if (empty($WEBTREES_EMAIL)) {
define('WT_TIMESTAMP', (int) Database::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne());
if (Auth::check()) {
- define('WT_TIMESTAMP_OFFSET', $WT_SESSION->timediff);
+ define('WT_TIMESTAMP_OFFSET', Session::get('timediff'));
} else {
define('WT_TIMESTAMP_OFFSET', (int) date('Z'));
}
@@ -488,15 +470,15 @@ if (WT_SCRIPT_NAME != 'admin_trees_manage.php' && WT_SCRIPT_NAME != 'admin_pgv_t
}
// Update the login time every 5 minutes
-if (WT_TIMESTAMP - $WT_SESSION->activity_time > 300) {
+if (WT_TIMESTAMP - Session::get('activity_time') > 300) {
Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
- $WT_SESSION->activity_time = WT_TIMESTAMP;
+ Session::put('activity_time', WT_TIMESTAMP);
}
// Set the theme
if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php' && substr(Filter::get('mod_action'), 0, 5) === 'admin') {
// Administration scripts begin with “admin” and use a special administration theme
- Theme::theme(new AdministrationTheme)->init($WT_SESSION, $WT_TREE);
+ Theme::theme(new AdministrationTheme)->init($WT_TREE);
} else {
if (Site::getPreference('ALLOW_USER_THEMES')) {
// Requested change of theme?
@@ -505,8 +487,8 @@ if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php'
$theme_id = '';
}
// Last theme used?
- if (!$theme_id && array_key_exists($WT_SESSION->theme_id, Theme::themeNames())) {
- $theme_id = $WT_SESSION->theme_id;
+ if (!$theme_id && array_key_exists(Session::get('theme_id'), Theme::themeNames())) {
+ $theme_id = Session::get('theme_id');
}
} else {
$theme_id = '';
@@ -529,12 +511,12 @@ if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php'
}
foreach (Theme::installedThemes() as $theme) {
if ($theme->themeId() === $theme_id) {
- Theme::theme($theme)->init($WT_SESSION, $WT_TREE);
+ Theme::theme($theme)->init($WT_TREE);
}
}
// Remember this setting
- $WT_SESSION->theme_id = $theme_id;
+ Session::put('theme_id', $theme_id);
}
// Search engines are only allowed to see certain pages.
diff --git a/index_edit.php b/index_edit.php
index 7e8a67794d..3f941e65fe 100644
--- a/index_edit.php
+++ b/index_edit.php
@@ -16,16 +16,12 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-use Zend_Session_Namespace;
-
/**
* Defined in session.php
*
- * @global Zend_Session_Namespace $WT_SESSION
- * @global Tree $WT_TREE
+ * @global Tree $WT_TREE
*/
-global $WT_SESSION, $WT_TREE;
+global $WT_TREE;
define('WT_SCRIPT_NAME', 'index_edit.php');
require './includes/session.php';
@@ -56,7 +52,7 @@ if ($user_id) {
if ($user_id < 0 || $gedcom_id < 0 || Auth::isAdmin() && $user_id != Auth::id()) {
// We're doing this from an admin page. Use the admin theme, and return there afterwards.
- Theme::theme(new AdministrationTheme)->init($WT_SESSION, $WT_TREE);
+ Theme::theme(new AdministrationTheme)->init($WT_TREE);
$return_to = 'admin_trees_manage.php?ged=';
} else {
$return_to = 'index.php';
@@ -127,7 +123,6 @@ if ($user_id) {
}
if ($action === 'update') {
- Zend_Session::writeClose();
foreach (array('main', 'side') as $location) {
if ($location === 'main') {
$new_blocks = $main;
diff --git a/login.php b/login.php
index 45c3ad07a7..73e424fd7b 100644
--- a/login.php
+++ b/login.php
@@ -18,17 +18,14 @@ namespace Fisharebest\Webtrees;
use Rhumsaa\Uuid\Uuid;
use Zend_Controller_Request_Http;
-use Zend_Session;
-use Zend_Session_Namespace;
/**
* Defined in session.php
*
* @global Zend_Controller_Request_Http $WT_REQUEST
- * @global Zend_Session_Namespace $WT_SESSION
* @global Tree $WT_TREE
*/
-global $WT_REQUEST, $WT_SESSION, $WT_TREE;
+global $WT_REQUEST, $WT_TREE;
define('WT_SCRIPT_NAME', 'login.php');
require './includes/session.php';
@@ -97,10 +94,10 @@ case 'login':
Auth::login($user);
Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
- $WT_SESSION->timediff = $timediff;
- $WT_SESSION->locale = Auth::user()->getPreference('language');
- $WT_SESSION->theme_id = Auth::user()->getPreference('theme');
- $WT_SESSION->activity_time = WT_TIMESTAMP;
+ Session::put('timediff', $timediff);
+ Session::put('locale', Auth::user()->getPreference('language'));
+ Session::put('theme_id', Auth::user()->getPreference('theme'));
+ Session::put('activity_time', WT_TIMESTAMP);
Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
@@ -126,9 +123,6 @@ case 'login':
// Redirect to the target URL
header('Location: ' . WT_BASE_URL . $url);
- // Explicitly write the session data before we exit,
- // as it doesn’t always happen when using APC.
- Zend_Session::writeClose();
return;
} catch (\Exception $ex) {
@@ -275,7 +269,7 @@ case 'register':
$controller->setPageTitle(I18N::translate('Request new user account'));
// The form parameters are mandatory, and the validation errors are shown in the client.
- if ($WT_SESSION->good_to_send && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) {
+ if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) {
// These validation errors cannot be shown in the client.
if (User::findByIdentifier($user_name)) {
@@ -390,7 +384,7 @@ case 'register':
}
}
- $WT_SESSION->good_to_send = true;
+ Session::put('good_to_send', true);
$controller
->pageHeader()
->addInlineJavascript('function regex_quote(str) {return str.replace(/[\\\\.?+*()[\](){}|]/g, "\\\\$&");}');
diff --git a/mediafirewall.php b/mediafirewall.php
index d2e0c60002..f4821e5f9a 100644
--- a/mediafirewall.php
+++ b/mediafirewall.php
@@ -16,8 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session;
-
/**
* Defined in session.php
*
@@ -28,8 +26,6 @@ global $WT_TREE;
define('WT_SCRIPT_NAME', 'mediafirewall.php');
require './includes/session.php';
-Zend_Session::writeClose();
-
$mid = Filter::get('mid', WT_REGEX_XREF);
$thumb = Filter::getBool('thumb');
$media = Media::getInstance($mid, $WT_TREE);
diff --git a/message.php b/message.php
index 237eafdd9b..70775dd41b 100644
--- a/message.php
+++ b/message.php
@@ -16,15 +16,6 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session_Namespace;
-
-/**
- * Defined in session.php
- *
- * @global Zend_Session_Namespace $WT_SESSION
- */
-global $WT_SESSION;
-
define('WT_SCRIPT_NAME', 'message.php');
require './includes/session.php';
@@ -74,18 +65,18 @@ if (Auth::check()) {
// This makes it harder for spammers.
switch ($action) {
case 'compose':
- $WT_SESSION->good_to_send = true;
+ Session::put('good_to_send', true);
break;
case 'send':
// Only send messages if we've come straight from the compose page.
- if (!$WT_SESSION->good_to_send) {
+ if (!Session::get('good_to_send')) {
Log::addAuthenticationLog('Attempt to send a message without visiting the compose page. Spam attack?');
$action = 'compose';
}
if (!Filter::checkCsrf()) {
$action = 'compose';
}
- unset($WT_SESSION->good_to_send);
+ Session::forget('good_to_send');
break;
}
diff --git a/setup.php b/setup.php
index 56aa3c7828..bed525c7dc 100644
--- a/setup.php
+++ b/setup.php
@@ -22,7 +22,7 @@ use Zend_Controller_Request_Http;
error_reporting(E_ALL);
// To embed webtrees code in other applications, we must explicitly declare any global variables that we create.
-global $WT_REQUEST, $WT_SESSION;
+global $WT_REQUEST;
define('WT_SCRIPT_NAME', 'setup.php');
define('WT_CONFIG_FILE', 'config.ini.php');
@@ -53,7 +53,6 @@ if (file_exists(WT_DATA_DIR . WT_CONFIG_FILE)) {
}
if (version_compare(PHP_VERSION, WT_REQUIRED_PHP_VERSION) < 0) {
- // We cannot translate these messages without a modern PHP
echo
'<h1>Sorry, the setup wizard cannot start.</h1>',
'<p>This server is running PHP version ', PHP_VERSION, '</p>',
@@ -62,10 +61,9 @@ if (version_compare(PHP_VERSION, WT_REQUIRED_PHP_VERSION) < 0) {
return;
}
-$WT_REQUEST = new Zend_Controller_Request_Http;
-$WT_SESSION = new \stdClass;
-$WT_SESSION->locale = null; // Needed for I18N
-$WT_SESSION->wt_user = null; // Needed for Auth
+Session::start();
+
+$WT_REQUEST = new Zend_Controller_Request_Http;
define('WT_LOCALE', I18N::init(Filter::post('lang', '[@a-zA-Z_]+')));
header('Content-Type: text/html; charset=UTF-8');
@@ -110,7 +108,7 @@ if (!isset($_POST['lang'])) {
echo
'<p>', I18N::translate('Change language'), ' ',
- select_edit_control('change_lang', $installed_languages, null, Filter::get('lang'), 'onchange="window.location=\'' . WT_SCRIPT_NAME . '?lang=\'+this.value;">'),
+ select_edit_control('change_lang', $installed_languages, null, WT_LOCALE, 'onchange="window.location=\'' . WT_SCRIPT_NAME . '?lang=\'+this.value;">'),
'</p>',
'<h2>', I18N::translate('Checking server configuration'), '</h2>';
$warnings = false;
diff --git a/site-offline.php b/site-offline.php
index 7294cb27e3..4154f05446 100644
--- a/site-offline.php
+++ b/site-offline.php
@@ -32,10 +32,7 @@ define('WT_BASE_URL', '');
define('WT_ROOT', '');
define('WT_DATA_DIR', realpath('data') . DIRECTORY_SEPARATOR);
define('WT_MODULES_DIR', 'modules_v3/');
-
-$WT_SESSION = new \stdClass;
-$WT_SESSION->locale = '';
-
+Session::start();
define('WT_LOCALE', I18N::init());
if (file_exists(WT_DATA_DIR . 'offline.txt')) {
diff --git a/site-unavailable.php b/site-unavailable.php
index 25c9abc37e..bf2ae2894f 100644
--- a/site-unavailable.php
+++ b/site-unavailable.php
@@ -43,8 +43,7 @@ if (!file_exists(WT_DATA_DIR . 'config.ini.php')) {
return;
}
-$WT_SESSION = new \stdClass;
-$WT_SESSION->locale = '';
+Session::start();
define('WT_LOCALE', I18N::init());
diff --git a/statistics.php b/statistics.php
index 8dbf520e90..a147d5b2c8 100644
--- a/statistics.php
+++ b/statistics.php
@@ -16,15 +16,12 @@ namespace Fisharebest\Webtrees;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use Zend_Session_Namespace;
-
/**
* Defined in session.php
*
- * @global Zend_Session_Namespace $WT_SESSION
- * @global Tree $WT_TREE
+ * @global Tree $WT_TREE
*/
-global $WT_SESSION, $WT_TREE;
+global $WT_TREE;
define('WT_SCRIPT_NAME', 'statistics.php');
require './includes/session.php';
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
index f03afc8e06..4e7a61c550 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -164,6 +164,7 @@ return array(
'Fisharebest\\Webtrees\\ReviewChangesModule' => $baseDir . '/app/Module/ReviewChangesModule.php',
'Fisharebest\\Webtrees\\RomanDate' => $baseDir . '/app/Date/RomanDate.php',
'Fisharebest\\Webtrees\\SearchController' => $baseDir . '/app/Controller/SearchController.php',
+ 'Fisharebest\\Webtrees\\Session' => $baseDir . '/app/Session.php',
'Fisharebest\\Webtrees\\SimpleController' => $baseDir . '/app/Controller/SimpleController.php',
'Fisharebest\\Webtrees\\Site' => $baseDir . '/app/Site.php',
'Fisharebest\\Webtrees\\SiteMapModule' => $baseDir . '/app/Module/SiteMapModule.php',