summaryrefslogtreecommitdiffstats
path: root/sqwebmail/token.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /sqwebmail/token.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'sqwebmail/token.c')
-rw-r--r--sqwebmail/token.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/sqwebmail/token.c b/sqwebmail/token.c
new file mode 100644
index 0000000..ad8acfb
--- /dev/null
+++ b/sqwebmail/token.c
@@ -0,0 +1,64 @@
+/*
+** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
+** distribution information.
+*/
+
+
+/*
+*/
+#include "sqwebmail.h"
+#include "config.h"
+#include "token.h"
+#include "sqconfig.h"
+#include "cgi/cgi.h"
+#include <stdio.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
+void tokennew()
+{
+time_t t;
+
+ time(&t);
+ printf("<input type=\"hidden\" name=\"msgtoken\" value=\"%ld-%ld\" />",
+ (long)t, (long)getpid());
+}
+
+void tokennewget()
+{
+time_t t;
+
+ time(&t);
+ printf("&amp;msgtoken=%ld-%ld", (long)t, (long)getpid());
+}
+
+int tokencheck()
+{
+const char *token=cgi("msgtoken");
+const char *savedtoken;
+
+ if (!token || token[0] == '\0')
+ return(0);
+ savedtoken=read_sqconfig(".", TOKENFILE, 0);
+ if (savedtoken && strcmp(token, savedtoken) == 0)
+ return (-1);
+ return (0);
+}
+
+void tokensave()
+{
+ write_sqconfig(".", TOKENFILE, cgi("msgtoken"));
+}
+