1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/*
** 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
#include <time.h>
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#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("&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"));
}
|