Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a HTML for to add to an existing XML file.

Status
Not open for further replies.

spodo

Technical User
Sep 13, 2005
1
0
0
IE
Hello,

The following question is probably a horrible betreyal of by ineptness.

I would like to find a way to add to an existing XML file using the user-inputted information in HTML text fields and submitted as a form.

The text information has to be incorporated into the xml during the process also.

e.g:

Using the following html to add a new item to an RSS feed:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<title>RSS Feed Updater.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<p>The Blocker Refuge RSS Feed. </p>
<form action="" method="post" name="form1" id="form1" onsubmit="">
<p>Name:
<input name="Name" type="text" size="57" />
</p>
<p>Job:
<input name="Job" type="text" size="50" />
</p>
<p>Homepage:
<input name="homepage" type="text" size="75" />
</p>
<input type="submit" name="Submit" value="Submit" />
</form>
<p>&nbsp;</p>

<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

The string [name << " - " << occupation] would form the title and the homepage string the link.

Basically I'm trying to make an open RSS feed.


Any suggestions?
 
dont understand, are you trying to add items to the xml file?

or are you trying to just use HTML to open the file?
 
I haven't read up on this properly yet but I came across an article once about XForms which apparently allow you to update xml from web pages.

Try the w3c site and search for XForms
 
XForms would be the ideal way to do this, but unfortunately its not natively supported in browsers (requires users to download a plugin).

If you don't want to use XForms, you'll need to use some kind of server-side solution - ASP, JSP, coldfusion, CGI, etc.

Jon

"I don't regret this, but I both rue and lament it.
 
Hello... Brian in Yakima, Wa here.

I am also wanting to do a similar thing using a simple html form to write additional email addresses (or just the domain name portion of the address) to an existing XML whitelist document which is parsed by an email server spam filter which I administrate. I also have the webserver under my control.

I would need complete instructions on how to implement such a thing. Or even better, buy something premade or have someone write it for me.

Is this something that someone here can coach me on?

Thanks,

Brian

 
This is pretty straight-forward. What server-side languages are installed on the webserver and which do you know how to use?

Jon

"I don't regret this, but I both rue and lament it.
 
Jon,

I'm sorry for the delay of my response to your response. I have been out of town dealing with the issues related to my mother's death. (She was almost 101) Lots of stuff to find a home for.

Anyway, I want you to know that I appreciate your interest in helping. I am truely a novice at server side programming, but I do have several Perl items running on the server which is Apache on Windows. The cgi stuff and forms I can handle. The only thing I have been able to dig up on the net about writing xml files (or re-writing them)with html forms involves DOM's and other things that I am not knowledgeable about.

My need is so simple. One form field to insert (or append) an email address into a section of an XML document. It might be straight-forward to you but I'll need a lot of hand-holding I'm afraid.

I'm hoping that anyone who attempts to help can realize that I'm not programmer, but an internet server (web, email, ftp, vnc, etc.) operator who has been fortunate enough to have success at most endeavors combining languages and other things. But I don't do stuff like this often and it seems like I have to relearn a whole lot every time I try to add something. Get it?

So, I'd say Perl, would be my best bet, probably - and I'd have to find a script which is already prepared for such a purpose and needs little modification.

Hope you can help.

Thanks,

Brian
 
One more thing...

The Web server and Email server programs (where the XML whitelist file is located) are on the same machine, which makes things easier, I'm sure.

Brian
 
Sorry to hear about your mum.

I havent done any Perl for a while. If you can write a script to get the form variables, thats probably the hardest part done. XML is just a text file, so all you need to do is load it to a variable and do some string manipulation. Perl does have modules for using XML (DOM methods and such) but you won't need to use them for a simple append. Just use string manipulation.

I could probably provide an example of any parts you not sure of.

Jon

"I don't regret this, but I both rue and lament it.
 
Jon,

By suggesting that I write a script to get the form variables - you're way passed my abilities.

I have, however, found a perl script which will find and replace text in any file. I haven't gotten far enough to test its viability but it's promising.

I have also begun to modify the accompanying (sample) HTML form to fulfill my needs, but have gotten stuck in the middle of that.

What seems like the correct approach is like this:

1. Find the string: " <expression casesensitive="no" type="regex" onmatch="score += 1">zyxxxyz</expression>"

2. replace with: " <expression casesensitive="no" type="regex" onmatch="score += 1">zyxxxyz</expression>
<expression casesensitive="no" type="regex" onmatch="score += 1">added email address</expression>"

The replacement is the line which was found originally and to it, added (after cr/lf) the same line with the new email address in place of the zyxxxyz. That would leave the original line to be found again and replaced over and over.

But, the punctuation in the xml line messes with the html and breaks it. And a bunch of stuff after that which I don't know how to do in the form

I want to send or include the HTML form file and hope someone can help me fix and finish it. Let me know where or how to post it.

Thanks again for the help. This is all a little part of some good learning. But I think sometimes I should just stick to my piano playing.

Brian
 
OK, just post your HTML and XML.

Jon

"I don't regret this, but I both rue and lament it.
 
Ok, Jon,

Here's the html form - incomplete as it is:

Code:
 <html><head>
 <title>Whitelist Editor</title>
 <body bgcolor="#FFFFFF" text="#000000" link="teal" vlink="gray" alink="red">

 <table border="0" width="90%" align="center">
 <tr> <TH width="10%" align="left" bgcolor="gray" height="100%">
  <BR>
 </th>
 <td align="left">
 <font face="verdana, arial" size="2">
 <center><B>Whitelist Editor</b></center>


 <BLOCKQUOTE>
 <form method="post" action="c:\program files\apache group\apache\cgi-bin\whitelist_editor.cgi">
 This page can be used to add email addresses to the "WHITELIST"<BR>
 <P><B>Each address must be added one at a time.</B></P>


 <input type="text" name="path_to_file" value="c\:Program Files\merak\">

 <input type="text" name="file_to_edit" value="Whitelist_test.xml">

 <input type="text" name="line_to_edit" value="	<expression casesensitive="no" type="regex" onmatch="score += 1">zyxxxyz</expression>"><BR>

 <b>Add this Email Address:</b> 
 <input type="text" name="new_content" size="50"></b><BR>


  Comment -- new content needs to be the line from above + cr/lf + same line with email address gathered from this field in place of the zyxxxyz.


 <input type="hidden" name="user_name" value="test">
 <input type="hidden" name="pass" value="test">
 </P>

 <P><center><input type="submit" name="byte_me" value="Add Address">&nbsp;&nbsp;<input type="reset" value="reset">
 </form></center></P>
 </BLOCKQUOTE></font>

 </td></tr></table>
 </body>
 </html>

And the whitelist XML is: (the line to edit is now at #87)

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<filters>
		<filter name="primary">
			<log>
				<option type="match true" />
				<option type="rules with match" />
				<option type="execution" />
			</log>
			<results default="accept">
				<result key="accept">
					<return>0</return>
					<copy enabled="no" createdir="no">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;accept&quot;,&quot;default&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="no">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
				</result>
				<result key="accept_do_nothing">
					<return>0</return>
				</result>
				<result key="mark">
					<return>0</return>
					<copy enabled="no" createdir="no">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;mark&quot;,&quot;whitelist&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="no">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
					<modifysource enabled="no">
					  <header enabled="no" action="add" item="X-RegEx-Filter" value="regex_whitelist.xml" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-Title" value="{result:rule:title}" comment="Not yet implemented" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-UID" value="{result:rule:uid}" comment="Not yet implemented" />
					</modifysource>
				</result>
				<result key="mark_high">
					<return>0</return>
					<copy enabled="no" createdir="no">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;mark_high&quot;,&quot;whitelist&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="no">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
					<modifysource enabled="yes">
					  <header enabled="no" action="add" item="X-RegEx-Filter" value="regex_whitelist.xml" />
					  <header enabled="no" action="replaceoradd" item="Importance" value="High" />
					  <header enabled="no" action="replaceoradd" item="X-Priority" value="1 (Highest)" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-Title" value="{result:rule:title}" comment="Not yet implemented" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-UID" value="{result:rule:uid}" comment="Not yet implemented" />
					</modifysource>
				</result>
			</results>
			<parser>
				<maxlines>10000</maxlines>
				<maxbuffer>500000</maxbuffer>
				<quickresult>yes</quickresult>
			</parser>
			<rules>
				<rule result="accept_do_nothing">
					<title>Whitelist MAIL FROM (do nothing)</title>
					<comment>Allow all email from these addresses (outbound mailing lists)</comment>
					<scope>
						<mailfrom>all</mailfrom>
					</scope>
					<expressions oninit="score=0" logic="return score > 0">
						<expression casesensitive="no" type="regex" onmatch="score += 1">clinic@yugm\.org</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">lcv@yugm\.org</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">lighthouseshoppe@yugm\.org</expression>
					</expressions>
				</rule>
				<rule result="mark_high">
					<title>Secret phrase</title>
					<comment>Secret phrase to force email to be accepted unconditionally. Any email containing one of these phrases will be accepted.</comment>
					<scope>
						<header>all</header>
					</scope>
					<expressions oninit="score=0" logic="return score > 0">
						<expression casesensitive="no" type="regex" onmatch="score += 1" comment="Secret phrase or word">prayer</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1" comment="Secret phrase or word">\[accept\]</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1" comment="Secret phrase or word">\[AGRM-LIST\]</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1" comment="Secret phrase or word">\[DEVELOPMENT\]</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1" comment="Secret phrase or word">board meeting</expression>
					</expressions>
				</rule>
				<rule result="mark">
					<title>Whitelist MAIL FROM</title>
					<comment>Allow all email from these addresses</comment>
					<scope>
						<mailfrom>all</mailfrom>
					</scope>
		<expressions oninit="score=0" logic="return score > 0">
	<expression casesensitive="no" type="regex" onmatch="score += 1">zyxxxyz</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">register4less\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">pc@max\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">Dave\.Benefiel@avenuea-razorfish\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">bcms@auna\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ssg2359@comcast\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">HavenatYakima@aol\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ericstoothoff@charter\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">gbliss@blisspages\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">teresa@thehomestead\.info</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">mopar@gorge\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">jodi_sargent81@yahoo\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">johnhatfield@comcast\.net></expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">jonathan@zav\.om\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">martinlopez1957@msn\.co</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ericstoothoff@charter\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">familiesnorthwest\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">diersinc\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">envelopeconverting\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">pastordennis@yakimatbc\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">digitalriver\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">xpedx\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ipaper\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">danieleburrow@yahoo\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">hsabank\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">FloydPeg@aol\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">f-prot\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">\bugm\.org\b</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">patricia_2005@earthlink\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">Christloves9@aol\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">timelesstexts\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">pat dodd</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">rescuecollege\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">chris@servantchurch\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">digikey\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">Christloves9@aol\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">nsadownick@bellintl\.ca</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">abbotts\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">accs\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">biblestudylessons\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">billygraham\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">chaplainjim</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">christianbook\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">culver@spiritone\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">danieleburrow@earthlink\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">designedhometheater\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">desiringgod\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">editpadpro\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">editwrx\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">feinsteinfoundation\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">fern@rockisland\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ga\.wa\.gov</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">goldwinggadgets\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">gospelway\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">griff208@charter\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">hp\.com</expression>regexbuddy.com
	<expression casesensitive="no" type="regex" onmatch="score += 1">hrcaerica@hm\.honda\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">icewarp\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">charter\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">Linda@pedersonbros\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">lindsund@comcast\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">lists.cciusa\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">lists.gospelcom\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">lmhsoft\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">lynnnathe@msn\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">martinlopez1957@msn\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">mcafee\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">mikeeclark@hotmail\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">nwinfo\.net</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">online-bible-college\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">onPhilanthropy\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">paypal\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">pilgrim@gracegems\.org</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">raldrich@owt\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">rcpddp@hotmail\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">Register4less\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">rejoyce3@msn\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">reply\.ebay\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">rob@powerviewsystems\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">simpledns\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">sosexchange1</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">ssutton@edcc\.edu</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">taspro6support</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">tharp_m@televar\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">walkintheword\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">weightwatchers\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score += 1">xecute\.com</expression>
	<expression casesensitive="no" type="regex" onmatch="score -= 1">service@paypal\.com</expression>
		</expressions>
				</rule>
				<rule result="mark">
					<title>Whitelist RCPT TO</title>
					<comment>Allow all email from these addresses (can be used to effectively disable filtering to specific users/domains, though the index is a better way to do this</comment>
					<scope>
						<rcptto>all</rcptto>
					</scope>
					<expressions oninit="score=0" logic="return score > 0">
					</expressions>
				</rule>
				<rule result="mark">
					<title>Whitelist body</title>
					<comment>Whitelist based on these expressions being in the body of an email</comment>
					<scope>
						<body>all</body>
					</scope>
					<expressions oninit="score=0" logic="return score > 0">
			<expression casesensitive="no" type="regex" onmatch="score += 1">EVHS1985</expression>
					</expressions>
				</rule>
			</rules>
		</filter>
		<filter name="secondary">
			<log>
				<option type="match true" />
				<option type="rules with match" />
				<option type="execution" />
			</log>
			<results default="accept">
				<result key="accept">
					<return>0</return>
					<copy enabled="no" createdir="no">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;accept&quot;,&quot;default&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="yes">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
				</result>
				<result key="mark">
					<return>0</return>
					<copy enabled="no" createdir="yes">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;mark&quot;,&quot;whitelist&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="yes">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
					<modifysource enabled="yes">
					  <header enabled="yes" action="add" item="X-RegEx-Filter" value="regex_whitelist.xml" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-Title" value="{result:rule:title}" comment="Not yet implemented" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-UID" value="{result:rule:uid}" comment="Not yet implemented" />
					</modifysource>
				</result>
				<result key="mark_high">
					<return>0</return>
					<copy enabled="no" createdir="yes">c:\regexflt\accepted\{yyyy}-{mm}\{smtp:rcpt_to_domain}\{smtp:rcpt_to_mailbox}\{source:filename}{smtp:recipient_id}.txt</copy>
					<copy enabled="no" operation="append" mail="no" append="&quot;{smtp:client_ip}&quot;,&quot;{smtp:helo}&quot;,&quot;{smtp:mail_from}&quot;,&quot;{smtp:rcpt_to}&quot;,&quot;{mm}/{dd}/{yyyy} {HH}:{MM}:{SS}&quot;,&quot;{smtp:mail_from_mailbox}&quot;,&quot;{smtp:mail_from_domain}&quot;,&quot;{smtp:rcpt_to_mailbox}&quot;,&quot;{smtp:rcpt_to_domain}&quot;,&quot;mark_high&quot;,&quot;whitelist&quot;,&quot;c:\\regexflt\\accepted\\{yyyy}-{mm}\\{smtp:rcpt_to_domain}\\{smtp:rcpt_to_mailbox}\\{source:filename}{smtp:recipient_id}.txt&quot;\r\n">c:\regexflt\accepted\{yyyy}-{mm}\log.txt</copy>
					<imap enabled="no" createdir="yes">c:\Program Files\Merak\mail\2150.com\rejectedmail\RegEx Accepted\{source:filename}{smtp:recipient_id}.imap</imap>
					<http enabled="no">[URL unfurl="true"]http://localhost/2150/regexflt_test.asp</http>[/URL]
					<modifysource enabled="yes">
					  <header enabled="yes" action="add" item="X-RegEx-Filter" value="regex_whitelist.xml" />
					  <header enabled="yes" action="replaceoradd" item="Importance" value="High" />
					  <header enabled="yes" action="replaceoradd" item="X-Priority" value="1 (Highest)" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-Title" value="{result:rule:title}" comment="Not yet implemented" />
					  <header enabled="no" action="add" item="X-RegEx-Filter-UID" value="{result:rule:uid}" comment="Not yet implemented" />
					</modifysource>
				</result>
			</results>
			<parser>
				<maxlines>1000</maxlines>
				<maxbuffer>10000</maxbuffer>
				<quickresult>yes</quickresult>
			</parser>
			<rules>
				<rule result="mark">
					<title>Whitelist subject</title>
					<comment>Exclude subject lines with a date at the end or with "order"/"confirm"/"reservation" in them to catch online orders and reservations that append an order # that otherwise would flag immediately as SPAM.</comment>
					<scope>
						<header>all</header>
					</scope>
					<expressions oninit="score=0" logic="return score > 0">
						<expression casesensitive="no" type="regex" onmatch="score -= 10" comment="If viagra is in the subject, don't allow whitelist subjects to work">^subject:.+\bv[iI1]agra\b</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Exclude any from address with 'advize'">^from:.+advize</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Exclude any subject with 'debt'">^subject:.+debt</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it starts with 'you can'">^subject:.+\byou can order\b</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'diet'">^subject:.+\bdiet</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'drugs'">^subject:.+\bdrugs</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'log in'">^subject:.+\blog +in</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'medication'">^subject:.+\bmedication</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'meds'">^subject:.+\bmeds</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'offer confirmation'">^subject:.+\boffer +confirmation</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'order approved'">^subject:.+\border +approved</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'penis'">^subject:.+pen[iIl1]s</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'porno'">^subject:.+p[oO0]rn[oO0]</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'virgin'">^subject:.+\bv[iI1]rg[iI1]n</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'waiting on your'">^subject:.+\bwaiting +on +your</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'we want'">^subject:.+\bwe +want</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'xanax'">^subject:.+\bxanax</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'order' if it has 'you can order'">^subject:.+\byou +can +order</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">^subject:.+\border\b</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'confirm' if it has 'your information'">^subject:.+\byour +information</expression>
						<expression casesensitive="no" type="regex" onmatch="score -= 1" comment="Don't whitelist based on 'confirm' if it has 'as seen on">^subject:.+\bas +seen +on</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">^subject:.+\bconfirmation</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">^subject:.+\breservation</expression>
						<expression casesensitive="no" type="regex" onmatch="score += 1">^subject:.+\bshipment</expression>
					</expressions>
				</rule>
			</rules>
		</filter>
	</filters>
</configuration>
 
In the form above, I forgot to change back the first three input fields to "hidden." - Details.

Brian
 
Haven't done any Perl for ages and its not installed on my webserver, but I gave it a go. Tidied up the HTML and made it more standards compliant:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
  <head>
    <title>Enter the title of your XHTML document here</title>
    <style type="text/css">
body {
  margin : 0px 0px 0px 0px;
}
#left {
  float: left;
  width: 10%;
  height: 100%;
  background-color: gray;
}
#main {
  float: left;
  padding: 10px;
}
#main h1 {
  text-align: center;
  font-size: small;
}
.center {
  text-align: center;
}  
    </style>
  </head>
  <body>
    <div id="left">&#160;</div>
    <div id="main">
      <h1>Whitelist Editor</h1>
      <form action="c:\program files\apache group\apache\cgi-bin\whitelist_editor.cgi" method="post">
        <p>This page can be used to add email addresses to the "WHITELIST"</p>
        <p>
          <strong>Each address must be added one at a time.</strong>
        </p>
        <p>
          <label for="email">Email Address:</label>
          <input id="email" type="text" name="email" />
        </p>
        <p class="center">
          <input type="submit" value="Add Address" />
        </p>
      </form>
    </div>
  </body>
</html>
Perl (untested and probably requiring tweaking):
Code:
#!/usr/bin/perl

# The following accepts the data from the form and splits it into its component parts

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	
@pairs = split(/&/, $buffer);
	
foreach $pair (@pairs) {
	($name, $value) = split(/=/, $pair);
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$FORM{$name} = $value;
}

# Read XML file to array of strings

$xml_file="MyXML.xml";
open(XML, $xml_file) || die("Could not open file!");
@xml=<XML>;
close(XML);

# Write XML back to file, adding email

open(XML,">>$xml_file") || die("Cannot Open File");
foreach $line (@xml) {
	print XML $line;
	if ($line == "<expression casesensitive=\"no\" type=\"regex\" onmatch=\"score += 1\">zyxxxyz</expression>") {
		print XML "<expression casesensitive=\"no\" type=\"regex\" onmatch=\"score += 1\">$FORM{email}</expression>"
	}
}
close(XML);

# Write the thank you page

print "Content-type: text/html\n\n";

print <<EndStart;

	<html>
	<head>
	<title>Thank You</title>
	</head>
	
	<body bgcolor="#ffffff" text="#000000">
	
	<h1>Thank You</h1>
	
	<p>Your email address has been stored.</p>
	
	</body>
	</html>

EndStart

Jon

"I don't regret this, but I both rue and lament it.
 
Thank y9ou very much, Jon,

I'll give it a try and let you know how you did. And I'll study it for my own benefit.

Brian
 
Jon,

I did not change any part of the form. But it does nothing. When an email address is entered, and the submit button clicked - nothing happens. I have checked the Apache logs and see no action.

Here is the script with the change in the shebang line and my entry of the location of the xml file.

Does the form look right to you with another examination??

Thanks again for your help - I deeply appreciate it.

Brian


Code:
#!c:\perl\bin\perl.exe

# The following accepts the data from the form and splits it into its component parts

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    
@pairs = split(/&/, $buffer);
    
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}

# Read XML file to array of strings

$xml_file="c:\program files\merak\whitelist_test.xml";
open(XML, $xml_file) || die("Could not open file!");
@xml=<XML>;
close(XML);

# Write XML back to file, adding email

open(XML,">>$xml_file") || die("Cannot Open File");
foreach $line (@xml) {
    print XML $line;
    if ($line == "<expression casesensitive=\"no\" type=\"regex\" onmatch=\"score += 1\">zyxxxyz</expression>") {
        print XML "<expression casesensitive=\"no\" type=\"regex\" onmatch=\"score += 1\">$FORM{email}</expression>"
    }
}
close(XML);

# Write the thank you page

print "Content-type: text/html\n\n";

print <<EndStart;

    <html>
    <head>
    <title>Thank You</title>
    </head>
    
    <body bgcolor="#ffffff" text="#000000">
    
    <h1>Thank You</h1>
    
    <p>Your email address has been stored.</p>
    
    </body>
    </html>

EndStart
 
I can't test the Perl cos I don't have it installed (could do an ASP page that works). The form action needs to be pointing correctly to the cgi file. To be sure, put them both in the same directory (cgi-bin) and change form action to:
Code:
<form action="whitelist_editor.cgi" method="post">

Jon

"I don't regret this, but I both rue and lament it.
 
The html form is now in the cgi-bin folder and the call line changed as you said. I see, very briefly, the "downolad file" dialog box pop up now with its progress bar. (seen that before during tests with the previous script) I don't know why that dialog comes up.

No return of html is made as per the script, nor does any change in the xml occour.

I know nothing about asp, and should probably not attempt it unless someone is willing to provide me with a lot more assistance. And just getting this far asking for help has been a trial.

I have been asking for the same kind of help on the Perl board here, and gotten way less play. Seems like such a complicated set of requirements, that no one can figure it out. (I jest, of course)

Like I said elsewhere, I'd offer money, but can't find a taker on that offer either. Phooey.

Thanks as before,

Brian

 
Are you sure Perl is set up properly on your webserver? Have you got a perl script to run? Try basic hello world script:
Code:
#!c:\perl\bin\perl.exe

print "Hello, world!\n";
Can you run ASP scripts? If you can, that would probably be easier as I can test them.

Jon

"I don't regret this, but I both rue and lament it.
 
Perl is set up properly and I do have several other scripts that run well.

I'll have to try to learn something about ASP. I don't know anything about it and have no idea if I can run something using it or not.

I'll let you know.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top