<h1>It's NewpixbOTTification time!</h1>
<form method="get" action="/cgi/npb/npbd">
NewpixbOTTify by URL<br>
- URL:
- <input type="text" name="inpix" value="http://">
+ URL of image:
+ <input type="text" name="inpix">
<input type="submit" value="NewpixbOTTify!">
</form>
Please don't hotlink the result. If you do, each time someone sees your link, my server will have to generate the image again!
+ <br><br>
+ <form method="post" action="/cgi/npb/npbd" enctype="multipart/form-data">
+ NewpixbOTTify by file upload<br>
+ Upload the image:
+ <input type="file" name="inpix">
+ <input type="submit" value="NewpixbOTTify!">
+ </form>
</body>
</html>
#include <cgi.h>
#include <stdio.h>
#include <stdlib.h>
+//#include <strings.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/stat.h>
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)