cgi-engine does not run

Monte Goulding monte at sweattechnologies.com
Wed Sep 10 20:43:01 EDT 2003


> Nothing
> there is no error as the script executes just fine, beside the save not 
> doing anything. I would bugzilla this, but I'm the only one getting 
> this behaviour, and I'm not gonna send runrev my computer just so they 
> can see it too ;)
> Oh and typing ./guestbook.cgi in the terminal just hangs until I press 
> ctrl-c ( I know a unix command *does little dance*)
> 
Make sure the stack is writable:
chmod 775 *.rev

Try altering the script to this:

#!mc
on startup
   open stack "guestbook"
   set the defaultStack to "guestbook" -- don't know if this is needed
   read from stdin until empty
   if it <> empty then
     put urldecode(it) into data
     split data by "&" and "="
     go to last card
     create card
     put the short internet date into field "date"
     put data["name"] into field "name"
     put data["text"] into field "entry"
     replace return with "<br>" in field "entry"
   end if
   put  "Content-Type: text/html" & crlf & crlf
   put "<html><head><title>You are on my iBook! @ 
bvg.kicks-ass.org</title></head><body bgcolor=" & quote & "148D00" & 
quote & ">" into tBuffer -- use a buffer (may help)
   repeat with x = the number of cards down to 1
     go to card x
     put "<p>date:<br>"  & field "date" after tBuffer
     put "<br>name:<br>"  & field "name" after tBuffer
     put "<br>text:<br>" & field "entry" & "</p><hr>" after tBuffer
   end repeat
   put "</body>" after tBuffer
   save stack "guestbook" 
   put tBuffer
   quit -- just quit instead of closing the stack
end startup

If it were me I'd use customPropertySets:
uNames = the name field
uEntries = the entry field
uDates = the date field

The script would be like this:

on startUp
  put the customProperties["uDates"] of stack "guestbook" into tDatesA
  put the customProperties["uNames"] of stack "guestbook" into tNamesA
  put the customProperties["uEntries"] of stack "guestbook" into tEntriesA
  put the number of lines of keys(tDatesA) into tNumEntries
  read from stdin until empty
  if it <> empty then
     put urldecode(it) into data
     split data by "&" and "="
     add 1 to tNumEntries
     put the short internet date into tDatesA[tNumEntries]
     put data["name"] into tNamesA[tNumEntries]
     put replaceText(data["text"],cr,"<br>") into tEntriesA[tNumEntries]
     set the customProperties["uDates"] of stack "guestbook" to tDatesA
     set the customProperties["uNames"] of stack "guestbook" to tNamesA
     set the customProperties["uEntries"] of stack "guestbook" to tEntriesA
     save stack "guestbook"
  end if
  put  "Content-Type: text/html" & crlf & crlf
  put "<html><head><title>You are on my iBook! @ 
bvg.kicks-ass.org</title></head><body bgcolor=" & quote & "148D00" & 
quote & ">" into tBuffer 
  repeat with x = tNumEntries down to 1
     put "<p>date:<br>"  & tDatesA[x] after tBuffer
     put "<br>name:<br>"  & tNamesA[x] after tBuffer
     put "<br>text:<br>" & tEntriesA[x] & "</p><hr>" after tBuffer
  end repeat
  put "</body>" after tBuffer 
  put tBuffer
end startUp

Cheers

Monte



More information about the use-livecode mailing list