From c7e73b45e1cc21e1c8a604db90b610629f098d53 Mon Sep 17 00:00:00 2001 From: botanic Date: Sat, 13 Sep 2014 10:31:12 -0700 Subject: [PATCH] Fix #122 --- .../setup/sql/nel_ams_lib_00006.sql | 14 +++++++ .../public_php/ams/func/userRegistration.php | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 code/web/private_php/setup/sql/nel_ams_lib_00006.sql create mode 100644 code/web/public_php/ams/func/userRegistration.php diff --git a/code/web/private_php/setup/sql/nel_ams_lib_00006.sql b/code/web/private_php/setup/sql/nel_ams_lib_00006.sql new file mode 100644 index 000000000..8a344379c --- /dev/null +++ b/code/web/private_php/setup/sql/nel_ams_lib_00006.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS `settings` ( +`idSettings` int(11) NOT NULL, + `Setting` varchar(32) COLLATE utf8_unicode_ci NOT NULL, + `Value` varchar(32) COLLATE utf8_unicode_ci NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +INSERT INTO `settings` (`idSettings`, `Setting`, `Value`) VALUES +(1, 'userRegistration', '0'); + +ALTER TABLE `settings` + ADD PRIMARY KEY (`idSettings`), ADD UNIQUE KEY `idSettings` (`idSettings`), ADD KEY `idSettings_2` (`idSettings`); + +ALTER TABLE `settings` +MODIFY `idSettings` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2; \ No newline at end of file diff --git a/code/web/public_php/ams/func/userRegistration.php b/code/web/public_php/ams/func/userRegistration.php new file mode 100644 index 000000000..632c0681d --- /dev/null +++ b/code/web/public_php/ams/func/userRegistration.php @@ -0,0 +1,42 @@ +update("settings", Array('Value' => $_POST['userRegistration']), "`Setting` = 'userRegistration'"); + + $result['target_id'] = $_GET['id']; + global $SITEBASE; + require_once($SITEBASE . '/inc/settings.php'); + $pageElements = settings(); + $pageElements = array_merge(settings(), $result); + $pageElements['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); + // pass error and reload template accordingly + helpers :: loadtemplate( 'settings', $pageElements); + throw new SystemExit(); + + } else { + //ERROR: user is not logged in + header("Location: index.php"); + throw new SystemExit(); + } + + } + catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + throw new SystemExit(); + } + +} \ No newline at end of file