00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019 #include "defines.h"
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <ctype.h>
00025 #include <time.h>
00026 #include <sys/types.h>
00027
00028 #include "readline.h"
00029 #include "hashlib.h"
00030 #include "utils.h"
00031 #include "configparser.h"
00032 #include "cfcgi.h"
00033 #include "template.h"
00034 #include "clientlib.h"
00035
00036
00037 static int SetLinks = 0;
00038
00039 int flt_link_set_links_post(t_cf_hash *head,t_configuration *dc,t_configuration *vc,t_cl_thread *thread,t_cf_template *tpl) {
00040 u_char buff[256];
00041 size_t n;
00042
00043 if(SetLinks == 0) return FLT_DECLINE;
00044
00045 if(thread->threadmsg->prev) {
00046 n = snprintf(buff,256,"?t=%lld&m=%lld",thread->tid,thread->threadmsg->prev->mid);
00047 tpl_cf_setvar(tpl,"prev",buff,n,1);
00048 }
00049
00050 if(thread->threadmsg->next) {
00051 n = snprintf(buff,256,"?t=%lld&m=%lld",thread->tid,thread->threadmsg->next->mid);
00052 tpl_cf_setvar(tpl,"next",buff,n,1);
00053 }
00054
00055 n = snprintf(buff,256,"?t=%lld&m=%lld",thread->tid,thread->messages->mid);
00056 tpl_cf_setvar(tpl,"first",buff,n,1);
00057
00058 n = snprintf(buff,256,"?t=%lld&m=%lld",thread->tid,thread->last->mid);
00059 tpl_cf_setvar(tpl,"last",buff,n,1);
00060
00061 return FLT_OK;
00062 }
00063
00064 int flt_link_handle_conf(t_configfile *cfg,t_conf_opt *entry,u_char **args,int argnum) {
00065 if(argnum == 1) {
00066 SetLinks = cf_strcmp(args[0],"yes") == 0;
00067 }
00068 else {
00069 fprintf(stderr,"Error: expecting 1 argument for directive SetLinkTags!\n");
00070 return 1;
00071 }
00072
00073 return 0;
00074 }
00075
00076 t_conf_opt flt_link_config[] = {
00077 { "SetLinkTags", flt_link_handle_conf, NULL },
00078 { NULL, NULL, NULL }
00079 };
00080
00081 t_handler_config flt_link_handlers[] = {
00082 { POSTING_HANDLER, flt_link_set_links_post },
00083 { 0, NULL }
00084 };
00085
00086 t_module_config flt_link = {
00087 flt_link_config,
00088 flt_link_handlers,
00089 NULL,
00090 NULL,
00091 NULL,
00092 NULL
00093 };
00094
00095