From 9631f84cb335c9b2ca01f9ee1ba7a8d4d6858972 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 17 Feb 2024 20:58:22 -0500 Subject: Drop deprecated stuff in the blog directory. --- blog/sbs_2/cgi-src/get-post-content.cpp | 83 --------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 blog/sbs_2/cgi-src/get-post-content.cpp (limited to 'blog/sbs_2/cgi-src/get-post-content.cpp') diff --git a/blog/sbs_2/cgi-src/get-post-content.cpp b/blog/sbs_2/cgi-src/get-post-content.cpp deleted file mode 100644 index 62cd5d8..0000000 --- a/blog/sbs_2/cgi-src/get-post-content.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2017 Chris Xiong - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -/* - * Get content of a post - * query parameters: - * p=: post file name - * returned object: - * HTML fragment of the post - */ -#include -#include -#include -#include -#include -#include -#include -#include "cgiutils.hpp" -#define stripr(s) s[strlen(s)-1]=='\n'?s[strlen(s)-1]=0:0 -std::vector fn; -char buf[262144]; -size_t sz; -void encrypt() -{ - std::string b(buf,sz); - for(size_t p=b.find("",p); - std::string attrib=b.substr(p+11,tag_end-p-11); - DOMAttrib a(attrib); - std::string cont=b.substr(tag_end+1,b.find("",p)-tag_end-1); - unsigned hash=5381; - std::string key=a.getAttrib("key"); - a.eraseAttrib("key"); - for(size_t j=0;j(&cont[j]); - cont[j]^=key[j%key.length()]; - } - a.setAttrib("encont",base64_encode(cont)); - a.setAttrib("hash",std::to_string(hash)); - a.setAttrib("id","encrypted"+std::to_string(i)); - cont="Encrypted content here. Click here to decrypt."; - b.replace(p,b.find("",p)-p,""+cont); - p=b.find("",p); - } - memcpy(buf,b.c_str(),b.length());sz=b.length(); -} -int main(int argc,char** argv,char** envp) -{ - QueryStrParser a; - HTTPHeader h; - if(!a.exist("p")){h.setStatusCode(400);h.print();return 0;} - FILE* f=fopen(("/var/www/html/blog/content/"+a.value("p")+".txt").c_str(),"r"); - if(!f){h.setStatusCode(400);h.print();return 0;} - h.appendHeader("Content-type: text/plain; charset=utf-8"); - h.print(); - sz=fread(buf,sizeof(char),262144,f); - encrypt(); - fwrite(buf,sizeof(char),sz,stdout); - fclose(f); - return 0; -} -- cgit v1.2.3