summaryrefslogtreecommitdiff
path: root/ws2a/bugcomment.c
diff options
context:
space:
mode:
Diffstat (limited to 'ws2a/bugcomment.c')
-rw-r--r--ws2a/bugcomment.c65
1 files changed, 13 insertions, 52 deletions
diff --git a/ws2a/bugcomment.c b/ws2a/bugcomment.c
index d96a0ef..afd0e6c 100644
--- a/ws2a/bugcomment.c
+++ b/ws2a/bugcomment.c
@@ -4,25 +4,26 @@
#include <stdint.h>
char* replaceHTML(char* str){
- printf("Replaceing:%s\n",str);
+ //printf("Replaceing:%s\n",str);
char* nstr = malloc((sizeof(char)*strlen(str)) + 1);
if(nstr == NULL){
+ printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("Failed to allocate memory!\n");
}
int strp = 0;
int nstrp = 0;
while(str[strp] != '\0'){
- printf("Strp=%d nstrp=%d\n",strp,nstrp);
+ //printf("Strp=%d nstrp=%d\n",strp,nstrp);
if(str[strp] == '+'){
nstr[nstrp] = ' ';
strp++;
nstrp++;
}else if(str[strp] == '%'){
- printf("Hit encodeing!\n");
+ //printf("Hit encodeing!\n");
int hex;
sscanf(str+strp,"%%%x",&hex);
- printf("Was:%c\n",(char)hex);
+ //printf("Was:%c\n",(char)hex);
nstr[nstrp] = (char)hex;
nstrp++;
strp+=3;
@@ -33,7 +34,7 @@ char* replaceHTML(char* str){
}
}
nstr[nstrp] = '\0';
- printf("Done, str is now:%s\n",nstr);
+ //printf("Done, str is now:%s\n",nstr);
return nstr;
}
@@ -76,9 +77,6 @@ int main(){
char* data = getenv("QUERY_STRING");
//char data[20] = "?id=1";
char* hardip = getenv("REMOTE_ADDR");
- printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
- printf("<p>data:%s",data);
-
char name[15];
char userid[20];
@@ -106,7 +104,7 @@ int main(){
char* bugid = "1";
*/
- printf("<p>name:%s<p>userid:%s<p>comment:%s<p>captcha:%s<p>bugid:%s",name,userid,comment,captcha,bugid);
+ //printf("<p>name:%s<p>userid:%s<p>comment:%s<p>captcha:%s<p>bugid:%s",name,userid,comment,captcha,bugid);
//Check captcha
char captchapath[100];
@@ -115,6 +113,7 @@ int main(){
FILE* captchafile = fopen(captchapath,"r");
if(captchafile == NULL){
+ printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("Captcha incorrect");
return;
}
@@ -124,11 +123,10 @@ int main(){
unsigned long filehash = 0;
fscanf(captchafile,"%lu",&filehash);
if(filehash != inputhash){
+ printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("Captcha incorrect");
- printf("input:%lu correct:%lu",inputhash,filehash);
return;
}
- printf("Captcha correct, deleteing...");
char command[100];
sprintf(command,"rm \"%s.txt\"",captchapath);
@@ -139,56 +137,19 @@ int main(){
sprintf(filepath,"../ws2a/bugs/%s",bugid);
FILE* bugfile = fopen(filepath,"a");
if(bugfile == NULL){
+ printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("<p>Unable to find bug!");
return;
}
char* dname = replaceHTML(name);
char* duid = useridhash(userid);
char* dcomment = replaceHTML(comment);
- printf("Everything ok, inserting comment!");
+ printf("Location: ../ws2a/bugview.html?id=%s\n\n",bugid);
+ //printf("<p>data:%s",data);
+ //printf("Everything ok, inserting comment!");
fprintf(bugfile,"\n%s\n%s\n%s\n",dname,duid,dcomment);
free(dname);
free(duid);
free(dcomment);
- /*
- FILE* lastfilenum;
- lastfilenum = fopen("../ws2a/bugs/lastbug","r");
- if(lastfilenum == NULL){
- printf("Error reteriveing bugs, contact the admin!");
- return 1;
- }
- long long last = 0;
- if(fscanf(lastfilenum,"%lld",&last) < 1){
- printf("Error finding file id");
- return 1;
- }
- fclose(lastfilenum);
- long long thisid = 0;
- sscanf(data,"id=%lld",&thisid);
- if(thisid > last){
- printf("Invalid!");
- return 1;
- }
-
- char filestring[64] = "../ws2a/bugs/";
- char filename[10];
- sprintf(filename,"%lld",thisid);
- strcat(filestring,filename);
- FILE* bugfile;
- bugfile = fopen(filestring,"r");
- if(bugfile == NULL){
- printf("Unable to open bug file!");
- return 1;
- }
- while(!feof(bugfile)){
- char c = fgetc(bugfile);
- if(feof(bugfile)){
- break;
- }else{
- putchar(c);
- }
- }
- fclose(bugfile);
- */
return 0;
}