Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

HTTP-Post Error

 [1/21] from: mattymattkim::hotmail::com at: 17-Oct-2002 0:27


I'm using the HTTP-POST script found on the REBOL website to send SMS messages over Rogers AT&T's website. http://www.rogers.com/english/wireless/sendpcs.html It's been working beautifully in the past with some help from you REBOL genious' but now occasionally I seem to get a "HTTP/1.1 500 Internal Server Error". Is Rogers trying to throttle the amount of SMS messages sent by 1 user through their website? Is there any way around this? Here's my modified code (warning, it's very crude!). I think most of it's the same as the original, except the bottom. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ REBOL [ Title: "Simple HTTP POST" File: %http-post.r Author: "Martin Johannesson" Email: [d95-mjo--nada--kth--se] Date: 30-Jun-1999 Purpose: { This script sends a "form" to a webserver using the POST method. The included example translates a string in English to German by posting the data to AltaVista's translation web page and then parsing the reply. } Category: [web util net 4] ] url-encode: func [ {URL-encode a string} data "String to encode" /local new-data ][ new-data: make string! "" normal-char: charset [ #"A" - #"Z" #"a" - #"z" #"@" #"." #"*" #"-" #"_" #"0" - #"9" ] if not string? data [return new-data] forall data [ append new-data either find normal-char first data [ first data ][ rejoin ["%" to-string skip tail (to-hex to-integer first data) -2] ] ] new-data ] http-post-form: func [ {Post a form to a web server} url "The URL to post to" data [block!] "A block of name/value pairs to represent the form" /local encoded-data port-spec HTTP-Post-Header http-request buffer tmp-buffer ][ port-spec: make port! [ scheme: 'tcp port-id: 80 timeout: 0:10 ] net-utils/url-parser/parse-url port-spec url encoded-data: make string! "" foreach [name value] data [ append encoded-data rejoin [ url-encode name "=" url-encode value "&" ] ] remove back tail encoded-data HTTP-Post-Header: make object! [ Accept: "*/*" User-Agent: reform ["REBOL" system/version] Host: port-spec/host Content-Type: "application/x-www-form-urlencoded" Content-Length: length? encoded-data ] http-request: rejoin [ "POST /" either found? port-spec/path [port-spec/path][""] either found? port-spec/target [port-spec/target][""] " HTTP/1.0^/" net-utils/export HTTP-Post-Header "^/" encoded-data ] http-port: open/lines [ scheme: 'tcp port-id: port-spec/port-id timeout: port-spec/timeout host: port-spec/host user: port-spec/user pass: port-spec/pass ] insert http-port http-request buffer: make string! 10000 tmp-buffer: reform ["HTTP-Response:" pick http-port 1] while [not none? tmp-buffer] [ append buffer rejoin [tmp-buffer "^/"] tmp-buffer: pick http-port 1 ] close http-port HTTP-Header: make object! [ HTTP-Response: Date: Server: Last-Modified: none Accept-Ranges: Content-Encoding: Content-Type: none Content-Length: Location: Expires: Referer: Connection: none ] parse-header HTTP-Header buffer ] send-message: func [ {Sends a message} area-code phone-number message ][ not-lt-gt: complement charset [#"<" #">"] tag-rule: ["<" some not-lt-gt ">"] tmp: http-post-form http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new? reduce [ "msisdn" join area-code phone-number "num1" area-code "num2" phone-number "oldtext" "" "text" message "SIZEBOX" to-string length? message "submit" "send message" "sm_ym" "Your Message: " "sm_status_ok" "has been sent to:" "sm_status_fail" "cannot presently be sent to: " "sm_logo" "/att-logo.gif" "sm_home_link" "http://www.rogers.com" "sm_home_text" "home" ] if none? find tmp/HTTP-Response "200" [return join "Error: " tmp/HTTP-Response] ; either parse tmp/content [ ; very ugly ; parsing attempt ; thru "Your Message: <br>" to {</b><br>} thru "<br>" copy trans to ; {</font>} to end ; changed parse value ; ][ ; return trans ; ][ ; print ["Content was: " tmp/content] ; return "Error: Unable to parse HTML result page" ; ] ] ;'area' 'number' and 'textbody' are variables loaded from another function. ;ex. '416' '5551234' 'hello there' print send-message area number textbody _________________________________________________________________ Surf the Web without missing calls! Get MSN Broadband. http://resourcecenter.msn.com/access/plans/freeactivation.asp

 [2/21] from: gchiu:compkarori at: 17-Oct-2002 20:25


>It's been working beautifully in the past with some help >from you REBOL genious' but now occasionally I seem to >get a "HTTP/1.1 500 Internal Server Error". > >http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new?
Perhaps the server code is dying because of the extra "?" you've added here. The "?" is used when using the GET method, but not with POST. Also, have you tried using 'read as in read/custom http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new [ ... ] to POST your message? -- Graham Chiu

 [3/21] from: rebol-list2:seznam:cz at: 19-Oct-2002 10:10


Hello Graham, Thursday, October 17, 2002, 9:25:00 AM, you wrote:
>>It's been working beautifully in the past with some help >>from you REBOL genious' but now occasionally I seem to >>get a "HTTP/1.1 500 Internal Server Error". >> >>http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new?
GC> Perhaps the server code is dying because of the extra "?" GC> you've added here. The "?" is used when using the GET GC> method, but not with POST. GC> Also, have you tried using 'read as in GC> read/custom GC> http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new [ ... GC> ] GC> to POST your message? GC> -- GC> Graham Chiu Yes, the read/custom and open/custom is very useful, some pages needs to be accesed only from some pages so the 'Referer and 'Host in the header must be set correctly, I'm using for example this code (and will have to add this to my %reb-web-bot.r script as well): This is not complete code, because first I want to make some code cleaning before puclicating it:-) only important parts are here now: port: open/direct/binary/custom http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2 [ header [ User-Agent: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)" Referer: "http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2" Host: "www2.eurotel.cz" ] ] probe port/locals cookie: port/locals/headers/set-cookie buffer: make binary! 8000 set-modes port/sub-port [lines: false binary: true no-wait: true] until [ if not data: wait [60 port/sub-port] [data: true break] if data: copy port/sub-port [append buffer data] not data ] close port ;some page parsing is here..... ;...after the parsing I have: poststr with the url-encoded postdata ;so I can send them: print read/custom rejoin [http:// port/host %/sms/index.html] x: compose/deep [ header [ User-Agent: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)" Referer: "http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2" Host: "www2.eurotel.cz" Cookie: (cookie) ] post (poststr) ] buffer: make binary! 8000 set-modes port/sub-port [lines: false binary: true no-wait: true] until [ if not data: wait [60 port/sub-port] [data: true break] if data: copy port/sub-port [append buffer data] not data ] close port print buffer: to-string buffer

 [4/21] from: mattymattkim:hot:mail at: 19-Oct-2002 8:41


To be quite honest, I'm still a newbie at REBOL and I find the code you posted, very difficult to understand! I wish I were a REBOL genious! =)
>From: RebOldes <[rebol-list2--seznam--cz]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 77>>
>[rebol-request--rebol--com] with "unsubscribe" in the >subject, without the quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online

 [5/21] from: rebol-list2:seznam:cz at: 21-Oct-2002 11:48


Hello Matthew, Saturday, October 19, 2002, 2:41:08 PM, you wrote: MK> To be quite honest, I'm still a newbie at REBOL and I find the code you MK> posted, very difficult to understand! I wish I were a REBOL genious! =) Everything needs some time:-) I had to spend a lot of my time to find how to use the /custom switch, because I havn't seen any documentation on it. Important is, that if you just need to post data, you can do: read/custom url [post "data=value"] In the more complex example I've send I use 'open port, because I needed to get the cookie. This is set in the port/locals/headers as the 'set-cookie value (if there is some cookie) To post the cookie with your data, you have to use: read/custom url [post "data=value" header [Cookie: "cookie_name=value"]] I was using the %http-post.r script as well but since there is support directly in Rebol, why not to use it.

 [6/21] from: gchiu:compkarori at: 22-Oct-2002 10:29


>Everything needs some time:-) I had to spend a lot of my >time to find >how to use the /custom switch, because I havn't seen any >documentation >on it.
And your example was much appreciated :)
>In the more complex example I've send I use 'open port, >because I >needed to get the cookie. This is set in the >port/locals/headers as >the 'set-cookie value (if there is some cookie) >
Does it correctly fetch multiple cookies?
>I was using the %http-post.r script as well but since >there is support >directly in Rebol, why not to use it.
Of course at the time that script was written, the custom switch did not exist. -- Graham Chiu

 [7/21] from: mattymattkim:hotm:ail at: 24-Oct-2002 20:49


How would I post multiple inputs? Like so? read/custom url [post "data=value" "data2=value"] Also, can "value" be a string? I've been trying to send text messages via Rogers AT&T web portal. I have it work using http-post.r, but I'd like to use read/custom to get this done. Here's what I have so far: read/custom http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new [post msisdn=4165551234 area=416 num1=416 num2=5551234 oldtexttext=hello there SIZEBOX=11 SIZEBOXW=2 submit=send message sm_title=Rogers | Wireless sm_header_ok=Thank You sm_header_fail=Sorry sm_ym=Your Message: sm_status_ok=has been sent to: sm_status_fail=cannot presently be sent to: sm_logo=/att-logo.gif sm_pcs_link=http://www.rogers.com/english/wireless/sendpcs.html sm_pcs_text=Send a PCS message sm_home_link=http://www.rogers.com "sm_home_text=home"] It seems to connect, but it doesn't work. :( Matt
>From: RebOldes <[rebol-list2--seznam--cz]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 24>>
>[rebol-request--rebol--com] with "unsubscribe" in the >subject, without the quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Get faster connections -- switch to MSN Internet Access! http://resourcecenter.msn.com/access/plans/default.asp

 [8/21] from: gchiu:compkarori at: 26-Oct-2002 12:16


On Thu, 24 Oct 2002 20:49:10 -0400 "Matthew Kim" <[mattymattkim--hotmail--com]> wrote:
>How would I post multiple inputs? Like so? > >read/custom url [post "data=value" "data2=value"] >
Try read/custom url [ post "name1=value1&name2=value2...." ] -- Graham Chiu

 [9/21] from: mattymattkim:hotmai:l at: 26-Oct-2002 13:09


Great! That worked! Now, I'm trying to apply this to another website, but it seems to send the post using Java. There's no URL to post it to. How do I solve this problem? I think this is the code to post the data: <a href="JavaScript: document.forms[0].submit();">
>From: "Graham Chiu" <[gchiu--compkarori--co--nz]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 15>>
>[rebol-request--rebol--com] with "unsubscribe" in the subject, without the >quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Surf the Web without missing calls! Get MSN Broadband. http://resourcecenter.msn.com/access/plans/freeactivation.asp

 [10/21] from: mattymattkim:hotm:ail at: 27-Oct-2002 23:53


Why doesn't this work? post_data: "data1=value&data2=value2" read/custom URL[ post post_data ] _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online

 [11/21] from: al:bri:xtra at: 28-Oct-2002 18:44


Matt wrote:
> Why doesn't this work? > post_data: "data1=value&data2=value2" > > read/custom URL[ > post post_data > ]
Try: post_data: "data1=value&data2=value2" read/custom URL compose [ post (post_data) ] 'compose evaluates paren! values in a block! value. Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [12/21] from: gchiu:compkarori at: 28-Oct-2002 20:47


On Sun, 27 Oct 2002 23:53:55 -0500 "Matthew Kim" <[mattymattkim--hotmail--com]> wrote:
>post_data: "data1=value&data2=value2" > >read/custom URL[ > post post_data >]
That's because 'post_data is inside the block, and not yet evaluated. You can also try read/custom URL reduce [ 'POST post_data ] -- Graham Chiu

 [13/21] from: mattymattkim:h:otmail at: 28-Oct-2002 9:02


Great, that worked! 2 questions: 1) How do I check the returned page (after posting), to ensure there are no errors. 2) Now, I'm trying to apply this to another website, but it seems to send the post using Java. There's no URL to post it to. How do I solve this problem? I think this is the code to post the data: <a href="JavaScript: document.forms[0].submit();"> Cheers, Matt
>From: "Graham Chiu" <[gchiu--compkarori--co--nz]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 17>>
>[rebol-request--rebol--com] with "unsubscribe" in the subject, without the >quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Get a speedy connection with MSN Broadband.  Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp

 [14/21] from: gchiu:compkarori at: 29-Oct-2002 6:58


On Mon, 28 Oct 2002 09:02:50 -0500 "Matthew Kim" <[mattymattkim--hotmail--com]> wrote:
>2 questions: > >1) How do I check the returned page (after posting), to >ensure there are no errors. >
page: read/custom URL reduce [ 'POST post_data ]
>2) Now, I'm trying to apply this to another website, but >it seems to send the post using Java. There's no URL to >post it to. How do I solve this problem?
That's javascript, and I'm not too familiar with that language, but there must be a form on the page that it is referring to, and the url will be there. -- Graham Chiu

 [15/21] from: al:bri:xtra at: 29-Oct-2002 16:39


Matt wrote:
> 2) Now, I'm trying to apply this to another website, but it seems to send
the post using Java. There's no URL to post it to. How do I solve this problem?
> I think this is the code to post the data: > <a href="JavaScript: document.forms[0].submit();">
That's JavaScript. JavaScript's only relationship with Java is the first four letters and they're usually associated with HTML pages. :) Look for a <form> line in the HTML. Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [16/21] from: mattymattkim:h:otmail at: 29-Oct-2002 1:25


I found the form line and it reads: <!-- form content begins --> <form method="POST" action="/servlet/CI_Meta" name="saab_lmp"> ... I'm pretty sure the entire path is: http://mo.gmcanada.com/servlet/CI_Meta But it asks for a username and password to get in. Matt
>From: "Andrew Martin" <[Al--Bri--xtra--co--nz]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 19>>
>[rebol-request--rebol--com] with "unsubscribe" in the >subject, without the quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Get a speedy connection with MSN Broadband.  Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp

 [17/21] from: brett:codeconscious at: 29-Oct-2002 17:36


Hi Matt, Supply the username and password just before the hostname in the url like this: http://username:[password--mo--gmcanada--com]/servlet/CI_Meta Brett. --------------- Matt wrote: ----------- <!-- form content begins --> <form method="POST" action="/servlet/CI_Meta" name="saab_lmp"> ... I'm pretty sure the entire path is: http://mo.gmcanada.com/servlet/CI_Meta But it asks for a username and password to get in.

 [18/21] from: mattymattkim:hotm:ail at: 29-Oct-2002 1:47


The thing is, I don't have the username and password. The form is accessible using a web browser. But I was trying to use REBOL to fill out the form and sent it. When looking for the <form method=post...
> URL reference, it looks like it's pointing to a site that requires a
username and password. I'm assuming they're somehow using a Javascript to provide the username and password? To hide that data from the public eye and prevent people from making automated scripts to fill out the form? Matt
>From: "Brett Handley" <[brett--codeconscious--com]> >Reply-To: [rebol-list--rebol--com]
<<quoted lines omitted: 16>>
>[rebol-request--rebol--com] with "unsubscribe" in the >subject, without the quotes.
Matt Kim If everything is under control, you are going too slow -Mario Andretti _________________________________________________________________ Internet access plans that fit your lifestyle -- join MSN. http://resourcecenter.msn.com/access/plans/default.asp

 [19/21] from: gscottjones:mchsi at: 29-Oct-2002 3:59


From: "Matthew Kim"
> The form is accessible using a web browser. But > I was trying to use REBOL to fill out the form and
<<quoted lines omitted: 3>>
> I'm assuming they're somehow using a Javascript to > provide the username and password? ...
Hi, Matthew, I don't think so. Perhaps the root document should be: www.gmcanada.com If that doesn't work, would you be willing to give us the actual URL to the page that has the form? Respectfully, --Scott Jones

 [20/21] from: mattymattkim:hotm:ail at: 29-Oct-2002 10:28


The site uses a lot of flash, could this pose a problem? Here's the source code for the form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <link rel="stylesheet" href="/ssi/english/vehicles/saab/stylesheet.css" type="text/css"> <script src="/ssi/english/vehicles/js/saabLMP_pulldown.js" language="JavaScript"></script> <script language="javascript"> <!-- var LMPCookie = document.cookie; function getCookie(cookieName) { var index = LMPCookie.indexOf(cookieName +"="); if (index == -1) return null index = LMPCookie.indexOf("=", index) + 1; var endIndex = LMPCookie.indexOf(";", index); if (endIndex == -1) endIndex = LMPCookie.length; return unescape(LMPCookie.substring(index, endIndex)); } var cookieVal = getCookie("saab_lmp_rules"); if (cookieVal == 999) location.href /ssi/english/vehicles/saab/lmp/rules.html ; function makeLeadingZero(str) { if (str.length == 1) { str = "0" + str; } return str; } function setCreateDate() { var theDate = new Date(); var theYear = theDate.getFullYear().toString(); var theMonth = (theDate.getMonth() + 1).toString(); theMonth = makeLeadingZero(theMonth); var theDay = theDate.getDate().toString(); theDay = makeLeadingZero(theDay); document.forms[0].create_date.value = theYear + theMonth + theDay; } function populateIDs() { var queryString = top.queryString; if ((queryString.indexOf("surveyID=")) == -1) { //traditional querystring has not carried, fall back to get value from cookie var strCookie = document.cookie var strVUE = "VUE_LMP_ids=" queryString = strCookie.substring(strCookie.indexOf(strVUE) + strVUE.length, strCookie.indexOf(";")); } var surveyStr = "surveyID="; var surveyStart = queryString.indexOf(surveyStr) + surveyStr.length; if (queryString.indexOf(surveyStr) != -1) { //if survey ID submitted to form, find length of survey ID number var endIndex = queryString.indexOf("&", surveyStart); if (endIndex != -1) { //querystring continues after survey ID, therefore ends at & var surveyLen = endIndex - surveyStart; } else { //querystring ends with survey ID var surveyLen = queryString.length - surveyStart; } //write ID to hidden form field var surveyID = queryString.substr(surveyStart, surveyLen); //document.forms[0].component_code.value = surveyID; } var eventStr = "eventCode="; var eventStart = queryString.indexOf(eventStr) + eventStr.length; if (queryString.indexOf(eventStr) != -1) { var endIndex = queryString.indexOf("&", eventStart); if (endIndex != -1) { var eventLen = endIndex - eventStart; } else { var eventLen = queryString.length - eventStart; } //write ID to hidden form field var eventCode = queryString.substr(eventStart, eventLen); document.forms[0].event_code.value = eventCode; } //alert(surveyID +", "+ eventCode); } function prefillSelections() { writeNewList(document.forms[0].cv_namplt_desc_1, arrNameplate); writeNewList(document.forms[0].cv_namplt_desc_2, arrNameplate); writeNewList(document.forms[0].ft_namplt_desc_1, arrNameplate); writeNewList(document.forms[0].ft_namplt_desc_2, arrNameplate); return true; } var missingRequiredFieldError = "Please complete the {FIELD_NAME} field."; var emailAddressError = "You have entered an incorrect or invalid email address."; var postalCodeError = "You have entered an incorrect or invalid postal code."; var numericError = "You have entered an incorrect or invalid {FIELD_NAME}."; var leaseEndDateError = "You have entered an invalid date for {FIELD_NAME}."; var languageSelectError = "You must choose a language."; var replaceFieldName = /{FIELD_NAME}/gi function validateForm(theForm) { valid = true; stripSpecialCharactersFromField(theForm.first_name_and_initial); stripSpecialCharactersFromField(theForm.last_name); stripSpecialCharactersFromField(theForm.address_line_1); stripSpecialCharactersFromField(theForm.address_line_2); stripSpecialCharactersFromField(theForm.city_name); stripPunctuationFromField(theForm.first_name_and_initial); stripPunctuationFromField(theForm.last_name); stripPunctuationFromField(theForm.address_line_1); stripPunctuationFromField(theForm.address_line_2); stripPunctuationFromField(theForm.city_name); if (valid && (theForm.first_name_and_initial.value == "")) { valid = false; theForm.first_name_and_initial.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, First Name ); alert(errMsg); } if (valid && (theForm.last_name.value == "")) { valid = false; theForm.last_name.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, Last Name ); alert(errMsg); } if (valid && (theForm.address_line_1.value == "")) { valid = false; theForm.address_line_1.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, Address ); alert(errMsg); } if (valid && (theForm.city_name.value == "")) { valid = false; theForm.city_name.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, City ); alert(errMsg); } if (valid && (theForm.candn_provnc_or_trtry_cd.selectedIndex == "")) { valid = false; theForm.candn_provnc_or_trtry_cd.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, Province ); alert(errMsg); } var pcode = theForm.candn_forwrd_sortn_code.value + theForm.candn_local_dstrbn_unit_cd.value; if (valid && pcode != "") { valid = valid && validatePostalCode(pcode); if (!valid) { theForm.candn_forwrd_sortn_code.focus(); alert(postalCodeError); } } if (valid && ((theForm.hom_ph_area_code.value == "") || (theForm.hom_ph_phone_nbr.value == ""))) { valid = false; theForm.hom_ph_area_code.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, Home Phone Number ); alert(errMsg); } stripPunctuationFromField(theForm.hom_ph_area_code); stripPunctuationFromField(theForm.hom_ph_phone_nbr); if (valid && ((theForm.hom_ph_area_code.value != "") || (theForm.hom_ph_phone_nbr.value != ""))) { if ((theForm.hom_ph_area_code.value.length == 3) && (theForm.hom_ph_phone_nbr.value.length == 7)) { valid = valid && validateNumericValue(theForm.hom_ph_area_code, "Home phone area code", true); valid = valid && validateNumericValue(theForm.hom_ph_phone_nbr, "Home phone number", true); }else { valid = false; theForm.hom_ph_area_code.focus(); var errMsg = numericError.replace(replaceFieldName, "home phone number"); alert(errMsg); } } if (valid && ((theForm.bus_ph_area_code.value == "") || (theForm.bus_ph_phone_nbr.value == ""))) { valid = false; theForm.bus_ph_area_code.focus(); var errMsg = missingRequiredFieldError.replace(replaceFieldName, business phone number ); alert(errMsg); } stripPunctuationFromField(theForm.bus_ph_area_code); stripPunctuationFromField(theForm.bus_ph_phone_nbr); if (valid && ((theForm.bus_ph_area_code.value != "") || (theForm.bus_ph_phone_nbr.value != ""))) { if ((theForm.bus_ph_area_code.value.length == 3) && (theForm.bus_ph_phone_nbr.value.length == 7)) { valid = valid && validateNumericValue(theForm.bus_ph_area_code, "Business phone area code", true); valid = valid && validateNumericValue(theForm.bus_ph_phone_nbr, "Business phone number", true); }else { valid = false; theForm.bus_ph_area_code.focus(); var errMsg = numericError.replace(replaceFieldName, "business phone number"); alert(errMsg); } } /* if (valid && ((theForm.purchs_int_rng_cd[0].checked == false) && (theForm.purchs_int_rng_cd[1].checked == false) && (theForm.purchs_int_rng_cd[2].checked == false) && (theForm.purchs_int_rng_cd[3].checked == false) && (theForm.purchs_int_rng_cd[4].checked == false) && (theForm.purchs_int_rng_cd[5].checked == false))) { valid = false; theForm.purchs_int_rng_cd[0].focus(); var errMsg = "Please tell us when you expect to obtain your next vehicle."; alert(errMsg); } if (valid && ((theForm.acqstn_methd_cd[0].checked == false) && (theForm.acqstn_methd_cd[1].checked == false))) { valid = false; theForm.acqstn_methd_cd[0].focus(); var errMsg = "Please tell us how you expect to obtain your next vehicle."; alert(errMsg); } */ //alert(document.forms[0].CURRENT_VEHICLE_MANUFACTURER_1.value); return valid; } function stripPunctuationFromField(fieldObject) { fieldObject.value = stripPunctuation(fieldObject.value); } function stripPunctuation(theValue) { var returnMe = ""; var validChars = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (i=0; i<theValue.length; i++) { var theChar = theValue.substring(i, i+1); if (validChars.indexOf(theChar.toUpperCase()) > -1) { returnMe += theChar; } } return returnMe; } function stripSpecialCharactersFromField(fieldObject) { fieldObject.value = stripSpecialCharacters(fieldObject.value); } function stripSpecialCharacters(theValue) { var returnMe = ""; var numSpecialChars = 8; var validChars = ["A", "C", "E", "I", "N", "O", "U", "Y"]; var special_a = ["À", "Á", "Â", "Ã", "Ä"]; var special_c = ["Ç"]; var special_e = ["È", "É", "Ê", "Ë"]; var special_i = ["Ì", "Í", "Î", "Ï"]; var special_n = ["Ñ"]; var special_o = ["Ò", "Ó", "Ô", "Õ", "Ö"]; var special_u = ["Ù", "Ú", "Û", "Ü"]; var special_y = ["Ý"]; var specialChars = [special_a, special_c, special_e, special_i, special_n, special_o, special_u, special_y]; for (x = 0; x < theValue.length; x++) { var theChar = theValue.substring(x, x+1); for (i = 0; i < numSpecialChars; i++) { for (j = 0; j < specialChars[i].length; j++) { if (theChar.toUpperCase() == specialChars[i][j]) { theChar = validChars[i] } } } returnMe += theChar } return returnMe; } /** * Checks that all chars in theValue are digits. */ function allCharsAreDigits(theValue) { for (var i=0; i<theValue.length; i++) { var theDigit = theValue.substring(i, (i+1)); if (!(parseInt(theDigit) > -1)) { return false; } } return true; } function validateNumericValue(fieldObject, fieldName, showErrorMsg) { var valid = allCharsAreDigits(fieldObject.value); if (!valid && showErrorMsg) { fieldObject.focus(); var errMsg = numericError.replace(replaceFieldName, fieldName); alert(errMsg); } return valid; } function validateEmailAddress(theValue) { var valid = true; var a = theValue.indexOf("@"); if ((a < 1) || (a == (theValue.length - 1))) { valid = false; }else { var emailName = theValue.substring(0, a); var emailDomain = theValue.substring(a+1); valid = valid && validateEmailName(emailName); valid = valid && validateEmailDomain(emailDomain); } return valid; } function validateEmailDomain(theDomain) { var dot = theDomain.indexOf("."); if ((dot < 1) || (dot == (theDomain.length -1))) { return false; } return validateEmailName(theDomain); } /** * Returns true if theAddress is a valid email name, else returns false. * The name is the bit before the @. */ function validateEmailName(theName) { if ((theName.length < 1) || (theName.length > 25)) { return false; } var encoded = escape(theName); if ((encoded.indexOf("%") < 0) && (encoded.indexOf("*") < 0) && (encoded.indexOf("+") < 0) && (encoded.indexOf("/") < 0) && (encoded.indexOf("@") < 0)) { return true; }else { return false; } } /** * Checks that the postal code is in a valid format. * Param is a form text object. */ function validatePostalCode(formObject) { var valid = true; var userPostalCode = formObject.value; // Strip spaces: var s = userPostalCode.indexOf(" "); while (s > -1) { userPostalCode = userPostalCode.substring(0, s) + userPostalCode.substring(s+1); s = userPostalCode.indexOf(" "); } formObject.value = userPostalCode.toUpperCase(); // Check the length of the postal code: if (userPostalCode.length != 6) { valid = false; }else { var letter1 = userPostalCode.substring(0,1).toUpperCase(); var letter2 = userPostalCode.substring(1,2).toUpperCase(); var letter3 = userPostalCode.substring(2,3).toUpperCase(); var letter4 = userPostalCode.substring(3,4).toUpperCase(); var letter5 = userPostalCode.substring(4,5).toUpperCase(); var letter6 = userPostalCode.substring(5,6).toUpperCase(); var validLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var validDigits = "0123456789"; // Check that the chars are valid values: if ((validLetters.indexOf(letter1) > -1) && (validDigits.indexOf(letter2) > -1) && (validLetters.indexOf(letter3) > -1) && (validDigits.indexOf(letter4) > -1) && (validLetters.indexOf(letter5) > -1) && (validDigits.indexOf(letter6) > -1)) { // OK valid = valid && true; }else { valid = false; } } return valid; } function validateLeaseEndDate(theForm, whichLease) { var valid = true; var leaseDate = ""; if ((eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '_YYYY.value != ""')) || (eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '_MM.value != ""')) || (eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '_DD.value != ""'))) { valid = valid && validateDate(eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '_DD'), eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + _MM ), eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + _YYYY )); if (valid) { leaseDate = "" + eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_YYYY.value") + eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_MM.value") + eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_DD.value"); } } eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '.value = leaseDate'); return valid; } /** * Checks the three supplied form objects to see if they are valid numbers. * Adds a '0' to the beginning of single-digit day and month fields. * Puts the altered values into the form objects. */ function validateDate(dayFormObject, monthFormObject, yearFormObject) { var day = dayFormObject.value; var month = monthFormObject.value; var year = yearFormObject.value; if ((day.length > 2) || (month.length > 2) || (year.length != 4)) { return false; } if ((navigator.appVersion.substring(0,3) >= "3.0" && navigator.appName == "Netscape") || (navigator.appVersion.substring(0,3) >= "4.0" && navigator.appName.substring(0,9) == "Microsoft")) { i

 [21/21] from: gscottjones:mchsi at: 29-Oct-2002 12:42


From: "Matthew Kim"
> The site uses a lot of flash, could this pose a problem?
I don't "know," but I don't think so.
> Here's the source code for the form:
<snipped> Hi, Mathew, You've got yourself a mess! :-) Without seeing the original URL, I do suspect that you are correct about the site URL being mo.gmcanada.com. The only information that I can see being pulled in concerns the event code (which is either pulled from the query string in the URL or the cookie). Curiously, other data is missing, namely arrNameplate . I cannot explain why the site seems to want authentication, nor from where it would receive it if this form where in situ (again, it doesn't seem to request such info from the cookie), unless it is embedded in the cookie or querystring, like as a session id from having previously signed in (and then passed by the "referal" url and parsed on the server.). Sorry, I can't be of further help. Good luck! --Scott Jones

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted