wf.c File Reference

#include "cgi.h"

Include dependency graph for wf.c:

Go to the source code of this file.

Functions

char * JSShowPage (ScriptEnvironment *Env, char *cmd, int argc, char **argv, CGINameValue *Params)
char * JSTimeStamp (ScriptEnvironment *Env, char *cmd, int argc, char **argv, CGINameValue *Params)
char * JSSendMail (ScriptEnvironment *Env, char *cmd, int argc, char **argv, CGINameValue *Params)
int CGImain (char *argv0, CGINameValue *Params, EZSSTREAM *htmlout)
int WFmain (char *argv0, char *url, CGINameValue *Params, EZSSTREAM *htmlout)


Function Documentation

int CGImain char *  argv0,
CGINameValue Params,
EZSSTREAM htmlout
 

  • _PAGE stores the page currently being viewed
  • _PAGENEXT is a FIFO of the pages to go to. New pages are appended
  • _PAGEBACK is a LIFO for the "Previous" button. New pages are prepended

For both of these lists, the "current" value is taken from the beginning of the comma-delimited values.

Definition at line 63 of file wf.c.

References AdminInfo::argv0, Authenticate(), CGI_DEFAULT_HEADER, AdminInfo::Config, DeleteNVP(), Error(), ExpandLocalPath(), GetEnvironment(), GetFieldValue, AdminInfo::htmlout, Index(), Login(), MAXPATH, AdminInfo::Params, ReadINIFileSection(), SendCGIHeader(), SendImage(), SetFieldValue(), ShowAdmin(), ShowPage(), SLASH, strdup3(), stricmp(), stristr(), strnicmp(), UserList(), and WFmain().

00064 {
00065     char* url = GetEnvironment(htmlout,"PATH_INFO");
00066     if (!url) url = GetFieldValue(Params,"_page");
00067  return WFmain(argv0,url,Params,htmlout);
00068 }

char* JSSendMail ScriptEnvironment Env,
char *  cmd,
int  argc,
char **  argv,
CGINameValue Params
 

Definition at line 45 of file wf.c.

References ScriptEnvironment::config, GetSetting(), and SendMail().

00046 {
00047  if (!Env->config) return 0;
00048  if (argc < 3) return 0;
00049  {
00050    char* server   = GetSetting(Env->config,"EMAILSERVER","");
00051    char* profile  = GetSetting(Env->config,"EMAILPROFILE","Windows Messaging Settings");
00052    char* name     = GetSetting(Env->config,"EMAILNAME","");
00053    char* password = GetSetting(Env->config,"EMAILPWD","");
00054    SendMail(argv[0],argv[1],argv[2], server, profile, name, password);
00055  }
00056  return 0;
00057 }

char* JSShowPage ScriptEnvironment Env,
char *  cmd,
int  argc,
char **  argv,
CGINameValue Params
 

Definition at line 16 of file wf.c.

References CGIFREE, GetFieldValue, HasToken(), SetFieldValue(), and strdup3().

00017 {/* prepend the next page to the _PAGENEXT list */
00018  char* pageskip;
00019  if (argc < 1) return 0;
00020  pageskip = GetFieldValue(Params,"_PAGESKIP");
00021  if (*pageskip)
00022   {
00023    if (!HasToken(pageskip,argv[0],0))
00024     {
00025      char*x = strdup3(pageskip,",",argv[0]);
00026      SetFieldValue(Params,"_PAGESKIP",x);
00027      CGIFREE(x);
00028     }
00029   }
00030  else
00031   {
00032    SetFieldValue(Params,"_PAGESKIP",argv[0]);
00033   }
00034  return 0;
00035 }

char* JSTimeStamp ScriptEnvironment Env,
char *  cmd,
int  argc,
char **  argv,
CGINameValue Params
 

Definition at line 37 of file wf.c.

References GetTime(), and strdup().

Referenced by CGImain(), ODBCRunScript(), RunReportF(), ValidateBack(), ValidatePage(), and WFmain().

00038 {
00039     char datetime[32];
00040     GetTime(datetime,datetime+8,0);
00041     return strdup(datetime);
00042 }

int WFmain char *  argv0,
char *  url,
CGINameValue Params,
EZSSTREAM htmlout
 

Definition at line 69 of file wf.c.

References CGIFCLOSE, DeleteNVP(), ExpandLocalPath(), FileOpen(), HTMLWrite(), HTMLWriteFileF(), JSEval(), JSHasRecord(), JSHTMLEscape(), JSIndexOf(), JSPrint(), JSRandom(), JSReport(), JSSendMail(), JSstrlen(), JSsubstr(), JSTimeStamp(), JStoFixed(), JSToNumber(), MAXPATH, NULL, ReadINIFileSection(), RunReport(), RunScript(), SendCGIHeader(), and stristr().

Referenced by CGImain().

00070 {
00071 #endif
00072  ScriptFunction Functions[] =
00073  {
00074   {"print",10,(ScriptFunctionCall)*JSPrint},
00075   {"write",10,(ScriptFunctionCall)*JSPrint},
00076   {"eval",1,(ScriptFunctionCall)*JSEval},
00077   {"timestamp",0,(ScriptFunctionCall)*JSTimeStamp},
00078   {"toFixed",2,(ScriptFunctionCall)*JStoFixed},
00079   {"sendMail",3,(ScriptFunctionCall)*JSSendMail},
00080   {"escape",1,(ScriptFunctionCall)*JSHTMLEscape},
00081   {"hasRecord",1,(ScriptFunctionCall)*JSHasRecord},
00082   {"runReport",8,(ScriptFunctionCall)*JSReport},
00083   {"number",1,(ScriptFunctionCall)*JSToNumber},
00084   {"toNumber",1,(ScriptFunctionCall)*JSToNumber},
00085   {"random",1,(ScriptFunctionCall)*JSRandom},
00086         {"subStr",3,(ScriptFunctionCall)*JSsubstr},
00087       {"indexOf",4,(ScriptFunctionCall)*JSIndexOf},
00088       {"length",1,(ScriptFunctionCall)*JSstrlen},
00089 {0,0,0}};
00090 
00091  CGINameValue* config = NULL;
00092 
00093  FILE* f = NULL;
00094 
00095  if (url)
00096  {
00097   if (!url[0]) url = "index.html";
00098   if (strstr(url,"..")) return 101;
00099   if (url[0] == '/') return 101;
00100   if (strchr(url,'|')) return 101;
00101   if (strchr(url,'\\')) return 101;
00102   if (strchr(url,'>')) return 101;
00103   if (strchr(url,'<')) return 101;
00104   f = FileOpen(argv0,url,0);
00105  }
00106 
00107  if (f)
00108     {
00109         if (stristr(url,".html") || stristr(url,".jsp"))
00110         {
00111             SendCGIHeader(htmlout,NULL);
00112             RunReport(argv0,htmlout,f,Params,NULL,NULL,0,0);
00113             CGIFCLOSE(f);
00114             return 0;
00115         }
00116         if (stristr(url,".js"))
00117         {
00118          ScriptEnvironment Global;
00119          char fn[MAXPATH];
00120           ExpandLocalPath(argv0,fn,"cgi",".ini");
00121          config = ReadINIFileSection(fn,"server",0);
00122 
00123          memset(&Global,0,sizeof(Global));
00124          Global.htmlout   = htmlout;
00125          Global.Functions = Functions;
00126          Global.argv0     = argv0;
00127          Global.config    = config;
00128 
00129             SendCGIHeader(htmlout,NULL);
00130             RunScript(&Global,f,Params);
00131          if (config) DeleteNVP(config);
00132             CGIFCLOSE(f);
00133             return 0;
00134         }
00135         if (stristr(url,".gif"))
00136         {
00137             SendCGIHeader(htmlout,"Content-type: image/gif\n\n");
00138         }
00139         else if (stristr(url,".jpg"))
00140         {
00141             SendCGIHeader(htmlout,"Content-type: image/jpeg\n\n");
00142         }
00143         else if (stristr(url,".pdf"))
00144         {
00145             SendCGIHeader(htmlout,"Content-type: application/pdf\n\n");
00146         }
00147         HTMLWriteFileF(htmlout,f);
00148         CGIFCLOSE(f);
00149       return 0;
00150     }
00151 
00152  HTMLWrite(htmlout,"<P>usage: wf.cgi?_page=index.html\n"
00153    "<HR>Workflow automation &copy; 2003 by Raosoft, Inc. All Rights Reserved.");
00154 
00155  return 0;
00156 }



Raosoft, Inc.
Raosoft EZReport, EZSurvey, InterForm, RapidReport, Raosoft, and SurveyWin are registered trademarks of Raosoft, Inc. Page contents © 1996-2007 by Raosoft, Inc. You may use and modify this file for your own use, but may not distribute it or derivative works without the prior written consent of Raosoft, Inc. This software is provided "as is," and Raosoft makes no warranty, express or implied, of fitness for a particular application. Every measure has been taken to anticipate risks inherent to computer networks, but we cannot guarantee safety or reliability of this program in every situation.
Tel: 206-525-4025 (US) Email: raosoft@raosoft.com
http://www.raosoft.com/