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
|
<?php
$module = array("admin" => "settings_admin");
function settings_conf() {
global $conf, $cmodes, $corder, $themes;
$output .= "<H3>General settings</H3>\n";
$output .= "<B>Sitename:</B><BR>\n";
$output .= "<INPUT NAME=\"edit[site_name]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_name, "drupal") ."\"><BR>\n";
$output .= "<I><SMALL>The name of this website.</SMALL></I><P>\n";
$output .= "<B>E-mail address:</B><BR>\n";
$output .= "<INPUT NAME=\"edit[site_mail]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_mail, "root@localhost") ."\"><BR>\n";
$output .= "<I><SMALL>A valid e-mail address for this website, used by the auto-mailer to when creating new user accounts.</SMALL></I><P>\n";
$output .= "<B>URL of site:</B><BR>\n";
$output .= "<INPUT NAME=\"edit[site_url]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_url, "http://drupal/") ."\"><BR>\n";
$output .= "<I><SMALL>The fully qualified URL of this website: starts with \"http://\" and ends with a trailing slash!</SMALL></I><P>\n";
$output .= "<B>Anonymous user:</B><BR>\n";
$output .= "<INPUT NAME=\"edit[anonymous]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(anonymous, "Anonymous") ."\"><BR>\n";
$output .= "<I><SMALL>The name displayed for anonymous users.</SMALL></I><P>\n";
$output .= "<HR>\n";
$output .= "<H3>Comment settings</H3>\n";
$output .= "<B>Default display mode:</B><BR>\n";
foreach ($cmodes as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_mode] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<SELECT NAME=\"edit[default_comment_mode]\">$options2</SELECT><BR>\n";
$output .= "<I><SMALL>The default mode in which comments are displayed.</SMALL></I><P>\n";
$output .= "<B>Default display mode:</B><BR>\n";
foreach ($corder as $key=>$value) $options3 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_order] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<SELECT NAME=\"edit[default_comment_order]\">$options3</SELECT><BR>\n";
$output .= "<I><SMALL>The default mode in which comments are displayed.</SMALL></I><P>\n";
$output .= "<B>Default threshold:</B><BR>\n";
for ($i = -1; $i < 6; $i++) $options4 .= " <OPTION VALUE=\"$i\"". ($conf[default_comment_threshold] == $i ? " SELECTED" : "") .">Filter - $i</OPTION>";
$output .= "<SELECT NAME=\"edit[default_comment_threshold]\">$options4</SELECT><BR>\n";
$output .= "<I><SMALL>The default threshold used to filter comments.</SMALL></I><P>\n";
$output .= "<HR>\n";
$output .= "<H3>Submission settings</H3>\n";
$size = array(1000 => "1.000 characters", 5000 => "5.000 characters", 10000 => "10.000 characters", 15000 => "15.000 characters", 30.000 => "30.000 characters", 50000 => "50.000 characters", 100000 => "100.000 characters");
$output .= "<B>Maximum submission size:</B><BR>\n";
foreach ($size as $key=>$value) $options5 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_input_size, 10000) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<SELECT NAME=\"edit[max_input_size]\">$options5</SELECT><BR>\n";
$output .= "<I><SMALL>The maximum number of characters someone can enter in a form.</SMALL></I><P>\n";
$rate = array(1 => "maximum 1 every second", 5 => "maximum 1 every 5 seconds", 15 => "maximum 1 every 15 seconds", 30 => "maximum 1 every 30 seconds", 60 => "maximum 1 every minute", 300 => "maximum 1 every 5 minutes", 900 => "maximum 1 every 15 minutes", 1800 => "maximum 1 every 30 minutes", 3600 => "maximum 1 every hour", 21600 => "maximum 1 every 6 hour", 43200 => "maximum 1 every 12 hour");
$output .= "<B>Maximum node rate:</B><BR>\n";
foreach ($rate as $key=>$value) $options6 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_node_rate, 900) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<SELECT NAME=\"edit[max_node_rate]\">$options6</SELECT><BR>\n";
$output .= "<I><SMALL>The maximum submission rate for nodes. Its purpose is to stop potential abuse or denial of service attacks.</SMALL></I><P>\n";
$output .= "<B>Maximum comment rate:</B><BR>\n";
foreach ($rate as $key=>$value) $options7 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_comment_rate, 120) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<SELECT NAME=\"edit[max_comment_rate]\"$options7</SELECT><BR>\n";
$output .= "<I><SMALL>The maximum submission rate for comments. Its purpose is to stop potential abuse or denial of service attacks.</SMALL></I><P>\n";
$output .= "<HR>\n";
$output .= "<H3>Theme settings</H3>\n";
$output .= "<B>Default theme:</B><BR>\n";
foreach ($themes as $key=>$value) $options1 .= "<OPTION VALUE=\"$key\"". (variable_get(theme_default, key($themes)) == $key ? " SELECTED" : "") .">$key</OPTION>\n";
$output .= "<SELECT NAME=\"edit[theme_default]\">$options1</SELECT><BR>\n";
$output .= "<I><SMALL>The default theme displayed for anonymous users.</SMALL></I><P>\n";
$output .= "<B>Footer message:</B><BR>\n";
$output .= "<TEXTAREA NAME=\"edit[theme_footer]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">". variable_get(theme_footer, "") ."</TEXTAREA><BR>\n";
$output .= "<I><SMALL>This text will be displayed at the bottom of each page. Useful to add a copyright notice to your pages.</SMALL></I><P>\n";
$output .= "<HR>\n";
return $output;
}
function settings_save($edit) {
global $conf;
if ($edit) {
db_query("DELETE FROM variable");
foreach ($edit as $name=>$value) db_query("INSERT INTO variable (name, value) VALUES ('". check_input($name) ."', '". check_input($value) ."')");
}
$conf = variable_init();
return "all settings have been saved.";
}
function settings_module($name, $module) {
global $settings;
if ($module["conf"]) {
$settings .= "<H3>". ucfirst($name) ." module</H3>\n";
$settings .= $module["conf"]();
$settings .= "<HR>\n";
}
}
function settings_overview() {
global $settings;
module_iterate("settings_module");
$output .= "<FORM ACTION=\"admin.php?mod=settings\" METHOD=\"post\">\n";
$output .= settings_conf();
$output .= $settings;
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save settings\">\n";
$output .= "</FORM>\n";
return $output;
}
function settings_admin() {
global $edit, $op;
switch ($op) {
case "Save settings":
print status(settings_save($edit));
// fall through:
default;
print settings_overview();
}
}
?>
|