]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
Suddenly, 403!
authorb <b@0d794883-4e4e-4f65-aa7a-0e7f5947bab5>
Sun, 19 Jan 2014 15:17:23 +0000 (15:17 +0000)
committerb <b@0d794883-4e4e-4f65-aa7a-0e7f5947bab5>
Sun, 19 Jan 2014 15:17:23 +0000 (15:17 +0000)
git-svn-id: svn://botcastle1b/npb@25 0d794883-4e4e-4f65-aa7a-0e7f5947bab5

403 [new file with mode: 0755]
403.cpp [new file with mode: 0644]
403.htm [new file with mode: 0644]
403.png [new file with mode: 0644]
503.png [new file with mode: 0644]
makefile
npb.htm

diff --git a/403 b/403
new file mode 100755 (executable)
index 0000000..1f19398
Binary files /dev/null and b/403 differ
diff --git a/403.cpp b/403.cpp
new file mode 100644 (file)
index 0000000..a08e577
--- /dev/null
+++ b/403.cpp
@@ -0,0 +1,325 @@
+    //  //It's NewpixbOTTification Time!
+   //  // Take a picture and add a newpixbot to it!
+  //  //  
+ //  //   Requires Dev Image Library,
+//  //  //on Pentium III libdevil must be
+   //  // recompiled with --disable-ssl2 --disable-ssl3
+  //  //
+ //  //   ~~bicyclesonthemoon
+
+#define INPIX_MUSTARD 1
+#define OUTPIX_MUSTARD 2
+#define NPBPIX_MUSTARD 3
+#define ARGUMENT_MUSTARD 4
+#define SEAISH_MUSTARD 5
+#define ANIMATED_MUSTARD 6
+#define FAIL 900
+#define OK 0
+
+#define NPBPIX0 "npb0.png"
+#define X0  411
+#define X01  21
+#define X02  96
+#define Y0  404
+#define Y01 214
+#define Y02  68
+
+#define NPBPIX1 "npb1.png"
+#define X1  411
+#define X11  22
+#define X12 133
+#define Y1  404
+#define Y11 241
+#define Y12  94
+
+#define NPBPIX2 "npb2.png"
+#define X2  411
+#define X21 213
+#define Y2  404
+#define Y21 234
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <IL/il.h>
+
+void mustard(int mustard);
+void loadnpb(const char *path);
+void npbottify0(const char *path);
+void npbottify1(const char *path);
+void npbottify2(const char *path);
+int main (int argc, const char *argv[]);
+
+ILuint inPix, outPix, npbPix;
+ILboolean q=true;
+ILboolean inH=false;
+ILboolean outH=false;
+ILboolean npbH=false;
+ILuint inX, inY, outX, outY;
+ILubyte *newdata;
+
+int main (int argc, const char *argv[])
+{
+       if(argc<3)
+               mustard(ARGUMENT_MUSTARD);
+       if (argc>=4)
+       {
+               if (argv[3][0]=='q' || argv[3][0]=='Q')
+                       q=false;
+       }
+       
+       ilInit();
+       if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
+       if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
+       ilClearColour(255,255,0,0);
+       ilGenImages(1, &inPix);
+       inH=true;
+       ilBindImage(inPix);
+       if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
+       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
+       //if(!ilConvertPal(IL_PAL_RGBA32))mustard(FAIL);
+       
+       inX=ilGetInteger(IL_IMAGE_WIDTH);
+       inY=ilGetInteger(IL_IMAGE_HEIGHT);
+       if(ilGetInteger(IL_NUM_IMAGES)>1)
+               mustard(ANIMATED_MUSTARD);
+       
+       if(inX<=X02&&inY<=Y02)
+               npbottify0(argv[2]);
+       else if(inX<=X12&&inY<=Y12)
+               npbottify1(argv[2]);
+       else
+               npbottify2(argv[2]);    
+       //ok
+       mustard(0);
+}
+
+void loadnpb(const char *path)
+{
+       ilGenImages(1, &npbPix);
+       npbH=true;
+       ilBindImage(npbPix);
+       if(!ilLoadImage(path))mustard(NPBPIX_MUSTARD);
+       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(NPBPIX_MUSTARD);
+}
+
+void npbottify0(const char *path)
+{
+       //newdata= new ILubyte[X0*Y0*4];
+       ilGenImages(1, &outPix);
+       outH=true;
+       loadnpb(NPBPIX0);
+       ilBindImage(outPix);
+       if(!ilCopyImage(npbPix))mustard(FAIL);
+       //if(!ilTexImage(X0,Y0,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
+       //if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(OUTPIX_MUSTARD);
+       newdata=ilGetData();
+       for(unsigned long i=0;i<X0;++i)
+       {
+               for(unsigned long j=0;j<Y0;++j)
+               {
+                       if((i>=X01+(X02-inX)/2)&&
+                          (i< X01+(X02-inX)/2+inX)&&
+                          (j>=Y01+(Y02-inY)/2)&&
+                          (j< Y01+(Y02-inY)/2+inY))
+                       {
+                               newdata[4*(i+X0*j)+0]=0xFF;
+                               newdata[4*(i+X0*j)+1]=0xFF;
+                               newdata[4*(i+X0*j)+2]=0xFF;
+                               newdata[4*(i+X0*j)+3]=0xFF;
+                       }
+                       else if((i>=X01)&&(i<X01+X02)&&
+                               (j>=Y01)&&(j<Y01+Y02))
+                       {
+                               newdata[4*(i+X0*j)+0]=0xFF;//looks better white
+                               newdata[4*(i+X0*j)+1]=0xFF;
+                               newdata[4*(i+X0*j)+2]=0xFF;
+                               newdata[4*(i+X0*j)+3]=0xFF;
+                       }
+                       else
+                       {
+                               //newdata[4*(i+X0*j)+0]=0xFF;
+                               //newdata[4*(i+X0*j)+1]=0xFF;
+                               //newdata[4*(i+X0*j)+2]=0xFF;
+                               //newdata[4*(i+X0*j)+3]=0x00;
+                       }
+               }
+       }
+       //if(!ilSetData(newdata))mustard(OUTPIX_MUSTARD);
+       
+       //printf("%d\n",iCurImage);
+       if(!ilOverlayImage(inPix,X01+(X02-inX)/2,Y0-inY-(Y01+(Y02-inY)/2),0))mustard(FAIL);
+       if(!ilOverlayImage(npbPix,0,0,0))mustard(FAIL);
+       if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
+}
+
+void npbottify1(const char *path)
+{
+       //newdata= new ILubyte[X0*Y0*4];
+       ilGenImages(1, &outPix);
+       outH=true;
+       loadnpb(NPBPIX1);
+       ilBindImage(outPix);
+       if(!ilCopyImage(npbPix))mustard(FAIL);
+       //if(!ilTexImage(X1,Y1,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
+       //if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(OUTPIX_MUSTARD);
+       newdata=ilGetData();
+       for(unsigned long i=0;i<X1;++i)
+       {
+               for(unsigned long j=0;j<Y1;++j)
+               {
+                       if((i>=X11+(X12-inX)/2)&&
+                          (i< X11+(X12-inX)/2+inX)&&
+                          (j>=Y11+(Y12-inY)/2)&&
+                          (j< Y11+(Y12-inY)/2+inY))
+                       {
+                               newdata[4*(i+X1*j)+0]=0xFF;
+                               newdata[4*(i+X1*j)+1]=0xFF;
+                               newdata[4*(i+X1*j)+2]=0xFF;
+                               newdata[4*(i+X1*j)+3]=0xFF;
+                       }
+                       else if((i>=X11)&&(i<X11+X12)&&
+                               (j>=Y11)&&(j<Y11+Y12))
+                       {
+                               newdata[4*(i+X1*j)+0]=0x00;
+                               newdata[4*(i+X1*j)+1]=0x00;
+                               newdata[4*(i+X1*j)+2]=0x00;
+                               newdata[4*(i+X1*j)+3]=0xFF;
+                       }
+                       else
+                       {
+                               //
+                       }
+               }
+       }
+       //if(!ilSetData(newdata))mustard(OUTPIX_MUSTARD);
+       
+       //printf("%d\n",iCurImage);
+       if(!ilOverlayImage(inPix,X11+(X12-inX)/2,Y1-inY-(Y11+(Y12-inY)/2),0))mustard(FAIL);
+       //(!ilOverlayImage(npbPix,0,0,0))mustard(FAIL);
+       if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
+}
+
+void npbottify2(const char *path)
+{
+       unsigned long i,j;
+       outX=(X21+inX+2>X2)?(X21+inX+2):X2;
+       outY=(Y21+inY+2>Y2)?(Y21+inY+2):Y2;
+       ilGenImages(1, &outPix);
+       outH=true;
+       loadnpb(NPBPIX2);
+       newdata=ilGetData();
+       ilBindImage(outPix);
+       if(!ilTexImage(outX,outY,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
+       if(!ilClearImage())mustard(FAIL);
+       ilSetPixels(outX-X2,0,0,X2,Y2,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
+       newdata=ilGetData();
+       for(i=outX-X21-inX-2;i<outX-X21+2;++i)
+       {
+               //printf("i=%lu\n",i);
+               for(j=Y21-2;j<Y21+inY+2;++j)
+               {
+                       //printf("i=%lu j=%lu\n",i,j);
+                       if((i==outX-X21-inX-2)||(i==outX-X21-inX-1)||
+                          (i==outX-X21    +1)||(i==outX-X21      )||
+                          (j==     Y21    -2)||(j==     Y21    -1)||
+                          (j==     Y21+inY+1)||(j==     Y21+inY  ))
+                       {
+                               newdata[4*(i+outX*j)+0]=0x00;
+                               newdata[4*(i+outX*j)+1]=0x00;
+                               newdata[4*(i+outX*j)+2]=0x00;
+                               newdata[4*(i+outX*j)+3]=0xFF;   
+                       }
+                       else
+                       {
+                               newdata[4*(i+outX*j)+0]=0xFF;
+                               newdata[4*(i+outX*j)+1]=0xFF;
+                               newdata[4*(i+outX*j)+2]=0xFF;
+                               newdata[4*(i+outX*j)+3]=0xFF;
+                       }
+               }
+       }
+       
+       if(!ilOverlayImage(inPix,outX-X21-inX,outY-Y21-inY,0))mustard(FAIL);
+       
+       i=outX-X21-inX-2;
+       j=Y21-2;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0x00;   
+       j=Y21+inY+1;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0x00;   
+       i=outX-X21+1;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0x00;   
+       j=Y21-2;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0x00;   
+       
+       i=outX-X21-inX;
+       j=Y21;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0xFF;   
+       j=Y21+inY-1;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0xFF;   
+       i=outX-X21-1;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0xFF;   
+       j=Y21;
+       newdata[4*(i+outX*j)+0]=0x00;
+       newdata[4*(i+outX*j)+1]=0x00;
+       newdata[4*(i+outX*j)+2]=0x00;
+       newdata[4*(i+outX*j)+3]=0xFF;
+       
+       if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
+
+       
+}
+
+void mustard(int mustard)
+{
+       switch(mustard)
+       {
+       case 0:
+               if(q) printf("NewpixbOTTified!\n");break;
+       case ARGUMENT_MUSTARD:
+               if(q) printf("npb inPix outPix [q]\n");break;
+       case INPIX_MUSTARD:
+               if(q) printf("inPIX mustard.\n");break;
+       case OUTPIX_MUSTARD:
+               if(q) printf("outPIX mustard.\n");break;
+       case NPBPIX_MUSTARD:
+               if(q) printf("npbPIX mustard.\n");break;
+       case SEAISH_MUSTARD:
+               if(q) printf("Seaishness is mustard.\n");break;
+       case ANIMATED_MUSTARD:
+               if(q) printf("Animation is mustard.\n");break;
+       default:
+               if (q) printf("Ch*rpin* mustard mustaard!\n");
+       }
+       if(inH)
+               ilDeleteImages(1, &inPix);
+       if(outH)
+       {
+               ilDeleteImages(1, &outPix);
+               //delete[] newdata;
+       }
+       if(npbH)
+               ilDeleteImages(1, &npbPix);
+       exit(mustard);
+}
+       
diff --git a/403.htm b/403.htm
new file mode 100644 (file)
index 0000000..a555251
--- /dev/null
+++ b/403.htm
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
+<html lang="pl">
+       <head>
+               <title>It's NewpixbOTTification time!</title>
+                       <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
+       </head>
+       <body>
+               <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.dnsd.info" border="0"></a>
+               <h1>It's 403ification time!</h1>
+               <form method="get" action="/cgi/npb/npbd/403">
+                       403 by URL<br>
+                       URL of image:
+                       <input type="text" name="inpix">
+                       <input type="submit" value="403">
+               </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/403" enctype="multipart/form-data">
+                       403 by file upload<br>
+                       Upload the image:
+                       <input type="file" name="inpix">
+                       <input type="submit" value="403">
+               </form>
+               <br>
+               Source code available at <a href="svn://bicyclesonthemoon.dnsd.info/npb">svn://bicyclesonthemoon.dnsd.info/npb</a> (use "e" to login) or <a href="http://1190.bicyclesonthemoon.dnsd.info/pro/npb">http://1190.bicyclesonthemoon.dnsd.info/pro/npb</a>.
+               
+       </body>
+</html>
diff --git a/403.png b/403.png
new file mode 100644 (file)
index 0000000..c6bc7de
Binary files /dev/null and b/403.png differ
diff --git a/503.png b/503.png
new file mode 100644 (file)
index 0000000..85181d2
Binary files /dev/null and b/503.png differ
index 34ab1149fbf9a2cef62f6a4dc360d0afc9a25251..f863d6e6de1c25ac4babbb5bcb779f784d23b8bd 100644 (file)
--- a/makefile
+++ b/makefile
@@ -3,10 +3,13 @@ CF=-g -Wall
 LF=-lIL
 LF2=-lcgi
 
-all: npb npbd
+all: 403 npb npbd
 
 npb: npb.cpp makefile
        $(CC) $(CF) $(LF) -o npb npb.cpp
 
+403: 403.cpp makefile
+       $(CC) $(CF) $(LF) -o 403 403.cpp
+
 npbd: npb npbd.cpp makefile
        $(CC) $(CF) -o npbd npbd.cpp $(LF2)
diff --git a/npb.htm b/npb.htm
index 8dbf692f5a705abfa5572b0f6dcb10ec284af56d..e6f1498c4062c18ad1fc6ea0deed4183094acd39 100644 (file)
--- a/npb.htm
+++ b/npb.htm
@@ -5,6 +5,7 @@
                        <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
        </head>
        <body>
+               <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.dnsd.info" border="0"></a>
                <h1>It's NewpixbOTTification time!</h1>
                <form method="get" action="/cgi/npb/npbd">
                        NewpixbOTTify by URL<br>
@@ -20,5 +21,8 @@
                        <input type="file" name="inpix">
                        <input type="submit" value="NewpixbOTTify!">
                </form>
+               <br>
+               Source code available at <a href="svn://bicyclesonthemoon.dnsd.info/npb">svn://bicyclesonthemoon.dnsd.info/npb</a> (use "e" to login) or <a href="http://1190.bicyclesonthemoon.dnsd.info/pro/npb">http://1190.bicyclesonthemoon.dnsd.info/pro/npb</a>.
+               
        </body>
 </html>