summaryrefslogtreecommitdiff
path: root/ws2a
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-10 14:04:42 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-10 14:04:42 -0400
commit335ecf09f90357dce2bd641296bec0127fd50758 (patch)
tree9d983ac35f68cb74676e886a3c5839646e57098e /ws2a
parent927c844f3d87fa6d6db1ac2ad93813ed06277939 (diff)
downloadwebpage-335ecf09f90357dce2bd641296bec0127fd50758.tar.gz
webpage-335ecf09f90357dce2bd641296bec0127fd50758.tar.bz2
webpage-335ecf09f90357dce2bd641296bec0127fd50758.zip
Changed the way captchas are served back
Diffstat (limited to 'ws2a')
-rw-r--r--ws2a/bugview.js9
-rw-r--r--ws2a/gencaptcha.c18
2 files changed, 16 insertions, 11 deletions
diff --git a/ws2a/bugview.js b/ws2a/bugview.js
index 60ffb11..0f1d5c6 100644
--- a/ws2a/bugview.js
+++ b/ws2a/bugview.js
@@ -71,14 +71,5 @@ function loadLastBugs() {
var bugnum = query["id"];
xhttp.open("GET", "/cgi-bin/showbug.cgi?id="+bugnum, true);
xhttp.send();
- var captcha = new XMLHttpRequest();
- captcha.onreadystatechange = function() {
- if (captcha.readyState == 4 && captcha.status == 200) {
- var imgname = xhttp.response;
- document.getElementById("captchaimg").innerHTML = "<img src=\"./captchas/" + imgname + ".png";
- }
- };
- captcha.open("GET","/cgi-bin/gencaptcha.cgi",true);
- captcha.send();
}
window.onload = loadLastBugs
diff --git a/ws2a/gencaptcha.c b/ws2a/gencaptcha.c
index 964e730..d0f9e50 100644
--- a/ws2a/gencaptcha.c
+++ b/ws2a/gencaptcha.c
@@ -50,7 +50,7 @@ void createRandomWords(char* buf){
int main(){
printf("%s%c%c\n",
- "Content-Type:text/html;charset=iso-8859-1",13,10);
+ "Content-Type:image/png",13,10);
srand(time(NULL));
char randwords[LONGADJ+LONGNOU+1];
@@ -67,5 +67,19 @@ int main(){
sprintf(command,"convert \"../ws2a/captchas/%s.png\" -virtual-pixel White -distort Arc %d \"../ws2a/captchas/%s.png\"",randwords,arcdis,randwords);
system(command);
- printf(randwords);
+ FILE* imgfile;
+ char filepath[100];
+ sprintf(filepath,"../ws2a/captchas/%s.png",randwords);
+ imgfile = fopen(filepath,"r");
+ if(imgfile == NULL){
+ printf("Unable to open file!");
+ return 1;
+ }
+ while(!feof(imgfile)){
+ char c = fgetc(imgfile);
+ if(feof(imgfile)){
+ return 0;
+ }
+ putchar(c);
+ }
}