diff options
| author | Alexander Pickering <Apickx@cogarr.org> | 2016-05-10 15:19:10 -0400 |
|---|---|---|
| committer | Alexander Pickering <Apickx@cogarr.org> | 2016-05-10 15:19:10 -0400 |
| commit | 8de5ff8c80980d31ffa0698cbbf4886680cd2343 (patch) | |
| tree | 07310c5095aa577853edebf1baf7f3d9062e4a00 | |
| parent | 210ecc4a8d79c7f069efbd132d3a97137134bda0 (diff) | |
| parent | 5d5d288bb595ae2297c99071f4db2a095c3ed101 (diff) | |
| download | webpage-8de5ff8c80980d31ffa0698cbbf4886680cd2343.tar.gz webpage-8de5ff8c80980d31ffa0698cbbf4886680cd2343.tar.bz2 webpage-8de5ff8c80980d31ffa0698cbbf4886680cd2343.zip | |
Merge branch 'development'
| -rw-r--r-- | ws2a/gencaptcha.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/ws2a/gencaptcha.c b/ws2a/gencaptcha.c index d0f9e50..8141ee5 100644 --- a/ws2a/gencaptcha.c +++ b/ws2a/gencaptcha.c @@ -49,8 +49,6 @@ void createRandomWords(char* buf){ } int main(){ - printf("%s%c%c\n", - "Content-Type:image/png",13,10); srand(time(NULL)); char randwords[LONGADJ+LONGNOU+1]; @@ -58,7 +56,7 @@ int main(){ int barraldis1 = rand()%10; int barraldis2 = rand()%10; - int arcdis = rand()%100; + int arcdis = (rand()%99)+1; char command[1024]; sprintf(command,"convert -background white -fill black -pointsize 48 label:\"%s\" \"../ws2a/captchas/%s.png\"",randwords,randwords); system(command); @@ -66,20 +64,39 @@ int main(){ system(command); sprintf(command,"convert \"../ws2a/captchas/%s.png\" -virtual-pixel White -distort Arc %d \"../ws2a/captchas/%s.png\"",randwords,arcdis,randwords); system(command); - + sleep(1); FILE* imgfile; char filepath[100]; - sprintf(filepath,"../ws2a/captchas/%s.png",randwords); - imgfile = fopen(filepath,"r"); + sprintf(filepath,"..\\ws2a\\captchas\\%s.png",randwords); + //printf("Filepath:%s",filepath); + imgfile = fopen(filepath,"rb"); if(imgfile == NULL){ printf("Unable to open file!"); return 1; } - while(!feof(imgfile)){ - char c = fgetc(imgfile); - if(feof(imgfile)){ - return 0; - } - putchar(c); + fseek(imgfile,0,SEEK_END); + unsigned long filelen = ftell(imgfile); + //printf("File length:%lu",filelen); + fseek(imgfile,0,SEEK_SET); + //fwrite(imgfile,1,filelen,stdout); + + char* buffer = malloc(filelen+1); + if(buffer == NULL){ + printf("Memory error!"); + return 1; + } + fread(buffer, filelen, 1, imgfile); + int i = 0; + while(i < filelen){ + printf("%c",buffer[i]); + i++; + } + free(buffer); + /* + char c; + while((c = fgetc(imgfile)) && !feof(imgfile)){ + printf("char is:something\n",c); + //putchar(c); } + */ } |
