home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / publish / admin / regpage2.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  3.1 KB  |  109 lines

  1. <CFSET Error = 0>
  2.  
  3. <!--- Check if the string contains any invalid characters --->
  4. <CFIF FindOneOf(':*?<>|"\ ', Path) NEQ 0>
  5.     <CFSET Error = 1>
  6.     <CFSET ErrorMessage = "The filename/path cannot contain any of the following characters:<BR>
  7. : * ? < > | " / (space)">
  8.  
  9. <!--- Check if the file has a .cfm extension --->
  10. <CFELSEIF Right(Form.Path, 4) NEQ ".cfm">
  11.     <CFSET Error = 1>
  12.     <CFSET ErrorMessage = "The file must have a .cfm extension!">
  13. </CFIF>
  14.  
  15. <!--- Separate directory from path --->
  16. <CFIF Path CONTAINS "/">
  17.     <CFSET Temp = Find("/", Reverse(Path))>
  18.     <CFSET Filename = Right(Path, Temp - 1)>
  19. <CFELSE>
  20.     <CFSET Filename = Path>
  21. </CFIF>
  22.  
  23. <!--- Check if the filename is long enough --->
  24. <CFIF Len(Filename) LTE 4 OR Left(Path, 2) IS "..">
  25.     <CFSET Error = 1>
  26.     <CFSET ErrorMessage = "The filename was invalid!">
  27. </CFIF>
  28.  
  29. <!--- Check if the file already exists in the database --->
  30. <CFQUERY DATASOURCE="CFexamples" NAME="FindDupe">
  31. SELECT * FROM PubPages
  32. WHERE TemplatePath = '#Path#'
  33. </CFQUERY>
  34. <CFIF FindDupe.RecordCount GT 0>
  35.     <CFSET Error = 1>
  36.     <CFSET ErrorMessage = "That file is already registered.">
  37. </CFIF>
  38.  
  39. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  40.  
  41. <HTML>
  42. <HEAD>
  43.     <TITLE>Register Page</TITLE>
  44. <STYLE TYPE="text/css">
  45. <!-- A {text-decoration: none} -->
  46. </STYLE>
  47. </HEAD>
  48.  
  49. <BODY BGCOLOR="#660000" TEXT="#FFFFFF" LINK="#FFFF00" VLINK="#FFFF00">
  50.  
  51. <TABLE ALIGN="RIGHT" CELLPADDING="0" CELLSPACING="0">
  52. <TR>
  53.     <TD ALIGN="RIGHT">
  54.     <FONT FACE="MS Sans Serif, Helvetica" SIZE="-2">
  55.         <A HREF="index.cfm">Administrator Home</A>
  56.     </FONT>
  57.     </TD>
  58. </TR>
  59. </TABLE>
  60.  
  61. <P><IMG SRC="images/registerpage.gif" WIDTH=120 HEIGHT=24 BORDER=0></P>
  62.  
  63. <CFIF Error IS 1>
  64.  
  65.     <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1"><B>Error:</B> <CFOUTPUT>#ErrorMessage#</CFOUTPUT></FONT></P>
  66.  
  67.     <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1">Please try again...</FONT></P>
  68.  
  69.     <FORM ACTION="regpage2.cfm">
  70.  
  71.     <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1"><B>Template Name</B> (relative to <CFOUTPUT>#ExpandPath("../")#</CFOUTPUT>)</FONT><BR>
  72.     <INPUT TYPE="TEXT" NAME="Path"></P>
  73.  
  74.     <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1"><B>No. of locations</B></FONT><BR>
  75.     <INPUT TYPE="TEXT" NAME="Locations" SIZE="3" MAXLENGTH="3" VALUE="1"></P>
  76.  
  77.     <P><INPUT TYPE="SUBMIT" VALUE="Continue"></P>
  78.  
  79.     </FORM>
  80.  
  81. <CFELSE>
  82.  
  83.     <CFTRANSACTION>
  84.  
  85.         <CFQUERY DATASOURCE="CFexamples" NAME="GetTopPageID">
  86.         SELECT Max(PageID) AS MaxID FROM PubPages
  87.         </CFQUERY>
  88.     
  89.         <CFIF GetTopPageID.MaxID IS "">
  90.             <CFSET NewPageID = 1>
  91.         <CFELSE>
  92.             <CFSET NewPageID = GetTopPageID.MaxID + 1>
  93.         </CFIF>
  94.  
  95.         <CFQUERY DATASOURCE="CFexamples">
  96.         INSERT INTO PubPages (PageID, TemplatePath, MaxLocation)
  97.         VALUES (#NewPageID#, '#Path#', #Locations#)
  98.         </CFQUERY>
  99.  
  100.     </CFTRANSACTION>
  101.  
  102.        <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1">Page created successfully! You can now schedule objects to appear on <CFOUTPUT>#Path#</CFOUTPUT>.</FONT></P>
  103.  
  104.     <P><FONT FACE="MS Sans Serif, Helvetica" SIZE="-1"><A HREF="index.cfm">Go back</A></FONT></P>
  105.  
  106. </CFIF>
  107.  
  108. </BODY>
  109. </HTML>