/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ /* This is used to display public content. No authentication, no cookies. no security, beside using the public_* API. The page always requires the image variable to return something useful. The webssl rewriterule transforms /public/user/content into public.hc?image=user/content */ #include #include #include #include #include #include "../bolixo.h" #include "../bolixo.m" #include #include #include "util.h" #include "../instrument.h" #include "../proto/bod_client.protoch" static W_SSTRING w_image ("image"); extern "C" void tlmp_initmod() { translat_load ("bolixo"); } static void webmain_real() { glocal string document; glocal string user; glocal CONNECT_INFO con; glocal.con.port = "/dev/bod.sock"; glocal.con.secret = util_readsecret(); ("/etc/bolixonode.conf",true); if (strncmp(line,"node=",5)==0){ util_setnodeurl(line+5); } return 0; const char *pt = w_image.c_str(); if (*pt == '/') pt++; const char *ptuser = pt; pt = strchr(pt,'/'); bool image = true; if (pt == NULL){ glocal.user = ptuser; image = false; }else if (strstr(pt,".html")!=NULL){ glocal.user = string (ptuser,pt-ptuser); glocal.document = pt+1; image = false; } if (!image){ glocal bool exist = false; glocal bool pubdir = false; glocal string website; glocal string interest; (glocal.con,glocal.user); glocal.exist = exist; glocal.pubdir = pubdir; glocal.website = website; glocal.interest = interest; if (!glocal.exist){ tlmpweb_title (glocal.user.c_str()); util_defstyles(); DIV f; f.dispflex().flowcol().print(); DIV o; o.flexfixe().print(); { DIV dd; dd.sfloat("right").print(); /- } o.flexfixe().print(); DIV d; d.borderradius(5).border(1,"black").marginauto().w(50).paddings(20,20).vpaddings(20,20).vmargins(50,0).print(); /-
htmlprintf (MSG_U(E_NOPUBLICPAGE,"No public page for user %s"),glocal.user.c_str()); /-

/-#I_CHECKBOLIXODIR You may want to do a search on the /- /-#I_DIRECTORY Bolixo.org directory /- }else{ webtable_ctrloutput(); (); (); glocal vector *msgs = &msgs; glocal int ret = -1; (glocal.con,glocal.user,offset,nb); if (success){ glocal.ret = 0; glocal.msgs->clear(); for (auto &m:messages) glocal.msgs->push_back(m); } return glocal.ret; glocal int ret = -1; glocal vector *files = &files; (glocal.con,glocal.user,string_f("/project%s",path.ptr),offset,nb); if (success){ glocal.ret = 0; glocal.files->clear(); for (auto &f:files) glocal.files->push_back(f); } return glocal.ret; glocal int ret = -1; glocal BOB_TYPE *content = &content; (glocal.con,glocal.user,string_f("/project/%s",path.ptr),0); if (success){ glocal.ret = 0; *glocal.content = content; } return glocal.ret; string tmp = util_flipspaces(modified.ptr); const char *modified_ptr = tmp.c_str(); if (is_image){ const char *slash = name.ptr[0] == '/' ? "" : "/"; return string_f("/public/%s/project%s%s?mod=%s",glocal.user.c_str(),slash,name.ptr,modified_ptr); }else{ return string_f("/public/%s?file=%s&mod=%s",glocal.user.c_str(),name.ptr,modified_ptr); } return string_f("/public/%s/msg/%s?mod=%s",glocal.user.c_str(),name.ptr,modified.ptr); ("/etc/bolixonode.conf",true); //if (strncmp(line,"node=",5)==0) nodename = line+5; if (strncmp(line,"dirserver=",10)==0) util_setdirserver(line+10); //if (strncmp(line,"org=",4)==0) org = line+4; return 0; tlmpweb_title (glocal.user.c_str()); //tlmpweb_setbaseurl(string_f("/Public/%s",glocal.user.c_str())); util_defstyles(); function Popup(url,width,height,href) { window.open(url,"noname",'width=' + width + ',height=' + height + ',menubar=no,status=no,titlebar=no,scrollbars=yes'); } ?> tlmpweb_body ("white",NULL); // These DIV are there so the layout is properly computed by the javascript fixsize (created by util_endscript()) DIV dm("","main"); dm.w(100).print(); DIV dh("","head"); dh.print(); dh.end(); DIV db("tabs","body"); db.w(100).print(); FORM_HIDDEN t(w_image); public_display (*this,glocal.con,glocal.user,glocal.pubdir,glocal.website,glocal.interest); if (util_sendpublicfile(glocal.con,name)==-1){ tlmpweb_httpnotfound(); } util_endscript(string_f("image=%s",glocal.user.c_str())); } }else{ if (util_sendpublicfile(glocal.con,w_image.c_str())==-1){ tlmpweb_httpnotfound(); } } } extern "C" void webmain() { long long start = fdpass_getnow(); ("unix:","/tmp/stop.sock",1); webmain_real(); end=true; webmain_real(); long long end = fdpass_getnow(); glocal long long diff = end - start; ("/tmp/public-duration",true); fprintf (fout,"%s?%s: %Ld.%06Ld\n" ,tlmpweb_curpage(),getenv ("QUERY_STRING") ,glocal.diff/1000000,glocal.diff%1000000); return 0; }