From: b <rowerynaksiezycu@gmail.com> Date: Mon, 5 Dec 2022 20:49:36 +0000 (+0000) Subject: newpixbot online X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=a4cc26155549eee6def832da05a6f641f92cd6ae;p=ott%2Fenhance newpixbot online --- diff --git a/bluenh-cgi.c b/bluenh-cgi.c index aa431db..b55cc8a 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -1,7 +1,7 @@ /* bluenh-cgi.c Online interface for npb -04.12.2022 +05.12.2022 Copyright (C) 2013, 2014, 2022 Balthasar SzczepaÅski @@ -141,12 +141,12 @@ int bluenh ( pid_t sub; int r; - snprintf(s_a, 4, "%"SCNuFAST8, a); - snprintf(s_b, 4, "%"SCNuFAST8, b); - snprintf(s_c, 4, "%"SCNuFAST8, c); - snprintf(s_d, 4, "%"SCNuFAST8, d); - snprintf(s_e, 4, "%"SCNuFAST8, e); - snprintf(s_f, 4, "%"SCNuFAST8, f); + snprintf(s_a, 4, "%"PRIuFAST8, a); + snprintf(s_b, 4, "%"PRIuFAST8, b); + snprintf(s_c, 4, "%"PRIuFAST8, c); + snprintf(s_d, 4, "%"PRIuFAST8, d); + snprintf(s_e, 4, "%"PRIuFAST8, e); + snprintf(s_f, 4, "%"PRIuFAST8, f); sub = fork(); if (sub == 0) diff --git a/bluenh.1.htm b/bluenh.1.htm index 12d07c6..c63c6db 100644 --- a/bluenh.1.htm +++ b/bluenh.1.htm @@ -2,8 +2,8 @@ <form method="post" action="/enhance/bluenh" enctype='multipart/form-data'> <img src="param.png" alt="parameter explanation picture"><br> <br> - a=<input class="pt" type="text" name="a" value= "0">, b=<input class="pt" type="text" name="b" value= "34">, c=<input class="pt" type="text" name="c" value= "41">,<br> - d=<input class="pt" type="text" name="d" value= "0">, e=<input class="pt" type="text" name="e" value= "40">, f=<input class="pt" type="text" name="f" value="255">.<br> + a=<input class="pt" type="text" name="a" value= "0" size="3">, b=<input class="pt" type="text" name="b" value= "34" size="3">, c=<input class="pt" type="text" name="c" value= "41" size="3">,<br> + d=<input class="pt" type="text" name="d" value= "0" size="3">, e=<input class="pt" type="text" name="e" value= "40" size="3">, f=<input class="pt" type="text" name="f" value="255" size="3">.<br> a < b < c<br> <br> Enhance by URL<br> diff --git a/diff-cgi.c b/diff-cgi.c index 2707359..27a3267 100644 --- a/diff-cgi.c +++ b/diff-cgi.c @@ -1,7 +1,7 @@ /* diff-cgi.c The online interface for the differential tool -04.12.2022 +05.12.2022 Copyright (C) 2022 Balthasar SzczepaÅski @@ -161,12 +161,12 @@ int diff ( pid_t sub; int r; - snprintf(s_ra, 4, "%"SCNuFAST8, ra); - snprintf(s_ga, 4, "%"SCNuFAST8, ga); - snprintf(s_ba, 4, "%"SCNuFAST8, ba); - snprintf(s_rb, 4, "%"SCNuFAST8, rb); - snprintf(s_gb, 4, "%"SCNuFAST8, gb); - snprintf(s_bb, 4, "%"SCNuFAST8, bb); + snprintf(s_ra, 4, "%"PRIuFAST8, ra); + snprintf(s_ga, 4, "%"PRIuFAST8, ga); + snprintf(s_ba, 4, "%"PRIuFAST8, ba); + snprintf(s_rb, 4, "%"PRIuFAST8, rb); + snprintf(s_gb, 4, "%"PRIuFAST8, gb); + snprintf(s_bb, 4, "%"PRIuFAST8, bb); sub = fork(); if (sub == 0) diff --git a/diff.1.htm b/diff.1.htm index 054500d..2393a54 100644 --- a/diff.1.htm +++ b/diff.1.htm @@ -9,9 +9,9 @@ File 2: <input class="pt" type="file" name="inpixf1"><br> <br> Color A:<br> - R=<input class="pt" type="text" name="ra" value= "0">, G=<input class="pt" type="text" name="ga" value= "87">, B=<input class="pt" type="text" name="ba" value="175"><br> + R=<input class="pt" type="text" name="ra" value= "0" size="3">, G=<input class="pt" type="text" name="ga" value= "87" size="3">, B=<input class="pt" type="text" name="ba" value="175" size="3"><br> Color B:<br> - R=<input class="pt" type="text" name="rb" value="187">, G=<input class="pt" type="text" name="gb" value="102">, B=<input class="pt" type="text" name="bb" value= "34"><br> + R=<input class="pt" type="text" name="rb" value="187" size="3">, G=<input class="pt" type="text" name="gb" value="102" size="3">, B=<input class="pt" type="text" name="bb" value= "34" size="3"><br> <br> <input class="pk" type="submit" value="ENHANCE!"><br> </form> \ No newline at end of file diff --git a/enhance.1.conf b/enhance.1.conf index 4a138c7..58eff10 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -3,6 +3,7 @@ ScriptAlias /enhance/bluenh ###CONF_bluenh; ScriptAlias /enhance/diff ###CONF_diff; ScriptAlias /enhance/nofading ###CONF_nofading; +ScriptAlias /enhance/npb ###CONF_npb; ScriptAlias /enhance/reveal ###CONF_reveal; <Directory ###CONF_bin;> @@ -11,8 +12,8 @@ ScriptAlias /enhance/reveal ###CONF_reveal; # legacy redirections Redirect permanent /pro/npb/npb.htm /enhance/npb.htm -Redirect permanent /pro/npb/403.htm /enhance/403.htm +Redirect permanent /pro/npb/403.htm /enhance/npb.htm Redirect permanent /pro/bluenh/bluenh.htm /enhance/bluenh.htm Redirect permanent /pro/nofading/nofading.htm /enhance/nofading.htm -Redirect permanent /pro/nofading/insertframe.htm /enhance/pal.htm -Redirect permanent /pro http://bicyclesonthemoon.info/git-projects/?p=ott/enhance& \ No newline at end of file +Redirect permanent /pro/insertframe/insertframe.htm /enhance/pal.htm +Redirect permanent /pro /enhance? \ No newline at end of file diff --git a/makefile b/makefile index 6fe3179..8ae88dc 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ # "makefile" is automatically generated from "makefile.1.mak" -# 04.12.2022 +# 05.12.2022 # # Copyright (C) 2022 Balthasar SzczepaÅski # @@ -108,25 +108,30 @@ npb_403.h\ nh.h\ nf.h\ rvl.h\ -df.h +df.h\ +mpb.h\ +mpb_503.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ -diff-cgi +diff-cgi\ +npb-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ -diff.htm +diff.htm\ +npb.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ -diff.1.htm +diff.1.htm\ +npb.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/makefile.1.mak b/makefile.1.mak index 914f0de..0736b7a 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -1,5 +1,5 @@ # "makefile" is automatically generated from "makefile.1.mak" -# 04.12.2022 +# 05.12.2022 # # Copyright (C) 2022 Balthasar SzczepaÅski # @@ -108,25 +108,30 @@ npb_403.h\ nh.h\ nf.h\ rvl.h\ -df.h +df.h\ +mpb.h\ +mpb_503.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ -diff-cgi +diff-cgi\ +npb-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ -diff.htm +diff.htm\ +npb.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ -diff.1.htm +diff.1.htm\ +npb.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/503.png b/mpb_503.png similarity index 100% rename from 503.png rename to mpb_503.png diff --git a/npb-cgi.c b/npb-cgi.c index d155c7a..27049dd 100644 --- a/npb-cgi.c +++ b/npb-cgi.c @@ -1,134 +1,181 @@ -// // //Download images and add - // // Newpixbots to them! (or Megans) - // // - // // Requires cgilib -// // //line 146 of cgi.h - // // must be changed - // // from "extern }" - // // to "}" -// // // - // // ~~bicyclesonthemoon +/* +npb-cgi.c +Download images and add Newpixbots to them! (or Megans) +05.12.2022 + +Copyright (C) 2013, 2014, 2022 Balthasar SzczepaÅski + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ -#include <cgi.h> #include <stdio.h> -#include <stdlib.h> +#include <stdint.h> #include <unistd.h> -#include <string.h> +#include <stdlib.h> #include <sys/wait.h> -#include <sys/stat.h> +#include <stdint.h> +#include <inttypes.h> -#define WGET_PATH "/usr/bin/wget" -#define NPB_PATH "./npb" -#define MEG_PATH "./403" -#define RM_PATH "/bin/rm" -#define LOG_PATH "/eizm/log/npb/npb.log" -#define LOG_PATH2 "/eizm/log/npb/403.log" -#define USERAGENT "NewpixbOTTification\x20(1190.bicyclesonthemoon.dnsd.info/npb/npb.htm)" -#define USERAGENT2 "403fication\x20(1190.bicyclesonthemoon.dnsd.info/npb/403.htm)" -#define MSTD_PATH "/pro/npb/mpb.png" -#define MSTD_PATH2 "/pro/npb/503.png" +#include <cgi.h> -int main (int argc, char *argv[]); -void mustard(int mustard); +#include "online-core.h" +#include "mpb.h" +#include "mpb_503.h" -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; -bool meg=false; + +int npb ( + char *inpix, char *outpix, + uint_fast8_t remove_border, uint_fast32_t remove_border_width, + uint_fast8_t new_border, uint_fast32_t new_border_width, + uint_fast8_t external_border, uint_fast32_t external_border_width, + uint_fast8_t corners, uint_fast8_t ong1, uint8_t t403 +); int main (int argc, char *argv[]) { - cgi=cgiInit(); + s_cgi *cgi; + char in_tmp[256]; + char out_tmp[256]; + char *in_path; + char *t; + uint_fast8_t remove_border, new_border, external_border, corners, ong1; + uint_fast32_t remove_border_width, new_border_width, external_border_width; + uint_fast8_t t403 = 0; - sprintf(path,"%s",(getenv("PATH_INFO")!=NULL)?(getenv("PATH_INFO")):""); - if(strcmp(path,"/403")==0) - { - meg=true; - //mustard(0); - } + int r=0; + int r1=0; + int r2=0; + int r3=0; - 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()); + do { + make_tmp_path(in_tmp, 256, 0, ""); + make_tmp_path(out_tmp, 256, 1, ".png"); + + cgi=cgiInit(); - //Why is there no spawnl() in linux? - sub=fork(); - if(sub==0) + r = get_file(cgi,"inpix2", in_tmp, &in_path); + if (r) + r = get_file(cgi,"inpix", in_tmp, &in_path); + if (r) + break; + + remove_border = (cgiGetValue(cgi, "r")!=NULL) ? 1 : 0; + external_border = (cgiGetValue(cgi, "e")!=NULL) ? 1 : 0; + new_border = (cgiGetValue(cgi, "b")!=NULL) ? 1 : 0; + corners = (cgiGetValue(cgi, "c")!=NULL) ? 1 : 0; + ong1 = (cgiGetValue(cgi, "o")!=NULL) ? 1 : 0; + t403 = (cgiGetValue(cgi, "4")!=NULL) ? 1 : 0; + + if (remove_border) { - t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",meg?USERAGENT2:USERAGENT,"-O",path,url,(char *)0); - exit(t); + t = cgiGetValue(cgi, "rw"); + if (t != NULL) + sscanf(t,"%"SCNuFAST32, &remove_border_width); + else + remove_border_width = 0; } - waitpid(sub,&t,0); - if(t)mustard(t); - } - - sub=fork(); - if(sub==0) - { - t=execl(meg?MEG_PATH:NPB_PATH,meg?MEG_PATH:NPB_PATH,path,path,"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) + + if (external_border) + { + t = cgiGetValue(cgi, "ew"); + if (t != NULL) + sscanf(t,"%"SCNuFAST32, &external_border_width); + else + external_border_width = 0; + } + + if (new_border) + { + t = cgiGetValue(cgi, "bw"); + if (t != NULL) + sscanf(t,"%"SCNuFAST32, &new_border_width); + else + new_border_width = 0; + } + + r = npb( + in_path, out_tmp, + remove_border, remove_border_width, + new_border, new_border_width, + external_border, external_border_width, + corners, ong1, t403 + ); + if (r) + break; + + r1 = send_file(out_tmp, "image/png", 0); + } while (0); + if (r) { - fread(buf,1,q,pix); - fwrite(buf,1,q,stdout); + r1 = send_data( + t403 ? mpb_503 : mpb, + t403 ? mpb_503_size : mpb_size, + "image/png", + 500 + ); } - fclose(pix); - fflush(stdout); - mustard(0);//no mustard + r2 = rm(in_tmp); + r3 = rm(out_tmp); + if (r) + return r; + if (r1) + return r1; + if (r2) + return r2; + if (r3) + return r3; + return 0; } -void mustard(int mustard) +int npb ( + char *inpix, char *outpix, + uint_fast8_t remove_border, uint_fast32_t remove_border_width, + uint_fast8_t new_border, uint_fast32_t new_border_width, + uint_fast8_t external_border, uint_fast32_t external_border_width, + uint_fast8_t corners, uint_fast8_t ong1, uint8_t t403 +) { - if(mustard) - { - cgiRedirect(meg?MSTD_PATH2: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(meg?LOG_PATH2:LOG_PATH,"at"); - if(pix!=NULL) + char s_rw[13] = "-0"; + char s_bw[13] = "-0"; + char s_ew[13] = "-0"; + + pid_t sub; + int r; + + if (remove_border) + snprintf(s_rw, 13, "-r%"PRIuFAST32, remove_border_width); + if (new_border) + snprintf(s_bw, 13, "-b%"PRIuFAST32, new_border_width); + if (external_border) + snprintf(s_ew, 13, "-e%"PRIuFAST32, external_border_width); + + sub = fork(); + if (sub == 0) { - fprintf(pix,"%x %s\n",mustard,url); - fclose(pix); + r = execl( + NPB_PATH, NPB_PATH, + s_rw, s_ew, s_bw, + corners ? "-c" : "-0", + ong1 ? "-o" : "-0", + t403 ? "-4" : "-0", + inpix, outpix, + (char *)0 + ); + exit(r); } - exit(mustard); -} \ No newline at end of file + waitpid(sub, &r, 0); + return r; +} diff --git a/npb.1.htm b/npb.1.htm index b27f9cd..c4f9e20 100644 --- a/npb.1.htm +++ b/npb.1.htm @@ -1,28 +1,28 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""> -<html lang="pl"> - <head> - <title>It's NewpixbOTTification time! • 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>It's NewpixbOTTification time!</h1> - <form method="post" action="/cgi/npb/npbd"> + <form method="post" action="/enhance/npb" enctype="multipart/form-data"> NewpixbOTTify by URL<br> URL of image: - <input type="text" name="inpix"> - <input type="submit" value="NewpixbOTTify!"> - </form> - <br> - <form method="post" action="/cgi/npb/npbd" enctype="multipart/form-data"> + <input class="pt" type="text" name="inpix2"> + <br> NewpixbOTTify by file upload<br> Upload the image: - <input type="file" name="inpix"> - <input type="submit" value="NewpixbOTTify!"> + <input class="pt" type="file" name="inpix"> + <br> + <input type="checkbox" class="pt" name="r"> remove original border, + width: <input class="pt" type="text" name="rw" size="2"> + <br> + <input type="checkbox" class="pt" name="b"> new border, + width: <input class="pt" type="text" name="bw" size="2"> + <br> + <input type="checkbox" class="pt" name="e"> external border, + width: <input class="pt" type="text" name="ew" size="2"> + <br> + <input type="checkbox" class="pt" name="c"> corners + <br> + <input type="checkbox" class="pt" name="o"> bOTTeriada Newpixbot + <br> + <input type="checkbox" class="pt" name="4"> Timeframe 403 + <br> + <br> + <input class="pt" 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> diff --git a/npb.c b/npb.c index 63bcb00..d315aff 100644 --- a/npb.c +++ b/npb.c @@ -1,7 +1,7 @@ /* npb.c Take a picture and add a newpixbot to it! -30.11.2022 +05.12.2022 Copyright (C) 2013 - 2015, 2022 Balthasar SzczepaÅski @@ -122,7 +122,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; - char short_options[] = "o4r:b:e:ch"; + char short_options[] = "o4r:b:e:ch0"; int opt; int r; @@ -227,6 +227,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) space_t = NPB0_T; space_b = NPB0_B; fill_white = 1; + override_new_border = 1; new_border = 0; npb_after = 1; fixed_frame = 1; @@ -240,6 +241,7 @@ int subtool_npb (int argc, char **argv, int argi, char **err) space_t = NPB1_T; space_b = NPB1_B; fill_white = 1; + override_new_border = 1; new_border = 0; npb_after = 1; fixed_frame = 1; @@ -568,8 +570,8 @@ int subtool_npb (int argc, char **argv, int argi, char **err) r = perform_action_1picture( 2, //id - fixed_frame ? space_l : x0_content_global, //x0 - fixed_frame ? space_t : y0_content_global, //y0 + fixed_frame ? space_l + external_border : x0_content_global, //x0 + fixed_frame ? space_t + external_border: y0_content_global, //y0 0, //f0 fixed_frame ? (space_r - space_l + 1) : width_content, //width fixed_frame ? (space_b - space_t + 1) : height_content, //height diff --git a/settings-release.txt b/settings-release.txt index eed7ff2..08fa7da 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -17,6 +17,7 @@ title_bluenh: ENHANCE! title_diff: See the difference! title_enhance: ENHANCE! title_nofading: No fading! +title_npb: It's NewpixbOTTification time! title_reveal: Reveal hidden detail! bin_path: /botm/bin/enhance diff --git a/settings.txt b/settings.txt index a2294a6..8b0c9cd 100644 --- a/settings.txt +++ b/settings.txt @@ -39,6 +39,7 @@ CONF_bin = $bin_path CONF_bluenh = $_bin_bluenh_cgi_path CONF_diff = $_bin_diff_cgi_path CONF_nofading = $_bin_nofading_cgi_path +CONF_npb = $_bin_npb_cgi_path CONF_reveal = $_bin_reveal_cgi_path