00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "config.h"
00022 #include "defines.h"
00023
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <ctype.h>
00027 #include <string.h>
00028 #include <sys/types.h>
00029
00030 #include <time.h>
00031
00032 #include "readline.h"
00033 #include "hashlib.h"
00034 #include "utils.h"
00035 #include "configparser.h"
00036 #include "cfcgi.h"
00037 #include "template.h"
00038 #include "clientlib.h"
00039 #include "fo_post.h"
00040
00041
00042
00043 PRIVATE int printer(const char * fmt, va_list pArgs) {
00044 }
00045
00046 PRIVATE int tracer(const char * fmt, va_list pArgs) {
00047 }
00048
00049 PRIVATE int terminate_handler(HTRequest *request, HTResponse *response, void *param, int status) {
00050
00051 HTEventList_stopLoop ();
00052
00053
00054 return HT_ERROR;
00055 }
00056
00057 u_char *get_url(const u_char *url) {
00058 u_char *cwd,*absolute_url;
00059 HTRequest* request = HTRequest_new();
00060 HTChunk* chunk = NULL;
00061 u_char *string = NULL;
00062
00063
00064 HTProfile_newPreemptiveClient("ClassicForum", "2.0");
00065
00066
00067 HTPrint_setCallback(printer);
00068 HTTrace_setCallback(tracer);
00069
00070
00071 HTRequest_setOutputFormat(request, WWW_RAW);
00072
00073
00074 HTRequest_addConnection(request, "close", "");
00075
00076
00077 HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);
00078
00079 cwd = HTGetCurrentDirectoryURL();
00080 absolute_url = HTParse(url, cwd, PARSE_ALL);
00081 chunk = HTLoadToChunk(absolute_url, request);
00082
00083 HT_FREE(absolute_url);
00084 HT_FREE(cwd);
00085
00086
00087 if (chunk) {
00088
00089 HTEventList_loop(request);
00090
00091
00092 string = HTChunk_toCString(chunk);
00093 }
00094
00095
00096 HTRequest_delete(request);
00097
00098
00099 HTProfile_delete();
00100
00101 return string;
00102 }
00103
00104
00105
00106 int flt_remotesignature_execute(t_cf_hash *head,t_configuration *dc,t_configuration *pc,t_message *p,int sock,int mode) {
00107 u_char *rs = strstr("[remote-signature:",p->content),*end,*url,*cnt;
00108 register u_char *ptr;
00109 t_string str;
00110
00111 if(rs) {
00112 for(ptr=rs+18;*ptr && ptr != ']' && !isspace(*ptr);ptr++);
00113
00114 if(*ptr == ']') {
00115 url = strndup(rs+18,end-ptr-18);
00116
00117
00118 if(is_valid_http_link(url,1) == 0) {
00119
00120 if((cnt = get_content(url)) != NULL) {
00121 str_init(&str);
00122 str_chars_set(&str,p->content,ptr-p->content);
00123 str_chars_append(&str,cnt,strlen(cnt));
00124 str_chars_append(&str,end,strlen(end));
00125 free(cnt);
00126 }
00127 }
00128
00129 free(url);
00130 }
00131 }
00132
00133 return FLT_DECLINE;
00134 }
00135
00136 t_conf_opt flt_remotesignature_config[] = {
00137 { NULL, NULL, NULL }
00138 };
00139
00140 t_handler_config flt_remotesignature_handlers[] = {
00141 { NEW_POST_HANDLER, flt_remotesignature_execute },
00142 { 0, NULL }
00143 };
00144
00145 t_module_config flt_remotesignature = {
00146 flt_remotesignature_config,
00147 flt_remotesignature_handlers,
00148 NULL,
00149 NULL,
00150 NULL,
00151 NULL
00152 };
00153
00154