Difference between revisions of "Lesson 7"

From VistApedia
Jump to: navigation, search
Line 23: Line 23:
 
You need to make sure that the HREF file, in my case "library7.cgi" is the cgi file that you have set to call this routine.  It is actually designed to recall itself to produce the tables.
 
You need to make sure that the HREF file, in my case "library7.cgi" is the cgi file that you have set to call this routine.  It is actually designed to recall itself to produce the tables.
  
+
IMPORTANT NOTICE: ALL OF THE '<' CHARACTERS HAVE BEEN REPLACED BY the HTML entity CHARACTERS ie: & lt ; BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '>' characters WERE CHANGED TO & rt ; . You can cut and paste from the rendered page, but you will have to Replace these back to the proper '<' and '>' characters when cutting and pasting from the edit-page.
 
 
IMPORTANT NOTICE: ALL OF THE '{' CHARACTERS HAVE BEEN REPLACED BY '{' CHARACTERS BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '}' WERE CHANGED TO '}'. Replace these back to the proper '{' and '}' characters when typing into your system.
 
 
  
 +
<pre>
 
  ZZLIB7
 
  ZZLIB7
 
   
 
   
Line 36: Line 34:
 
     ;
 
     ;
 
     W "Content-type: text/html",!!
 
     W "Content-type: text/html",!!
     W "{html}",!
+
     W "&lt;html&gt;",!
     W "{head}",!
+
     W "&lt;head&gt;",!
     W "{title}ZZLIB3 GLOBAL LISTS.{/title}",!
+
     W "&lt;title&gt;ZZLIB3 GLOBAL LISTS.&lt;/title&gt;",!
     W "{/head}",!
+
     W "&lt;/head&gt;",!
     W "{body}",!
+
     W "&lt;body&gt;",!
 
     ;
 
     ;
 
     S XX=$ZTRNLNM("QUERY_STRING")
 
     S XX=$ZTRNLNM("QUERY_STRING")
 
     ;
 
     ;
     W "{A HREF=""library7.cgi?TB1""}Sort by Index Number{/A}{BR}"
+
     W "&lt;A HREF=""library7.cgi?TB1""&gt;Sort by Index Number&lt;/A&gt;&lt;BR&gt;"
     W "{A HREF=""library7.cgi?TB2""}Sort by Last Name{/A}{BR}"
+
     W "&lt;A HREF=""library7.cgi?TB2""&gt;Sort by Last Name&lt;/A&gt;&lt;BR&gt;"
     W "{A HREF=""library7.cgi?TB3""}Sort by First Name{/A}{BR}"
+
     W "&lt;A HREF=""library7.cgi?TB3""&gt;Sort by First Name&lt;/A&gt;&lt;BR&gt;"
 
     ;         
 
     ;         
 
     I XX="TB1" D TB1
 
     I XX="TB1" D TB1
Line 52: Line 50:
 
     I XX="TB3" D TB3
 
     I XX="TB3" D TB3
 
     ;
 
     ;
     W "{/body}",!
+
     W "&lt;/body&gt;",!
     W "{/html}",!
+
     W "&lt;/html&gt;",!
 
     ;
 
     ;
 
     Q
 
     Q
 
     ;
 
     ;
  TB1 W "{P}",!
+
  TB1 W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1=0
 
     S ZS1=0
 
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
 
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
 
     .S ZD1=^ZZLIB3(ZS1)
 
     .S ZD1=^ZZLIB3(ZS1)
     .W "{TR}",!
+
     .W "&lt;TR&gt;",!
     .W "{TD}",ZS1,"{/TD}","{TD}",$P(ZD1,"^",2),"{/TD}"
+
     .W "&lt;TD&gt;",ZS1,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD1,"^",2),"&lt;/TD&gt;"
     .W "{TD}",$P(ZD1,"^",1),"{/TD}",!
+
     .W "&lt;TD&gt;",$P(ZD1,"^",1),"&lt;/TD&gt;",!
     .W "{/TR}",!
+
     .W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
 
     ;
 
     ;
  TB2 W "{P}",!
+
  TB2 W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1="B"
 
     S ZS1="B"
 
     S ZS2=""
 
     S ZS2=""
Line 86: Line 84:
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ...S ZD4=^ZZLIB3(ZS4)
 
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "{TR}",!
+
     ...W "&lt;TR&gt;",!
     ...W "{TD}",ZS4,"{/TD}","{TD}",$P(ZD4,"^",2),"{/TD}"
+
     ...W "&lt;TD&gt;",ZS4,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD4,"^",2),"&lt;/TD&gt;"
     ...W "{TD}",$P(ZD4,"^",1),"{/TD}",!
+
     ...W "&lt;TD&gt;",$P(ZD4,"^",1),"&lt;/TD&gt;",!
     ...W "{/TR}",!
+
     ...W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
 
  TB3  ;
 
  TB3  ;
     W "{P}",!
+
     W "&lt;P&gt;",!
     W "{TABLE BORDER=1}",!
+
     W "&lt;TABLE BORDER=1&gt;",!
     W "{TR}",!
+
     W "&lt;TR&gt;",!
     W "{TH}INDEX{/TH}{TH}FIRST NAME{/TH}{TH}LAST NAME{/TH}",!
+
     W "&lt;TH&gt;INDEX&lt;/TH&gt;&lt;TH&gt;FIRST NAME&lt;/TH&gt;&lt;TH&gt;LAST NAME&lt;/TH&gt;",!
     W "{/TR}",!
+
     W "&lt;/TR&gt;",!
 
     S ZS1="C"
 
     S ZS1="C"
 
     S ZS2=""
 
     S ZS2=""
Line 107: Line 105:
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
 
     ...S ZD4=^ZZLIB3(ZS4)
 
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "{TR}",!
+
     ...W "&lt;TR&gt;",!
     ...W "{TD}",ZS4,"{/TD}","{TD}",$P(ZD4,"^",2),"{/TD}"
+
     ...W "&lt;TD&gt;",ZS4,"&lt;/TD&gt;","&lt;TD&gt;",$P(ZD4,"^",2),"&lt;/TD&gt;"
     ...W "{TD}",$P(ZD4,"^",1),"{/TD}",!
+
     ...W "&lt;TD&gt;",$P(ZD4,"^",1),"&lt;/TD&gt;",!
     ...W "{/TR}",!
+
     ...W "&lt;/TR&gt;",!
     W "{/TABLE}",!
+
     W "&lt;/TABLE&gt;",!
     W "{/P}",!
+
     W "&lt;/P&gt;",!
 
     Q
 
     Q
 +
 +
</pre>
  
 
  Tutorial Home: [[M Web Tutorials]]
 
  Tutorial Home: [[M Web Tutorials]]
 
  Prev: [[Lesson 6]]
 
  Prev: [[Lesson 6]]
 
  Next: [[Lesson 8]]
 
  Next: [[Lesson 8]]

Revision as of 18:59, 10 October 2006

Linux / Apache / GT.M / Web Application Lesson 7 - B Corrected for Security.

Tutorial Home: M Web Tutorials
Prev: Lesson 6
Next: Lesson 8

In the following routine we make use of functions and add hypertext links. We also use the special function supplied with GT.M called $ZTRNLNM and use it to examine a environment variable called QUERY_STRING.

Many times when you are surfing the web, you may see a http address followed by a question mark "?", and then a bunch of information. This bunch of information can come from a form that you filled out or that was hidden on the page that you were previously on.

In the UNIX / Linux world the information that is past the question mark "?" is placed in the environment variable QUERY_STRING.

In our mumps routine we use the special function $ZTRNLNM to give us the value that is in the environment variable QUERY_STRING. You will notice in our hyperlinks that we have placed our routine function tags after the question mark "?" for our three methods of displaying the data in our ^ZZLIB3 global.

Depending on which hyperlink you select the environment variable QUERY_STRING will contain "TB1", "TB2", or "TB3".

The $ZTRNLNM function will use this value to set XX equal to "TB1", "TB2", or "TB3".

The I(f) command tests the value of XX. If the test XX="TB1" is true then the rest of the line is executed. If the test XX="TB1" is false execution of this line in discontinued and execution moves to the next line.

If someone tries to run this script/routine with anything other then TB1, TB2, or TB3, nothing happens.

You need to make sure that the HREF file, in my case "library7.cgi" is the cgi file that you have set to call this routine. It is actually designed to recall itself to produce the tables.

IMPORTANT NOTICE: ALL OF THE '<' CHARACTERS HAVE BEEN REPLACED BY the HTML entity CHARACTERS ie: & lt ; BECAUSE THE WIKI WAS NOT FORMATTING PROPERLY OTHERWISE. LIKEWISE, ALL THE '>' characters WERE CHANGED TO & rt ; . You can cut and paste from the rendered page, but you will have to Replace these back to the proper '<' and '>' characters when cutting and pasting from the edit-page.

 ZZLIB7
 
 -------------------------------------------------------------------------------
 
 ZZLIB7    ; ROUTINE TO CREATE A WEB PAGE USING THE ^ZZLIB3 GLOBAL.
     ;
     ;
     W "Content-type: text/html",!!
     W "<html>",!
     W "<head>",!
     W "<title>ZZLIB3 GLOBAL LISTS.</title>",!
     W "</head>",!
     W "<body>",!
     ;
     S XX=$ZTRNLNM("QUERY_STRING")
     ;
     W "<A HREF=""library7.cgi?TB1"">Sort by Index Number</A><BR>"
     W "<A HREF=""library7.cgi?TB2"">Sort by Last Name</A><BR>"
     W "<A HREF=""library7.cgi?TB3"">Sort by First Name</A><BR>"
     ;        
     I XX="TB1" D TB1
     I XX="TB2" D TB2
     I XX="TB3" D TB3
     ;
     W "</body>",!
     W "</html>",!
     ;
     Q
     ;
 TB1 W "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1=0
     F  S ZS1=$O(^ZZLIB3(ZS1)) Q:+ZS1=0  D
     .S ZD1=^ZZLIB3(ZS1)
     .W "<TR>",!
     .W "<TD>",ZS1,"</TD>","<TD>",$P(ZD1,"^",2),"</TD>"
     .W "<TD>",$P(ZD1,"^",1),"</TD>",!
     .W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q
     ;
 TB2 W "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1="B"
     S ZS2=""
     F  S ZS2=$O(^ZZLIB3(ZS1,ZS2)) Q:ZS2=""  D
     .S ZS3=""
     .F  S ZS3=$O(^ZZLIB3(ZS1,ZS2,ZS3)) Q:ZS3=""  D
     ..S ZS4=""
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "<TR>",!
     ...W "<TD>",ZS4,"</TD>","<TD>",$P(ZD4,"^",2),"</TD>"
     ...W "<TD>",$P(ZD4,"^",1),"</TD>",!
     ...W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q
 TB3  ;
     W "<P>",!
     W "<TABLE BORDER=1>",!
     W "<TR>",!
     W "<TH>INDEX</TH><TH>FIRST NAME</TH><TH>LAST NAME</TH>",!
     W "</TR>",!
     S ZS1="C"
     S ZS2=""
     F  S ZS2=$O(^ZZLIB3(ZS1,ZS2)) Q:ZS2=""  D
     .S ZS3=""
     .F  S ZS3=$O(^ZZLIB3(ZS1,ZS2,ZS3)) Q:ZS3=""  D
     ..S ZS4=""
     ..F  S ZS4=$O(^ZZLIB3(ZS1,ZS2,ZS3,ZS4)) Q:ZS4=""  D
     ...S ZD4=^ZZLIB3(ZS4)
     ...W "<TR>",!
     ...W "<TD>",ZS4,"</TD>","<TD>",$P(ZD4,"^",2),"</TD>"
     ...W "<TD>",$P(ZD4,"^",1),"</TD>",!
     ...W "</TR>",!
     W "</TABLE>",!
     W "</P>",!
     Q

Tutorial Home: M Web Tutorials
Prev: Lesson 6
Next: Lesson 8