Browse Source

Forgot to track these apparently

spaghetti 2 years ago
parent
commit
7e10fdac6c
2 changed files with 151 additions and 0 deletions
  1. 3 0
      contest.php
  2. 148 0
      sections/tools/development/misc_values.php

+ 3 - 0
contest.php View File

@@ -0,0 +1,3 @@
1
+<?
2
+define('ERROR_EXCEPTION', true);
3
+require('classes/script_start.php');

+ 148 - 0
sections/tools/development/misc_values.php View File

@@ -0,0 +1,148 @@
1
+<?
2
+if (!check_perms('admin_manage_permissions') && !check_perms('users_mod')) {
3
+    error(403);
4
+}
5
+
6
+if (!check_perms('admin_manage_permissions')) {
7
+  View::show_header('Site Options');
8
+  $DB->query("SELECT Name, First, Second FROM misc");
9
+?>
10
+  <div class="header">
11
+    <h1>Miscellaneous Values</h1>
12
+  </div>
13
+  <table width="100%">
14
+    <tr class="colhead">
15
+      <td>Name</td>
16
+      <td>First</td>
17
+      <td>Second</td>
18
+    </tr>
19
+<?
20
+  while (list($Name, $First, $Second) = $DB->next_record()) {
21
+?>
22
+    <tr class="row">
23
+      <td><?=$Name?></td>
24
+      <td><?=$First?></td>
25
+      <td><?=$Second?></td>
26
+    </tr>
27
+<?
28
+  }
29
+?>
30
+  </table>
31
+<?
32
+  View::show_footer();
33
+  die();
34
+}
35
+
36
+if (isset($_POST['submit'])) {
37
+    authorize();
38
+
39
+    if ($_POST['submit'] == 'Delete') {
40
+  $Name = db_string($_POST['name']);
41
+        $DB->query("DELETE FROM misc WHERE Name = '" . $Name . "'");
42
+    } else {
43
+        $Val->SetFields('name', '1', 'regex', 'The name must be separated by underscores. No spaces are allowed.', array('regex' => '/^[a-z][_a-z0-9]{0,63}$/i'));
44
+        $Val->SetFields('first', '1', 'string', 'You must specify the first value.');
45
+        $Val->SetFields('second', '1', 'string', 'You must specify the second value.');
46
+
47
+        $Error = $Val->ValidateForm($_POST);
48
+        if ($Error) {
49
+            error($Error);
50
+        }
51
+
52
+        $Name = db_string($_POST['name']);
53
+        $Value = db_string($_POST['first']);
54
+        $Comment = db_string($_POST['second']);
55
+
56
+        if ($_POST['submit'] == 'Edit') {
57
+            $DB->query("SELECT Name FROM misc WHERE ID = '" . db_string($_POST['id']) . "'");
58
+            list($OldName) = $DB->next_record();
59
+            $DB->query("
60
+                UPDATE misc
61
+                SET
62
+                    Name = '$Name',
63
+                    First = '$First',
64
+                    Second = '$Second'
65
+                WHERE ID = '" . db_string($_POST['id']) . "'
66
+            ");
67
+        } else {
68
+            $DB->query("
69
+                INSERT INTO misc (Name, First, Second)
70
+                VALUES ('$Name', '$First', '$Second')
71
+            ");
72
+        }
73
+    }
74
+}
75
+
76
+$DB->query("
77
+    SELECT
78
+        ID,
79
+        Name,
80
+        First,
81
+        Second
82
+    FROM misc
83
+    ORDER BY LOWER(Name) DESC
84
+");
85
+
86
+View::show_header('Miscellaneous Values');
87
+?>
88
+
89
+<div class="header">
90
+  <h2>Miscellaneous Values</h2>
91
+</div>
92
+<div class="box slight_margin">
93
+  <table>
94
+    <tr class="colhead">
95
+      <td>
96
+        <span class="tooltip" title="Words must be separated by underscores">Name</span>
97
+      </td>
98
+      <td>First</td>
99
+      <td>Second</td>
100
+      <td>Submit</td>
101
+    </tr>
102
+    <tr>
103
+      <form class="create_form" name="misc_values" action="" method="post">
104
+        <input type="hidden" name="action" value="misc_values" />
105
+        <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
106
+        <td>
107
+          <input type="text" size="40" name="name" />
108
+        </td>
109
+        <td>
110
+          <input type="text" size="20" name="first" />
111
+        </td>
112
+        <td>
113
+          <input type="text" size="75" name="second" />
114
+        </td>
115
+        <td>
116
+          <input type="submit" name="submit" value="Create" />
117
+        </td>
118
+      </form>
119
+    </tr>
120
+<?
121
+while (list($ID, $Name, $First, $Second) = $DB->next_record()) {
122
+?>
123
+    <tr>
124
+      <form class="manage_form" name="misc_values" action="" method="post">
125
+        <input type="hidden" name="id" value="<?=$ID?>" />
126
+        <input type="hidden" name="action" value="misc_values" />
127
+        <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
128
+        <td>
129
+          <input type="text" size="40" name="name" value="<?=$Name?>" />
130
+        </td>
131
+        <td>
132
+          <input type="text" size="20" name="value" value="<?=$First?>" />
133
+        </td>
134
+        <td>
135
+          <input type="text" size="75" name="comment" value="<?=$Second?>" />
136
+        </td>
137
+        <td>
138
+          <input type="submit" name="submit" value="Edit" />
139
+          <input type="submit" name="submit" value="Delete" />
140
+        </td>
141
+      </form>
142
+    </tr>
143
+<?
144
+}
145
+?>
146
+  </table>
147
+</div>
148
+<? View::show_footer(); ?>