summaryrefslogtreecommitdiff
path: root/modules/settings.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/settings.module')
-rw-r--r--modules/settings.module115
1 files changed, 115 insertions, 0 deletions
diff --git a/modules/settings.module b/modules/settings.module
new file mode 100644
index 000000000..1bbe64fdb
--- /dev/null
+++ b/modules/settings.module
@@ -0,0 +1,115 @@
+<?php
+
+$module = array("admin" => "settings_admin");
+
+function settings_conf() {
+ global $conf, $cmodes, $corder;
+
+ $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 system</H3>\n";
+
+ $output .= "<B>Default display mode:</B><BR>\n";
+ foreach ($cmodes as $key=>$value) $options1 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_mode] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[default_comment_mode]\">$options1</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) $options2 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_order] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[default_comment_order]\">$options2</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++) $options3 .= " <OPTION VALUE=\"$i\"". ($conf[default_comment_threshold] == $i ? " SELECTED" : "") .">Filter - $i</OPTION>";
+ $output .= "<SELECT NAME=\"edit[default_comment_threshold]\">$options3</SELECT><BR>\n";
+ $output .= "<I><SMALL>The default threshold used to filter comments.</SMALL></I><P>\n";
+
+ $output .= "<HR>\n";
+ $output .= "<H3>Submission system</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) $options4 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_input_size, 10000) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_input_size]\">$options4</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) $options5 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_node_rate, 900) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_node_rate]\">$options5</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) $options6 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_comment_rate, 120) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_comment_rate]\"$options6</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";
+
+ 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();
+ }
+}
+
+?> \ No newline at end of file