forked from Zavy86/WikiDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
144 lines (144 loc) · 6.89 KB
/
settings.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
137
138
139
140
141
142
143
144
<?php
/**
* Settings
*
* @package WikiDocs
* @repository https://github.com/Zavy86/wikidocs
*
*/
require_once("bootstrap.inc.php");
// get localization
$TXT=Localization::getInstance();
// acquire variables
$g_act=($_GET['act'] ?? '');
// store action
if($g_act=="store"){
// sed codes
$EDITCODE=($_POST['editcode']===EDITCODE?EDITCODE:md5($_POST['editcode']));
$VIEWCODE=($_POST['viewcode']===VIEWCODE?VIEWCODE:(strlen($_POST['viewcode'])?md5($_POST['viewcode']):null));
// build configuration file
$config="<?php\n";
$config.="define('DEBUGGABLE',".(DEBUGGABLE?"true":"false").");\n";
$config.="define('PATH',\"".PATH."\");\n";
$config.="define('LANG',\"".$_POST['lang']."\");\n";
$config.="define('TITLE',\"".$_POST['title']."\");\n";
$config.="define('SUBTITLE',\"".$_POST['subtitle']."\");\n";
$config.="define('OWNER',\"".$_POST['owner']."\");\n";
$config.="define('NOTICE',".($_POST['notice']?"\"".$_POST['notice']."\"":"null").");\n";
$config.="define('PRIVACY',".($_POST['privacy']?"\"".$_POST['privacy']."\"":"null").");\n";
$config.="define('EDITCODE',\"".$EDITCODE."\");\n";
$config.="define('VIEWCODE',".($VIEWCODE?"\"".$VIEWCODE."\"":"null").");\n";
$config.="define('COLOR',\"".$_POST['color']."\");\n";
$config.="define('DARK',".(isset($_POST['dark'])?"true":"false").");\n";
$config.="define('GTAG',".($_POST['gtag']?"\"".$_POST['gtag']."\"":"null").");\n";
// write configuration file
file_put_contents(BASE."datasets/config.inc.php",$config);
// alert and redirect
wdf_alert($TXT->SettingsStored,"success");
wdf_redirect(PATH);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="helpers/materialize-1.0.0/css/materialize.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="styles/styles.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="styles/styles-<?= (DARK?"dark":"light") ?>.css" media="screen,projection"/>
<link type="image/ico" rel="icon" href="favicon.ico" sizes="any"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="theme-color" content="<?= COLOR ?>">
<style>:root{--theme-color:<?= COLOR ?>;}</style>
<title><?= $TXT->Settings ?> - Wiki|Docs</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col s12">
<h1>Wiki|Docs</h1>
<p><?= $TXT->Payoff ?></p>
</div><!-- /col -->
<div class="col s12">
<h2><?= $TXT->Settings ?></h2>
<p><?= $TXT->SettingsConfigure ?>..</p>
<form action="settings.php?act=store" method="post">
<div class="row">
<div class="input-field col s12 m5">
<input type="text" name="title" id="title" class="validate" value="<?= TITLE ?>" required>
<label for="title"><span class="green-text"><?= $TXT->SettingsTitle ?></span></label>
</div>
<div class="input-field col s12 m7">
<input type="text" name="subtitle" id="subtitle" class="validate" value="<?= SUBTITLE ?>" required>
<label for="subtitle"><span class="green-text"><?= $TXT->SettingsSubtitle ?></span></label>
</div>
</div>
<div class="row">
<div class="input-field col s12 m5">
<input type="text" name="owner" id="owner" class="validate" placeholder="<?= $TXT->SettingsOwnerPlaceholder ?>" value="<?= OWNER ?>" required>
<label for="owner"><span class="green-text"><?= $TXT->SettingsOwner ?></span></label>
</div>
<div class="input-field col s12 m7">
<input type="text" name="notice" id="notice" class="validate" placeholder="<?= $TXT->SettingsNoticePlaceholder ?>" value="<?= NOTICE ?>" required>
<label for="notice"><span class="green-text"><?= $TXT->SettingsNotice ?></span></label>
</div>
</div>
<div class="row">
<div class="input-field col s12 m12">
<input type="text" name="privacy" id="privacy" class="validate" placeholder="<?= $TXT->SettingsPrivacyPlaceholder ?>" value="<?= PRIVACY ?>">
<label for="privacy"><span class="green-text"><?= $TXT->SettingsPrivacy ?></span></label>
</div>
</div>
<div class="row">
<div class="input-field col s12 m5">
<input type="password" name="editcode" id="editcode" class="validate" placeholder="<?= $TXT->SettingsEditCodePlaceholder ?>.." value="<?= EDITCODE ?>" required>
<label for="editcode"><span class="green-text"><?= $TXT->SettingsEditCode ?></span></label>
</div>
<div class="input-field col s12 m7">
<input type="password" name="viewcode" id="viewcode" class="validate" placeholder="<?= $TXT->SettingsViewCodePlaceholder ?>.." value="<?= VIEWCODE ?>">
<label for="viewcode"><span class="green-text"><?= $TXT->SettingsViewCode ?></span></label>
</div>
</div>
<div class="row">
<div class="input-field col s6 m3">
<input type="text" name="color" id="color" class="validate" placeholder="<?= $TXT->SettingsColorPlaceholder ?>.. (#4CAF50)" value="<?= COLOR ?>" required>
<label for="color"><span class="green-text"><?= $TXT->SettingsColor ?></span></label>
</div>
<div class="input-field col s6 m2">
<label for="check-dark">
<input type="checkbox" name="dark" id="check-dark"<?php if(DARK){echo " checked";}?>>
<span><?= $TXT->SettingsDark ?></span>
</label>
</div>
<div class="input-field col s12 m5">
<input type="text" name="gtag" id="gtag" class="validate" placeholder="<?= $TXT->SettingsGtagPlaceholder ?>.. (like UA-123456789-1)" value="<?= GTAG ?>">
<label for="gtag"><span class="green-text"><?= $TXT->SettingsGtag ?></span></label>
</div>
<div class="input-field col s12 m2">
<select name="lang" id="lang" class="validate" value="<?= LANG ?>">
<?php foreach(Localization::available() as $value=>$label): ?>
<option value="<?= $value ?>"<?= ($value==LANG?" selected":null) ?>><?= $label ?></option>
<?php endforeach; ?>
</select>
<label for="lang"><span class="green-text"><?= $TXT->SettingsLanguage ?></span></label>
</div>
</div>
<div class="row">
<div class="input-field col s12 m12">
<button type="button" class="btn btn-block waves-effect waves-light grey left" onclick="location.href='<?= PATH ?>';"><?= $TXT->SettingsCancel ?><i class="material-icons left">keyboard_arrow_left</i></button>
<button type="submit" class="btn btn-block waves-effect waves-light green right"><?= $TXT->SettingsSubmit ?><i class="material-icons right">check</i></button>
</div>
</div>
</form>
</div><!-- /col -->
</div><!-- /row-->
</div><!-- /container-->
<script src="helpers/jquery-3.7.0/js/jquery.min.js"></script>
<script src="helpers/materialize-1.0.0/js/materialize.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded',function(){
let selectElements=document.querySelectorAll('select');
let instances=M.FormSelect.init(selectElements);
});
</script>
</body>
</html>