Revolution for CGI Scripts
Mark Guzdial
guzdial at cc.gatech.edu
Fri Apr 5 09:48:02 EST 2002
WOW! I was hoping for a pointer -- what I got was a whole tutorial!
THANK YOU!
Mark
On Monday, April 1, 2002, at 03:30 PM, Sivakatirswami wrote:
> on 4/1/02 7:01 AM, Mark Guzdial wrote:
>
>> How does one get started exploring Revolution for CGI Scripts?
> It's great you will love it... forget PERL.
>
>> I don't
>> see anything in the built-in documentation nor anything on the website.
> Yes, no documentation released: Here's the quick version.. assumes you
> have
> web space on a remote host in a virtual domain (i.e. your ISP/web
> host...)
>
> 1) get a UNIX friend to download and un tar the engine (you might have
> to
> get the engine from the Metacard site) you need for the platform you
> will be
> one... Solaris or whatever..have them FTP that to you using binary
> transfer... ( in my case, to our site and then I download to my Mac...
> be
> sure to use binary transfer)
>
> 2) Now, upload that engine to your cgi-bin on the site, set permissions
> to
> CHMOD 755... then take a look in your web master error logs and you
> will see
> the path that the server uses to point to files in your public_html
> directory. This may vary from server to server
>
> 3) then you put scripts on the site, in your CGI bin like this:
>
> #!/export/vhost/org/g/greatsite/www/public_html/cgi-bin/mc
>
> --where the above is the path to files in your home/public_html
> --and simply points to the MC engine you installed
>
> on startup
> set the directory to "../images"
> put random(49) into ArtNo
> put "taka_art_" &ArtNo&".gif" into nextArt
> put URL ("binfile:header_art/"&nextArt) into URL
> ("binfile:taka_header_art.gif")
> put "Done" into theResult
> put "Content-Type: text/html" & cr
> put "Content-Length:" && the length of theResult & cr & cr
> put theResult
> end startUp
>
> now, set the permissions CHMOD 755 for the above script also.
>
>
> fyi the above script takes a random image from a folder (all the same
> size
> of course) and copies it to another image... the html file that uses the
> image then has a different image in that same place. i.e. this is a
> daily
> rotation of an image on site.
>
> Here is another script that processes a simple subscription on a form
> and
> sends email off to subscribe the individual
>
> #!/export/vhost/org/g/greatwebsite/www/public_html/cgi-bin/mc
> on startup
> read from stdin until empty
> put urlDecode (it) into tDataIn
> split tDataIn by "&" and "="
> put isWellFormedMailtoScheme (tDataIn ["email"]) into emailCheck
> switch emailCheck
> case "False"
> put badEmail(fixYourEmail) into tResponse
> break
> case "True"
>
> put tDataIn ["subscribe_mc"] into tRemit
> put tDataIn ["email"] after tRemit
>
> put "---Valid Web Subscription--" & cr before tRemit
> put "/usr/lib/sendmail -t" into mprocess
> open process mprocess for write
> write "From:" && "webmaster at hindu.org" & cr to process mprocess
> write "To:" && "mylistAdmin at someListServe.org" & cr to process
> mprocess
> write "Subject:" && "Subscriber to Master Course" & cr & cr to process
> mprocess
> write tRemit to process mprocess
> close process mprocess
> wait until the openprocesses is empty
> ## now we send an acknowledgement to the person by HTTP
> put url "file:../mc/subscr-mc_thankyou.shtml" into tResponse
> replace "***Subscriber***" with tDataIn ["email"] in tResponse
> end switch
>
> put "Content-Type: text/html" & cr
> put "Content-Length:" && the length of tResponse & cr & cr
> put tResponse
>
> end startup
>
> ##this function is a bit "hokey" but works ... new regEx expressions
> ## should make this easier now... but haven't had time to re-write it.
>
>
> function isWellFormedMailtoScheme email
>
> # return TRUE if email is a legal email URI, else return FALSE
> # We are not actually *validating* the email address, only its syntax.
> # Per address specification rules of RFC822: Standard for ARPA
> Internet
> Text Messages
> # http://www.w3.org/Protocols/rfc822/Overview.html
>
> # Basic syntax requires: one or more characters before the @ sign,
>
> split email by "@"
> if extents(email) <> "1,2" then return false # only 1 @-sign is
> permitted
> put email[2] into hostanddomain
>
> # There are 2 options to check, domain-literal or domain-logical:
>
>
> # domain-literal option:
> # primitive network host address form, must have [###.###.###.###]
> where 0
> < # < 256
> if char 1 of hostanddomain = "[" then
> if not last char of hostanddomain = "]" then return false
> delete char 1 of hostanddomain
> delete last char of hostanddomain
> set the itemDel to "."
> if the num of items of hostanddomain <> 4 then return false
> repeat with x = 1 to 4
> if not isNumber(item x of hostanddomain) then return false
> if item x of hostanddomain > 255 or item x of hostanddomain < 1
> then
> return false
> end repeat
> return TRUE
> end if
>
> # domain-logical option: (the "normal" form)
> # this permits an arbitrary number of strings separated by ".",
> ending in
> a domain name
> set the itemDel to "."
> put the num of items of hostanddomain into hostanddomainItems
> if hostanddomainItems = 0 then return false
> if hostanddomain contains ".." then return false # empty hosts not
> allowed
> repeat with x = length(hostanddomain) down to 1
> if not ("0123456789.-abcdefghijklmnopqrstuvwxyz_" contains char x of
> hostanddomain) then return false
> end repeat
> return TRUE
> end isWellFormedMailtoScheme
>
> function badEmail
> put "<html><head><Title>There is a problem with your email address!"\
> & "</TITLE></HEAD><CENTER><BODY BGCOLOR=#ffffff> <FONT
> color=FF0000><h3>Sorry,"\
> & "there was something wrong in the way you entered your email. <br>"\
> & "Please go back and enter it again. Thank
> you.</H3></FONT></CENTER></BODY></HTML>" into fixYourEmail
> return fixYourEmail
> end badEmail
>
>
>> Thanks!
>> Mark
>
> I also have a REV "gadget" that I keep all my cgi's in and I can upload
> them
> to site, set CHMOD automatically and then run them and "catch" and
> returned
> data in a field... for fast testing i.e. avoids the FTP
> Client/browser/Bbedit loop for your dev and testing.
>
> Hinduism Today
>
> Sivakatirswami
> Editor's Assistant/Production Manager
> katir at hindu.org
> www.HinduismToday.com, www.HimalayanAcademy.com,
> www.Gurudeva.org, www.hindu.org
>
> Read The Master Course Lesson of the Day at
> http://www.gurudeva.org/lesson.shtml
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list