瀏覽代碼

Update readme, add SQL code, remove unused function in required.php

tags/v0.1^0
Skylar Ittner 2 年之前
父節點
當前提交
cbbd8859c8
共有 4 個文件被更改,包括 125 次插入32 次删除
  1. 二進制
      database.mwb
  2. 114
    0
      database.sql
  3. 11
    0
      readme.md
  4. 0
    32
      required.php

二進制
database.mwb 查看文件


+ 114
- 0
database.sql 查看文件

@@ -0,0 +1,114 @@
1
+-- MySQL Script generated by MySQL Workbench
2
+-- Fri 09 Jun 2017 03:48:51 AM MDT
3
+-- Model: New Model    Version: 1.0
4
+-- MySQL Workbench Forward Engineering
5
+
6
+SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
7
+SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
8
+SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
9
+
10
+-- -----------------------------------------------------
11
+-- Schema captcheck
12
+-- -----------------------------------------------------
13
+
14
+-- -----------------------------------------------------
15
+-- Schema captcheck
16
+-- -----------------------------------------------------
17
+CREATE SCHEMA IF NOT EXISTS `captcheck` DEFAULT CHARACTER SET utf8 ;
18
+USE `captcheck` ;
19
+
20
+-- -----------------------------------------------------
21
+-- Table `captcheck`.`answers`
22
+-- -----------------------------------------------------
23
+CREATE TABLE IF NOT EXISTS `captcheck`.`answers` (
24
+  `aid` INT NOT NULL AUTO_INCREMENT,
25
+  `aname` VARCHAR(45) NOT NULL,
26
+  `aimg` VARCHAR(45) NOT NULL,
27
+  PRIMARY KEY (`aid`),
28
+  UNIQUE INDEX `aid_UNIQUE` (`aid` ASC))
29
+ENGINE = InnoDB;
30
+
31
+
32
+-- -----------------------------------------------------
33
+-- Table `captcheck`.`sessions`
34
+-- -----------------------------------------------------
35
+CREATE TABLE IF NOT EXISTS `captcheck`.`sessions` (
36
+  `sid` INT NOT NULL AUTO_INCREMENT,
37
+  `skey` VARCHAR(60) NOT NULL,
38
+  `aid` INT NOT NULL,
39
+  `expired` TINYINT(1) NOT NULL DEFAULT 0,
40
+  `timestamp` DATETIME NOT NULL,
41
+  PRIMARY KEY (`sid`),
42
+  UNIQUE INDEX `sid_UNIQUE` (`sid` ASC),
43
+  INDEX `fk_sessions_answers1_idx` (`aid` ASC),
44
+  CONSTRAINT `fk_sessions_answers1`
45
+    FOREIGN KEY (`aid`)
46
+    REFERENCES `captcheck`.`answers` (`aid`)
47
+    ON DELETE NO ACTION
48
+    ON UPDATE NO ACTION)
49
+ENGINE = InnoDB;
50
+
51
+
52
+-- -----------------------------------------------------
53
+-- Table `captcheck`.`scrambled_answers`
54
+-- -----------------------------------------------------
55
+CREATE TABLE IF NOT EXISTS `captcheck`.`scrambled_answers` (
56
+  `sid` INT NOT NULL,
57
+  `aid` INT NOT NULL,
58
+  `acode` VARCHAR(20) NOT NULL,
59
+  INDEX `fk_sessions_has_answers_answers1_idx` (`aid` ASC),
60
+  INDEX `fk_sessions_has_answers_sessions1_idx` (`sid` ASC),
61
+  CONSTRAINT `fk_sessions_has_answers_sessions1`
62
+    FOREIGN KEY (`sid`)
63
+    REFERENCES `captcheck`.`sessions` (`sid`)
64
+    ON DELETE NO ACTION
65
+    ON UPDATE NO ACTION,
66
+  CONSTRAINT `fk_sessions_has_answers_answers1`
67
+    FOREIGN KEY (`aid`)
68
+    REFERENCES `captcheck`.`answers` (`aid`)
69
+    ON DELETE NO ACTION
70
+    ON UPDATE NO ACTION)
71
+ENGINE = InnoDB;
72
+
73
+
74
+SET SQL_MODE=@OLD_SQL_MODE;
75
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
76
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
77
+
78
+-- -----------------------------------------------------
79
+-- Data for table `captcheck`.`answers`
80
+-- -----------------------------------------------------
81
+START TRANSACTION;
82
+USE `captcheck`;
83
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (1, 'heart', 'heart');
84
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (2, 'envelope', 'envelope');
85
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (3, 'building', 'building');
86
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (4, 'camera', 'camera');
87
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (5, 'cloud', 'cloud');
88
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (6, 'circle', 'circle');
89
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (7, 'girl', 'female');
90
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (8, 'boy', 'male');
91
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (9, 'paper', 'file-o');
92
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (10, 'smartphone', 'mobile');
93
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (11, 'moon', 'moon-o');
94
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (12, 'pencil', 'pencil');
95
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (13, 'paint brush', 'paint-brush');
96
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (14, 'airplane', 'plane');
97
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (15, 'printer', 'print');
98
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (16, 'puzzle piece', 'puzzle-piece');
99
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (17, 'picture', 'picture-o');
100
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (18, 'sun', 'sun-o');
101
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (19, 'star', 'star');
102
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (20, 'square', 'square');
103
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (21, 'tree', 'tree');
104
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (22, 'umbrella', 'umbrella');
105
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (23, 'snowflake', 'snowflake-o');
106
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (24, 'basket', 'shopping-basket');
107
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (25, 'globe', 'globe');
108
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (26, 'flag', 'flag');
109
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (27, 'cube', 'cube');
110
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (28, 'lightning', 'bolt');
111
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (29, 'truck', 'truck');
112
+INSERT INTO `captcheck`.`answers` (`aid`, `aname`, `aimg`) VALUES (30, 'gear', 'cog');
113
+
114
+COMMIT;

+ 11
- 0
readme.md 查看文件

@@ -4,6 +4,7 @@ Captcheck
4 4
 Easy, light, self-hostable CAPTCHA service.  Works on all modern browsers and 
5 5
 IE9+.  Uses icons from Font-Awesome.
6 6
 
7
+
7 8
 How to use
8 9
 ----------
9 10
 
@@ -45,6 +46,16 @@ Example responses:
45 46
 `{"session":"some_session_id","result":false,"msg":"Answer incorrect."}`
46 47
 
47 48
 
49
+Installation
50
+------------
51
+
52
+1. Run composer install.
53
+2. Copy settings.template.php to settings.php and plug in your settings.
54
+3. Install the database.
55
+4. Customize captcheck.js with the correct api_url.
56
+5. Follow the How to Use section and the example setup in test.html and test.php.
57
+
58
+
48 59
 Execution Flow
49 60
 --------------
50 61
 

+ 0
- 32
required.php 查看文件

@@ -84,38 +84,6 @@ function is_empty($str) {
84 84
     return (is_null($str) || !isset($str) || $str == '');
85 85
 }
86 86
 
87
-/*
88
- * http://stackoverflow.com/a/20075147/2534036
89
- */
90
-if (!function_exists('base_url')) {
91
-
92
-    function base_url($atRoot = FALSE, $atCore = FALSE, $parse = FALSE) {
93
-        if (isset($_SERVER['HTTP_HOST'])) {
94
-            $http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
95
-            $hostname = $_SERVER['HTTP_HOST'];
96
-            $dir = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
97
-
98
-            $core = preg_split('@/@', str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(dirname(__FILE__))), NULL, PREG_SPLIT_NO_EMPTY);
99
-            $core = $core[0];
100
-
101
-            $tmplt = $atRoot ? ($atCore ? "%s://%s/%s/" : "%s://%s/") : ($atCore ? "%s://%s/%s/" : "%s://%s%s");
102
-            $end = $atRoot ? ($atCore ? $core : $hostname) : ($atCore ? $core : $dir);
103
-            $base_url = sprintf($tmplt, $http, $hostname, $end);
104
-        } else
105
-            $base_url = 'http://localhost/';
106
-
107
-        if ($parse) {
108
-            $base_url = parse_url($base_url);
109
-            if (isset($base_url['path']))
110
-                if ($base_url['path'] == '/')
111
-                    $base_url['path'] = '';
112
-        }
113
-
114
-        return $base_url;
115
-    }
116
-
117
-}
118
-
119 87
 
120 88
 /**
121 89
  * Attempts to discover the user's IP address.

Loading…
取消
儲存