This repository has been archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_configuration.php
136 lines (126 loc) · 3.61 KB
/
admin_configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
//Forms posted
if(!empty($_POST))
{
$cfgId = array();
$newSettings = $_POST['settings'];
//Validate new site name
if ($newSettings[1] != $websiteName) {
$newWebsiteName = $newSettings[1];
if(minMaxRange(1,150,$newWebsiteName))
{
$errors[] = lang("CONFIG_NAME_CHAR_LIMIT",array(1,150));
}
else if (count($errors) == 0) {
$cfgId[] = 1;
$cfgValue[1] = $newWebsiteName;
$websiteName = $newWebsiteName;
}
}
//Validate new URL
if ($newSettings[2] != $websiteUrl) {
$newWebsiteUrl = $newSettings[2];
if(minMaxRange(1,150,$newWebsiteUrl))
{
$errors[] = lang("CONFIG_URL_CHAR_LIMIT",array(1,150));
}
else if (substr($newWebsiteUrl, -1) != "/"){
$errors[] = lang("CONFIG_INVALID_URL_END");
}
else if (count($errors) == 0) {
$cfgId[] = 2;
$cfgValue[2] = $newWebsiteUrl;
$websiteUrl = $newWebsiteUrl;
}
}
//Validate new site email address
if ($newSettings[3] != $emailAddress) {
$newEmail = $newSettings[3];
if(minMaxRange(1,150,$newEmail))
{
$errors[] = lang("CONFIG_EMAIL_CHAR_LIMIT",array(1,150));
}
elseif(!isValidEmail($newEmail))
{
$errors[] = lang("CONFIG_EMAIL_INVALID");
}
else if (count($errors) == 0) {
$cfgId[] = 3;
$cfgValue[3] = $newEmail;
$emailAddress = $newEmail;
}
}
//Validate email activation selection
if ($newSettings[4] != $emailActivation) {
$newActivation = $newSettings[4];
if($newActivation != "true" AND $newActivation != "false")
{
$errors[] = lang("CONFIG_ACTIVATION_TRUE_FALSE");
}
else if (count($errors) == 0) {
$cfgId[] = 4;
$cfgValue[4] = $newActivation;
$emailActivation = $newActivation;
}
}
//Validate new email activation resend threshold
if ($newSettings[5] != $resend_activation_threshold) {
$newResend_activation_threshold = $newSettings[5];
if($newResend_activation_threshold > 72 OR $newResend_activation_threshold < 0)
{
$errors[] = lang("CONFIG_ACTIVATION_RESEND_RANGE",array(0,72));
}
else if (count($errors) == 0) {
$cfgId[] = 5;
$cfgValue[5] = $newResend_activation_threshold;
$resend_activation_threshold = $newResend_activation_threshold;
}
}
//Validate new language selection
if ($newSettings[6] != $language) {
$newLanguage = $newSettings[6];
if(minMaxRange(1,150,$language))
{
$errors[] = lang("CONFIG_LANGUAGE_CHAR_LIMIT",array(1,150));
}
elseif (!file_exists($newLanguage)) {
$errors[] = lang("CONFIG_LANGUAGE_INVALID",array($newLanguage));
}
else if (count($errors) == 0) {
$cfgId[] = 6;
$cfgValue[6] = $newLanguage;
$language = $newLanguage;
}
}
//Validate new template selection
if ($newSettings[7] != $template) {
$newTemplate = $newSettings[7];
if(minMaxRange(1,150,$template))
{
$errors[] = lang("CONFIG_TEMPLATE_CHAR_LIMIT",array(1,150));
}
elseif (!file_exists($newTemplate)) {
$errors[] = lang("CONFIG_TEMPLATE_INVALID",array($newTemplate));
}
else if (count($errors) == 0) {
$cfgId[] = 7;
$cfgValue[7] = $newTemplate;
$template = $newTemplate;
}
}
//Update configuration table with new settings
if (count($errors) == 0 AND count($cfgId) > 0) {
updateConfig($cfgId, $cfgValue);
$successes[] = lang("CONFIG_UPDATE_SUCCESSFUL");
}
}
$languages = getLanguageFiles(); //Retrieve list of language files
$templates = getTemplateFiles(); //Retrieve list of template files
$permissionData = fetchAllPermissions(); //Retrieve list of all permission levels
require_once("models/header.php");
include("models/menu.php");
include("include/html-templates/admin_configuration.php");
include("models/plugins.php");
?>