1 // npbd.cpp - copied from the original NewpixbOTTification but not actually used
2 // The online interface for the NewpixbOTTification and 403fication software
5 // Copyright (C) 2014 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:
35 #define WGET_PATH "/usr/bin/wget"
36 #define NPB_PATH "/eizm/pro/ong1/npb"
37 #define MEG_PATH "./403"
38 #define RM_PATH "/bin/rm"
39 #define LOG_PATH "/eizm/log/npb/npb.log"
40 #define LOG_PATH2 "/eizm/log/npb/403.log"
41 #define USERAGENT "NewpixbOTTification\x20(1190.bicyclesonthemoon.dnsd.info/npb/npb.htm)"
42 #define USERAGENT2 "403fication\x20(1190.bicyclesonthemoon.dnsd.info/npb/403.htm)"
43 #define MSTD_PATH "/pro/npb/mpb.png"
44 #define MSTD_PATH2 "/pro/npb/503.png"
46 int main (int argc, char *argv[]);
47 void mustard(int mustard);
50 unsigned char buf[1024];
63 int main (int argc, char *argv[])
67 sprintf(path,"%s",(getenv("PATH_INFO")!=NULL)?(getenv("PATH_INFO")):"");
68 if(strcmp(path,"/403")==0)
77 sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile);
78 sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename);
82 sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):"");
83 sprintf(path,"/var/tmp/%lu",(unsigned long)getpid());
85 //Why is there no spawnl() in linux?
89 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",meg?USERAGENT2:USERAGENT,"-O",path,url,(char *)0);
99 t=execl(meg?MEG_PATH:NPB_PATH,meg?MEG_PATH:NPB_PATH,path,path,"q",(char *)0);
105 pix=fopen(path,"rb");
108 fstat(fileno(pix),&st);
112 printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
113 printf("Content-type: image/png\n\n");
114 for(unsigned long i=0;i<p;++i)
116 fread(buf,1,1024,pix);
117 fwrite(buf,1,1024,stdout);
122 fwrite(buf,1,q,stdout);
126 mustard(0);//no mustard
129 void mustard(int mustard)
133 cgiRedirect(meg?MSTD_PATH2:MSTD_PATH);
138 t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
142 // pix=fopen(meg?LOG_PATH2:LOG_PATH,"at");
145 // fprintf(pix,"%x %s\n",mustard,url);