xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit 53531783fef35e191df784150c0edb597d8b48b5

Add question captcha for anonymous bug adding
Author: xaizek
Author date (UTC): 2019-07-08 13:02
Committer name: xaizek
Committer date (UTC): 2019-07-08 16:07
Parent(s): 6de27cabb5e0c238a4d49ab66d5be97fadfd68f9
Signing key: 99DC5E4DB05F6BE2
Tree: b073f06b64303e69043cd4d3204284621897f8c2
File Lines added Lines deleted
inc/bug.inc.php 17 0
root/themes/default/repo/bug/bug_add_edit.html 12 0
root/themes/reversed.top/repo/bug/bug_add_edit.html 12 0
File inc/bug.inc.php changed (mode: 100644) (index 30482ec..d21107f)
... ... function rg_bug_edit_high_level($db, &$rg)
1282 1282 } }
1283 1283 } }
1284 1284
1285 $captcha_id = rg_var_str("captcha_id");
1286 $captcha_answer = rg_var_str("captcha_answer");
1287 rg_log("TEST: uid = " . $rg['login_ui']['uid']);
1288 rg_log("TEST: captcha_id = $captcha_id");
1289 rg_log("TEST: empty(captcha_id) = " . empty($captcha_id));
1290 if ($rg['login_ui']['uid'] == 0 && $captcha_id !== "") {
1291 if (empty($captcha_answer)) {
1292 $errmsg[] = "captcha cannot be empty";
1293 break;
1294 }
1295 if (!rg_captcha_verify($captcha_id, $captcha_answer)) {
1296 $errmsg[] = "wrong captcha";
1297 break;
1298 }
1299 }
1300
1285 1301 if (!rg_valid_referer()) { if (!rg_valid_referer()) {
1286 1302 $errmsg[] = "invalid referer; try again"; $errmsg[] = "invalid referer; try again";
1287 1303 break; break;
 
... ... function rg_bug_edit_high_level($db, &$rg)
1320 1336 $hints[]['HTML:hint'] = rg_template("hints/repo/bug/add.html", $rg, TRUE /* xss */); $hints[]['HTML:hint'] = rg_template("hints/repo/bug/add.html", $rg, TRUE /* xss */);
1321 1337 $rg['HTML:bug_edit_hints'] = rg_template_table("hints/list", $hints, $rg); $rg['HTML:bug_edit_hints'] = rg_template_table("hints/list", $hints, $rg);
1322 1338
1339 $rg = array_merge($rg, rg_captcha_get());
1323 1340 $ret .= rg_template("repo/bug/bug_add_edit.html", $rg, TRUE /* xss */); $ret .= rg_template("repo/bug/bug_add_edit.html", $rg, TRUE /* xss */);
1324 1341 } }
1325 1342
File root/themes/default/repo/bug/bug_add_edit.html changed (mode: 100644) (index 3b2ba9c..0555ff6)
34 34 <textarea name="labels" id="labels" rows="3" cols="80">@@bug::labels@@</textarea> <textarea name="labels" id="labels" rows="3" cols="80">@@bug::labels@@</textarea>
35 35 </p> </p>
36 36
37 @@if(@@login_ui::uid@@ == 0){{
38 @@if(@@has_captcha@@ == 1){{
39 <p>
40 <input type="hidden" name="captcha_id" value="@@captcha_id@@" />
41 <label for="captcha_answer">
42 <span class="captcha_label">Captcha:</span><br/>@@captcha_question@@
43 </label>
44 <input name="captcha_answer" type="text" id="captcha_answer" value="@@captcha_answer@@" />
45 </p>
46 }}
47 }}
48
37 49 <input type="submit" name="button" value="@@if(@@bug::bug_id@@ == 0){{Add bug}}{{Update}}" /> <input type="submit" name="button" value="@@if(@@bug::bug_id@@ == 0){{Add bug}}{{Update}}" />
38 50
39 51 </form> </form>
File root/themes/reversed.top/repo/bug/bug_add_edit.html changed (mode: 100644) (index 3b2ba9c..0555ff6)
34 34 <textarea name="labels" id="labels" rows="3" cols="80">@@bug::labels@@</textarea> <textarea name="labels" id="labels" rows="3" cols="80">@@bug::labels@@</textarea>
35 35 </p> </p>
36 36
37 @@if(@@login_ui::uid@@ == 0){{
38 @@if(@@has_captcha@@ == 1){{
39 <p>
40 <input type="hidden" name="captcha_id" value="@@captcha_id@@" />
41 <label for="captcha_answer">
42 <span class="captcha_label">Captcha:</span><br/>@@captcha_question@@
43 </label>
44 <input name="captcha_answer" type="text" id="captcha_answer" value="@@captcha_answer@@" />
45 </p>
46 }}
47 }}
48
37 49 <input type="submit" name="button" value="@@if(@@bug::bug_id@@ == 0){{Add bug}}{{Update}}" /> <input type="submit" name="button" value="@@if(@@bug::bug_id@@ == 0){{Add bug}}{{Update}}" />
38 50
39 51 </form> </form>
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master