--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
+<html lang="pl">
+ <head>
+ <title>ENHANCE! • Bicycles on the Moon</title>
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
+ <link rel="icon" type="image/png" href="/img/favicon.png"/>
+ </head>
+ <body>
+ <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.dnsd.info" border="0"></a>
+ <h1>ENHANCE!</h1>
+ <form method="post" action="/cgi/bluenh/bluenhd" enctype='multipart/form-data'>
+ <img src="param.png" alt="parameter explanation picture"><br>
+ <br>
+ a=<input type="text" name="a" value= "0">, b=<input type="text" name="b" value= "34">, c=<input type="text" name="c" value= "41">,<br>
+ d=<input type="text" name="d" value= "0">, e=<input type="text" name="e" value= "40">, f=<input type="text" name="f" value="255">.<br>
+ <br>
+
+ Enhance by URL<br>
+ URL of image:
+ <input type="text" name="inpix">
+ <input type="submit" value="ENHANCE!"><br>
+ <br>
+ Enhance by file upload<br>
+ Upload the image:
+ <input type="file" name="inpix2">
+ <input type="submit" value="ENHANCE!">
+ </form>
+ <br>
+ <br>
+ Source code available at <a href="svn://bicyclesonthemoon.dnsd.info/bluenh">svn://bicyclesonthemoon.dnsd.info/bluenh</a> (use "e" to login) or <a href="http://1190.bicyclesonthemoon.dnsd.info/pro/bluenh">http://1190.bicyclesonthemoon.dnsd.info/pro/bluenh</a>.
+
+ </body>
+</html>
--- /dev/null
+// // //Download images and
+ // // ENHANCE them!
+ // //
+ // // Requires cgilib
+// // //line 146 of cgi.h
+ // // must be changed
+ // // from "extern }"
+ // // to "}"
+// // //
+ // // ~~bicyclesonthemoon
+
+#include <cgi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
+#define WGET_PATH "/usr/bin/wget"
+#define ENH_PATH "./bluenh"
+#define RM_PATH "/bin/rm"
+#define LOG_PATH "/eizm/log/bluenh/bluenh.log"
+#define USERAGENT "Bluenhancement\x20(1190.bicyclesonthemoon.dnsd.info/bluenh/bluenh.htm)"
+#define MSTD_PATH "/pro/bluenh/nh.png"
+
+int main (int argc, char *argv[]);
+void mustard(int mustard);
+
+FILE *pix;
+unsigned char buf[1024];
+char url[1024];
+char path[256];
+char method[256];
+s_cgi *cgi;
+int t;
+pid_t sub;
+struct stat st;
+unsigned long p;
+unsigned short q;
+char **up;
+// unsigned char a,b,c,d,e,f;
+// bool meg=false;
+
+int main (int argc, char *argv[])
+{
+ cgi=cgiInit();
+
+ up=cgiGetFiles(cgi);
+ if (up)
+ {
+ 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","-t","2","-U",USERAGENT,"-O",path,url,(char *)0);
+ exit(t);
+ }
+ waitpid(sub,&t,0);
+ if(t)mustard(t);
+ }
+
+ sub=fork();
+ if(sub==0)
+ {
+ t=execl(ENH_PATH,ENH_PATH,path,path,cgiGetValue(cgi,"a")!=NULL?cgiGetValue(cgi,"a"):"0",cgiGetValue(cgi,"b")!=NULL?cgiGetValue(cgi,"b"):"127",cgiGetValue(cgi,"c")!=NULL?cgiGetValue(cgi,"c"):"255",cgiGetValue(cgi,"d")!=NULL?cgiGetValue(cgi,"d"):"0",cgiGetValue(cgi,"e")!=NULL?cgiGetValue(cgi,"e"):"127",cgiGetValue(cgi,"f")!=NULL?cgiGetValue(cgi,"f"):"255","q",(char *)0);
+ exit(t);
+ }
+ waitpid(sub,&t,0);
+ if(t)mustard(t);
+
+ pix=fopen(path,"rb");
+ if(pix==NULL)
+ mustard(123);
+ fstat(fileno(pix),&st);
+ p=st.st_size/1024;
+ q=st.st_size%1024;
+
+ printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
+ printf("Content-type: image/png\n\n");
+ for(unsigned long i=0;i<p;++i)
+ {
+ fread(buf,1,1024,pix);
+ fwrite(buf,1,1024,stdout);
+ }
+ if(q!=0)
+ {
+ fread(buf,1,q,pix);
+ fwrite(buf,1,q,stdout);
+ }
+ fclose(pix);
+ fflush(stdout);
+ mustard(0);//no mustard
+}
+
+void mustard(int mustard)
+{
+ if(mustard)
+ {
+ cgiRedirect(MSTD_PATH);
+ }
+ sub=fork();
+ if(sub==0)
+ {
+ t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
+ exit(t);
+ }
+ waitpid(sub,&t,0);
+ pix=fopen(LOG_PATH,"at");
+ if(pix!=NULL)
+ {
+ fprintf(pix,"%x %s\n",mustard,url);
+ fclose(pix);
+ }
+ exit(mustard);
+}
\ No newline at end of file