154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
+
-
+
+
-
+
+
+
+
+
|
** This routine returns true if a captcha was rendered and if subsequent
** page generation should be aborted. It returns false if the page
** should not be restricted and should be rendered normally.
*/
int robot_restrict(const char *zPage){
const char *zGlob;
const char *zToken;
static int bKnownPass = 0;
if( g.zLogin ) return 0; /* Logged in users always get through */
if( g.zLogin ) return 0; /* Logged in users always get through */
if( bKnownPass ) return 0; /* Already known to pass robot restrictions */
zGlob = db_get("robot-restrict",robot_restrict_default());
if( zGlob==0 || zGlob[0]==0 ) return 0;
if( zGlob==0 || zGlob[0]==0 ){ bKnownPass = 1; return 0; }
if( !glob_multi_match(zGlob, zPage) ) return 0;
zToken = P("token");
if( zToken!=0
&& db_exists("SELECT 1 FROM config WHERE name='token-%q'", zToken)
){
bKnownPass = 1;
return 0; /* There is a valid token= query parameter */
}
if( robot_proofofwork() ){
/* A captcha was generated. Abort this page. A redirect will occur
** if the captcha passes. */
return 1;
}
bKnownPass = 1;
return 0;
}
/*
** WEBPAGE: test-robotck
**
|