From: b Date: Tue, 31 Dec 2013 17:42:29 +0000 (+0000) Subject: Let's upload something! X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=ad1deef32222a8fc7ec2bac8a1804dc3a6eab971;p=ott%2Fenhance Let's upload something! git-svn-id: svn://botcastle1b/npb@22 0d794883-4e4e-4f65-aa7a-0e7f5947bab5 --- diff --git a/npb.htm b/npb.htm index b137293..8dbf692 100644 --- a/npb.htm +++ b/npb.htm @@ -8,10 +8,17 @@

It's NewpixbOTTification time!

NewpixbOTTify by URL
- URL: - + URL of image: +
Please don't hotlink the result. If you do, each time someone sees your link, my server will have to generate the image again! +

+
+ NewpixbOTTify by file upload
+ Upload the image: + + +
diff --git a/npbd b/npbd index 9fc150e..b0a9d90 100755 Binary files a/npbd and b/npbd differ diff --git a/npbd.cpp b/npbd.cpp index ea09373..0fa2288 100644 --- a/npbd.cpp +++ b/npbd.cpp @@ -12,6 +12,7 @@ #include #include #include +//#include #include #include #include @@ -28,31 +29,40 @@ FILE *pix; unsigned char buf[1024]; char url[1024]; char path[256]; -//char cmd[1024]; +char method[256]; s_cgi *cgi; int t; pid_t sub; struct stat st; unsigned long p; unsigned short q; +char **up; int main (int argc, char *argv[]) { - cgi=cgiInit(); - sprintf(url,"%s",cgiGetValue(cgi,"inpix")); - sprintf(path,"/var/tmp/%lu",(unsigned long)getpid()); - - //Why is there no spawnl() in linux? - sub=fork(); - if(sub==0) + up=cgiGetFiles(cgi); + if (up) { - t=execl(WGET_PATH,WGET_PATH,"-q","-O",path,url,(char *)0); - exit(t); + sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile); + sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename); + } + else + { + sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):""); + sprintf(path,"/var/tmp/%lu",(unsigned long)getpid()); + + //Why is there no spawnl() in linux? + sub=fork(); + if(sub==0) + { + t=execl(WGET_PATH,WGET_PATH,"-q","-O",path,url,(char *)0); + exit(t); + } + waitpid(sub,&t,0); + if(t)mustard(t); } - waitpid(sub,&t,0); - if(t)mustard(t); sub=fork(); if(sub==0)