From 9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 10 Feb 2019 11:16:07 +0800 Subject: Initial commit. --- blog/content/.htaccess | 2 ++ blog/content/util/indexer.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 blog/content/.htaccess create mode 100644 blog/content/util/indexer.cpp (limited to 'blog/content') diff --git a/blog/content/.htaccess b/blog/content/.htaccess new file mode 100644 index 0000000..93169e4 --- /dev/null +++ b/blog/content/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all diff --git a/blog/content/util/indexer.cpp b/blog/content/util/indexer.cpp new file mode 100644 index 0000000..b072633 --- /dev/null +++ b/blog/content/util/indexer.cpp @@ -0,0 +1,48 @@ +//filename title date tags +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define stripr(s) s[strlen(s)-1]=='\n'?s[strlen(s)-1]=0:0 +std::vector fn; +char buf1[65536],buf2[65536],buf3[65536]; +int main() +{ + struct dirent* pd;DIR* pdir; + pdir=opendir("/var/www/html/blog/content"); + while((pd=readdir(pdir))!=NULL) + { + std::string s(pd->d_name); + if(s.length()<4)continue; + if(s.substr(s.length()-4)==".txt") + fn.push_back(s.substr(0,s.length()-4)); + } + closedir(pdir); + std::sort(fn.begin(),fn.end(),std::greater()); + FILE *f,*rf; + f=fopen("/var/www/html/blog/content/pindex","w"); + for(size_t i=0;itm_year+1900,mt->tm_mon+1,mt->tm_mday); + fprintf(f,"%s\n",buf3); + fclose(rf); + } + fclose(f); +} -- cgit v1.2.3