2 // The online interface for the tools to insert and extract indexed images
\r
5 // Copyright (C) 2015 Balthasar SzczepaĆski
\r
7 // This program is free software: you can redistribute it and/or modify
\r
8 // it under the terms of the GNU Affero General Public License as
\r
9 // published by the Free Software Foundation, either version 3 of the
\r
10 // License, or (at your option) any later version.
\r
12 // This program is distributed in the hope that it will be useful,
\r
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 // GNU Affero General Public License for more details.
\r
17 // You should have received a copy of the GNU Affero General Public License
\r
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
21 // Requires cgilib (http://www.infodrom.org/projects/cgilib/)
\r
28 #include <sys/wait.h>
\r
29 #include <sys/stat.h>
\r
31 #define WGET_PATH "/usr/bin/wget"
\r
32 #define INS_PATH "./insert"
\r
33 #define EXT_PATH "./extract"
\r
34 #define DIF_PATH "./seediff"
\r
36 #define RM_PATH "/bin/rm"
\r
37 #define LOG_PATH "/eizm/log/insertframe/insertframe.log"
\r
38 #define USERAGENT "Hidden frames. (1190.bicyclesonthemoon.dnsd.info/insertframe/insertframe.htm)"
\r
39 #define MSTD_PATH "/pro/insertframe/nclr.png"
\r
41 int main (int argc, char *argv[]);
\r
42 void mustard(int mustard);
\r
57 int main (int argc, char *argv[])
\r
59 unsigned char buf[1024];
\r
65 // unsigned short r0, r1;
\r
71 sprintf(path0,"%s",(cgiGetValue(cgi,"a")!=NULL)?(cgiGetValue(cgi,"a")):"0");
\r
73 // sprintf(path0,"%s",(cgiGetValue(cgi,"r0")!=NULL)?(cgiGetValue(cgi,"r0")):"1");
\r
75 // sprintf(path0,"%s",(cgiGetValue(cgi,"r1")!=NULL)?(cgiGetValue(cgi,"r1")):"0");
\r
78 up=cgiGetFiles(cgi);
\r
81 if (cgiGetFile(cgi,up[0])!=NULL)
\r
83 sprintf(path0,"%s",cgiGetFile(cgi,up[0])->tmpfile);
\r
84 sprintf(url0,"%s",cgiGetFile(cgi,up[0])->filename);
\r
87 if (cgiGetFile(cgi,up[1])!=NULL)
\r
89 sprintf(path1,"%s",cgiGetFile(cgi,up[1])->tmpfile);
\r
90 sprintf(url1,"%s",cgiGetFile(cgi,up[1])->filename);
\r
97 sprintf(url0,"%s",(cgiGetValue(cgi,"inpix0")!=NULL)?(cgiGetValue(cgi,"inpix0")):"");
\r
98 sprintf(path0,"/var/tmp/%lu_0",(unsigned long)getpid());
\r
103 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path0,url0,(char *)0);
\r
112 sprintf(url1,"%s",(cgiGetValue(cgi,"inpix1")!=NULL)?(cgiGetValue(cgi,"inpix1")):"");
\r
113 sprintf(path1,"/var/tmp/%lu_1",(unsigned long)getpid());
\r
120 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path1,url1,(char *)0);
\r
134 t=execl(INS_PATH,INS_PATH,path0,path1,path0,(cgiGetValue(cgi,"r0")!=NULL)?(cgiGetValue(cgi,"r0")):"1",(cgiGetValue(cgi,"r1")!=NULL)?(cgiGetValue(cgi,"r1")):"0","q",(char *)0);
\r
138 t=execl(EXT_PATH,EXT_PATH,path0,path0,path1,"q",(char *)0);
\r
141 t=execl(DIF_PATH,DIF_PATH,path0,path0,"q",(char *)0);
\r
150 pix=fopen((act==2?path1:path0),"rb");
\r
153 fstat(fileno(pix),&st);
\r
157 printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
\r
158 printf("Content-type: image/png\n\n");
\r
161 fread(buf,1,1024,pix);
\r
162 fwrite(buf,1,1024,stdout);
\r
166 fread(buf,1,q,pix);
\r
167 fwrite(buf,1,q,stdout);
\r
171 mustard(0);//no mustard
\r
175 void mustard(int mustard)
\r
179 cgiRedirect(MSTD_PATH);
\r
184 t=execl(RM_PATH,RM_PATH,"-f",path0,(char *)0);
\r
192 t=execl(RM_PATH,RM_PATH,"-f",path1,(char *)0);
\r
197 pix=fopen(LOG_PATH,"at");
\r
200 fprintf(pix,"%x %x %s %s\n",mustard,act,url0,url1);
\r