2 // The online interface for the fading enhancement tool
5 // Copyright (C) 2015 Balthasar Szczepański
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 // Requires cgilib (http://www.infodrom.org/projects/cgilib/)
22 // line 146 of cgi.h must be changed from:
28 Fri Jun 12, 2015 6:59 am UTC
30 Forum: Individual XKCD Comic Threads
45 #define WGET_PATH "/usr/bin/wget"
46 #define ENH_PATH "./nofading"
47 #define RM_PATH "/bin/rm"
48 #define LOG_PATH "/eizm/log/nofading/nofading.log"
49 #define USERAGENT "No fading (1190.bicyclesonthemoon.dnsd.info/nofading/nofading.htm)"
50 #define MSTD_PATH "/pro/nofading/nf.png"
52 int main (int argc, char *argv[]);
53 void mustard(int mustard);
63 int main (int argc, char *argv[])
65 unsigned char buf[1024];
76 sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile);
77 sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename);
81 sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):"");
82 sprintf(path,"/var/tmp/%lu",(unsigned long)getpid());
84 //Why is there no spawnl() in linux?
88 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path,url,(char *)0);
98 t=execl(ENH_PATH,ENH_PATH,path,path,(cgiGetValue(cgi,"f")!=NULL)?(cgiGetValue(cgi,"f")):"0","q",cgiGetValue(cgi,"a")!=NULL?"0":"a",(char *)0);
104 pix=fopen(path,"rb");
107 fstat(fileno(pix),&st);
111 printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
112 printf("Content-type: image/png\n\n");
113 for(unsigned long i=0;i<p;++i)
115 fread(buf,1,1024,pix);
116 fwrite(buf,1,1024,stdout);
121 fwrite(buf,1,q,stdout);
125 mustard(0);//no mustard
128 void mustard(int mustard)
132 cgiRedirect(MSTD_PATH);
137 t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
141 pix=fopen(LOG_PATH,"at");
144 fprintf(pix,"%x %s\n",mustard,url);