<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>North Atlanta Web Design &#187; Class</title>
	<atom:link href="https://www.northatlantawebdesign.com/index.php/tag/class/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.northatlantawebdesign.com</link>
	<description>Programming Examples, Samples, and Tutorials</description>
	<lastBuildDate>Mon, 15 Aug 2011 20:18:35 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.41</generator>
	<item>
		<title>VBScript String Methods in a Simple PHP Class</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/08/24/vbscript-string-methods-in-a-simple-php-class/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/08/24/vbscript-string-methods-in-a-simple-php-class/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 20:42:52 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[Wrapper]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=172</guid>
		<description><![CDATA[When some people start out in a new language, they are in it for the long haul.  Other people sometimes just need to touch on it without getting into the details.  PHP is one of those languages where you can do things in a quick and dirty way without getting into the details.  I have [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>When some people start out in a new language, they are in it for the long haul.  Other people sometimes just need to touch on it without getting into the details.  <a type="amzn">PHP</a> is one of those languages where you can do things in a quick and dirty way without getting into the details.  I have written a simple class for the kind of person that just wants to get a few things done quickly that is familiar with VBScripting.  The class is mainly a wrapper class that allows you to perform <a type="amzn">VBScript</a> style methods on strings in PHP.  For instance, you can use VBScript::Left($string, $length) instead of using PHP&#8217;s substr($string, 0, $length).  Enjoy!<br />
<span id="more-172"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*****************************************************************************\
Author: Jeff Gibeau
WebSite: http://www.NorthAtlantaWebDesign.com
Purpose:
A string operation wrapper class that allows you to use VBScript style methods
in place of PHP style methods.  Recreates all methods from:

http://www.w3schools.com/VBscript/vbscript_ref_functions.asp#string

\*****************************************************************************/
class VBString
{
	//Returns the position of the first occurrence of one string within another.
	//The search begins at the first character of the string.
	function InStr($haystack, $needle, $startPosition = 0)
	{
		return strpos($haystack, $needle, $startPosition);
	}
	
	//Returns the position of the first occurrence of one string within another.
	//The search begins at the last character of the string.
	function InStrRev($haystack, $needle, $startPosition = 0)
	{
		if(floatval(phpversion()) &gt;= 5)
			return strrpos($haystack, $needle, $startPosition);
		else
			return strrpos($haystack, $needle);
	}
	
	//Converts a specified string to lowercase.
	function LCase($string)
	{
		return strtolower($string);
	}
	
	//Returns a specified number of characters from the left side of a string.
	function Left($string, $length)
	{
		return substr($string, 0, $length);
	}
	
	//Returns the number of characters in a string.
	function Len($string)
	{
		return strlen($string);
	}
	
	//Removes spaces on the left side of a string.
	function LTrim($string)
	{
		return ltrim($string);
	}
	
	//Removes spaces on the right side of a string.
	function RTrim($string)
	{
		return rtrim($string);
	}
	
	//Removes spaces on both the left and the right side of a string.
	function Trim($string)
	{
		return trim($string);
	}
	
	//Returns a specified number of characters from a string.
	function Mid($string, $start, $length = &quot;&quot;)
	{
		if(!empty($length))
			return substr($string, $start, $length);
		else
			return substr($string, $start);
	}
	
	//Replaces a specified part of a string with another string a specified
	//number of times.
	function Replace($haystack, $needle, $replaceWith, $start = -1, $count = -1)
	{
		$returnVal = $haystack;
		if($start != -1)
		{
			if($count != -1 &amp;&amp; floatval(phpversion()) &gt;= 5)
			{
				$returnVal = substr($haystack, 0, $start) . str_replace($needle, $replaceWith, substr($haystack, $start), $count);
			}
			else
			{
				$returnVal = substr($haystack, 0, $start) . str_replace($needle, $replaceWith, substr($haystack, $start));
			}
		}
		else
		{
			if($count != -1 &amp;&amp; floatval(phpversion()) &gt;= 5)
			{
				$returnVal = str_replace($needle, $replaceWith, $haystack, $count);
			}
			else
			{
				$returnVal = str_replace($needle, $replaceWith, $haystack);
			}
		}
		return $returnVal;
	}
	
	//Returns a specified number of characters from the right side of a string.
	function Right($string, $count)
	{
		return substr($string, ($count * -1));
	}
	
	//Returns a string that consists of a specified number of spaces.
	function Space($numSpaces)
	{
		$returnVal = '';
		for($i = 0; $i &lt; $numSpaces; $i++)
			$returnVal .= ' ';
		return $returnVal;
	}
	
	//Compares two strings and returns a value that represents the result of
	//the comparison.
	function StrComp($string1, $string2)
	{
		return strcmp($string1, $string2);
	}
	
	//Returns a string that contains a repeating character of a specified length.
	function String($length, $character)
	{
		$returnVal = '';
		while(strlen($returnVal) &lt; $length)
			$returnVal .= $character;
		return substr($returnVal, 0, $length);
	}
	
	//Reverses a string.
	function StrReverse($string)
	{
		return strrev($string);
	}
	
	//Converts a specified string to uppercase.
	function UCase($string)
	{
		return strtoupper($string);
	}
}
?&gt;
</pre>
<p>Using this class</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require_once 'vbstring_class.php';
$string1 = '  The quick brown fox jumped over the lazy dog.  ';
$string2 = 'he';
$string3 = 'hat';
$nl = &quot;\n&quot;;
echo '
&lt;style&gt;
* { font-family:courier; }
span.answer { color:red; background:#eeeeee;border:1px solid #ccc; }
&lt;/style&gt;
&lt;pre&gt;
';
//VBString::InStr
echo 'VBString::InStr(&quot;'.$string1.'&quot;, &quot;'.$string2.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;'. VBString::InStr($string1, $string2).'&lt;/span&gt;'.$nl;

//VBString::InStrRev
echo 'VBString::InStrRev(&quot;'.$string1.'&quot;, &quot;'.$string2.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;'. VBString::InStrRev($string1, $string2).'&lt;/span&gt;'.$nl;

//VBString::LCase
echo 'VBString::LCase(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'. VBString::LCase($string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::Left
echo 'VBString::Left(&quot;'.$string1.'&quot;, 5) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Left($string1, 5).'&quot;&lt;/span&gt;'.$nl;

//VBString::Len
echo 'VBString::Len(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;'.VBString::Len($string1).'&lt;/span&gt;'.$nl;

//VBString::LTrim
echo 'VBString::LTrim(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::LTrim($string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::RTrim
echo 'VBString::RTrim(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::RTrim($string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::Trim
echo 'VBString::Trim(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Trim($string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::Mid
echo 'VBString::Mid(&quot;'.$string1.'&quot;, 5, 5) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Mid($string1, 5, 5).'&quot;&lt;/span&gt;'.$nl;

//VBString::Replace
echo 'VBString::Replace(&quot;'.$string1.'&quot;, &quot;'.$string2.'&quot;, &quot;'.$string3.'&quot;, 5) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Replace($string1, $string2, $string3, 5).'&quot;&lt;/span&gt;'.$nl;

//VBString::Right
echo 'VBString::Right(&quot;'.$string1.'&quot;, 5) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Right($string1, 5).'&quot;&lt;/span&gt;'.$nl;

//VBString::Space
echo 'VBString::Space(10) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::Space(10).'&quot;&lt;/span&gt;'.$nl;

//VBString::StrComp
echo 'VBString::StrComp(&quot;'.$string1.'&quot;, &quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::StrComp($string1, $string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::String
echo 'VBString::String(10, &quot;*&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::String(10, &quot;*&quot;).'&quot;&lt;/span&gt;'.$nl;

//VBString::StrReverse
echo 'VBString::StrReverse(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'.VBString::StrReverse($string1).'&quot;&lt;/span&gt;'.$nl;

//VBString::UCase
echo 'VBString::UCase(&quot;'.$string1.'&quot;) -&gt; &lt;span class=&quot;answer&quot;&gt;&quot;'. VBString::UCase($string1).'&quot;&lt;/span&gt;'.$nl;

echo '&lt;/pre&gt;';
?&gt;
</pre>
<p>Useful Links:</p>
<ul>
<li><a href="http://www.w3schools.com/VBscript/vbscript_ref_functions.asp#string">W3Schools VBScript String Methods</a></li>
<li><a href="http://us2.php.net/manual/en/book.strings.php">PHP Strings Manual</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/08/24/vbscript-string-methods-in-a-simple-php-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy to use, yet powerful PHP E-mail Class</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/07/21/easy-to-use-yet-powerful-php-e-mail-class/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/07/21/easy-to-use-yet-powerful-php-e-mail-class/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 15:34:33 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[E-mail]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[email class]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=111</guid>
		<description><![CDATA[This is a pretty robust PHP Email class that I wrote a few years back. Has the capability to do text or html e-mails with multiple attachments. Enjoy! Usage Examples: Useful Links: PHP Quick Reference]]></description>
				<content:encoded><![CDATA[<p>This is a pretty robust PHP Email class that I wrote a few years back.  Has the capability to do text or html e-mails with multiple attachments.  Enjoy!<br />
<span id="more-111"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/******************************************************************************\
--
--	Class Name: eMail
--		Purpose: Handles various aspects of sending/generating e-mails in PHP.
--		Current Capabilities:
			- Allows multiple &quot;To&quot; recipients
			- Allows multiple &quot;Cc&quot; recipients
			- Allows multiple &quot;Bcc&quot; recipients
			- Allows &quot;From&quot; header to be modified
			- Allows &quot;Sender&quot; header to be modified
			- Allows &quot;Content-Type&quot; for text or html
			- Allows for multiple attachments
			- Checks e-mail addresses via regular expressions to verify they
				will not cause errors
			-
--
\******************************************************************************/


	//Define class
class eMail {

/******************************************************************************\
--
--	User Specific Variables
--		Purpose: Variables which should/may be modified by the user.  This
--			defines defaults used in the program that can be changed later.
--
\******************************************************************************/
	//Set Default Variables
	var $replyTo = 'System &lt;system@example.com&gt;';	//Default reply address
	var $from = 'System &lt;system@example.com&gt;';		//Default From address
	var $sender = 'System &lt;system@example.com&gt;';	//Default Sender address
	var $isHTML = false;				//False sends e-mail in plain text by default
	var $nl = &quot;\n&quot;;						// New Line character, either \r\n or \n


/******************************************************************************\
--
--	Constant variables
--		Purpose: The constant variables should not be changed/modified unless
--			you know what you are messing with.
--
\******************************************************************************/
	//Constants
	var $errors = null;				//Array to hold any errors which may occur
	var $attachments = null;		//Array to hold attachments
 	var $mime_boundary = null;		//boundary set for using attachments
	var $to = null;					//Array to hold recipients
	var $cc = null;					//Array to hold recipients
	var $bcc = null;				//Array to hold recipients
	var $header = null;				//Header used to send e-mail
	var $subject = null;			//Subject of the e-mail
	var $body = null;				//Message portion of the e-mail
	var $message = null;			//used to build message when mail is sent


/******************************************************************************\
--
--	Regular Expressions
--		Purpose: Used in error checking e-mail addresses and various parts of
--			the emails.
--
\******************************************************************************/

 	//Regular Expressions for Error Checking
		//Email address with no name attached
	var $regex_email = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
		//Email address with name attached
	var $regex_email2 = '^([\._A-Za-z0-9-]+[ ]+)+[&lt;][_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+[&gt;]$';
 		//Regular Expression for limiting body of message
 	var $regex_body = '^.*$';
 		//Regular Expression for limiting subject of message
 	var $regex_subject = '^.+$';


/******************************************************************************\
--
--	User Functions
--		Purpose: Allows user to add recipients, attachments, body, subject,etc.
--
\******************************************************************************/

		//Class Constructor, automatically called when a new object is created
	function eMail(){}

		//Adds a recipient for the e-mail
	function addTo($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;to[sizeOf($this-&gt;to)] = $email_addr;
			return true;
		} else{
			return false;
		}
	}

		//Adds a Carbon Copy address for the e-mail
	function addCC($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;cc[sizeOf($this-&gt;cc)] = $email_addr;
			return true;
		} else{
			return false;
		}
	}

		//Adds a Blind Carbon Copy address for the e-mail
	function addBCC($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;bcc[sizeOf($this-&gt;bcc)] = $email_addr;
			return true;
		} else{
			return false;
		}
	}

		//Sets the from header for the e-mail
	function setFrom($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;from = $email_addr;
			return true;
		} else{
			$this-&gt;addError(&quot;Invalid Format for FROM e-mail address&quot;);
			return false;
		}
	}

		//Sets the ReplyTo header for the e-mail
	function setReplyTo($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;replyTo = $email_addr;
			return true;
		} else{
			$this-&gt;addError(&quot;Invalid Format for ReplyTo e-mail address&quot;);
			return false;
		}
	}

		//Sets the Sender header for the e-mail
	function setSender($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;replyTo = $email_addr;
			return true;
		} else{
			$this-&gt;addError(&quot;Invalid Format for Sender e-mail address&quot;);
			return false;
		}
	}

		//Sets the From, ReplyTo, and Sender header with one e-mail
	function setSenderInfo($email_addr){
		$email_addr = $this-&gt;clean_email($email_addr);
		if($this-&gt;verify_email($email_addr)){
			$this-&gt;replyTo = $email_addr;
			$this-&gt;sender = $email_addr;
			$this-&gt;from = $email_addr;
			return true;
		} else{
			$this-&gt;addError(&quot;Invalid Format for From, Sender, and ReplyTo e-mail addresses&quot;);
			return false;
		}
	}

		//Sets the subject of the e-mail and verifies that all characters are allowed
	function setSubject($subjectIn){
		if($this-&gt;verify_subject($subjectIn)){
			$this-&gt;subject = $subjectIn;
			return true;
		} else{
			return false;
		}
	}

		//Sets the body of the e-mail and verifies that all characters in the body is allowed
	function setBody($bodyIn, $html_flag = false){
		$this-&gt;isHTML = $html_flag;
		if($this-&gt;verify_body($bodyIn)){
			$this-&gt;body = $bodyIn;
			return true;
		} else{
			return false;
		}
	}

		//Adds an attachment to be sent with the email
	function addAttachment($fileData, $fileName = &quot;unknown&quot;, $fileType = &quot;&quot;){
		$currSize = sizeOf($this-&gt;attachments);
		$this-&gt;attachments[$currSize][0] = $fileData;
		$this-&gt;attachments[$currSize][1] = $fileName;
		$this-&gt;attachments[$currSize][2] = $fileType;
	}



/******************************************************************************\
--
--	Send Mail Function
--		Purpose: Sends the e-mail after everything is setup.
--
\******************************************************************************/
		//Sets the mail headers for HTML, generates all the e-mail parameters and sends it
	function sendMail(){
			//Check body content via regular expression
		$this-&gt;verify_body($this-&gt;body);
			//Check subject content via regular expression
		$this-&gt;verify_subject($this-&gt;subject);

			//Verify at least on &quot;To&quot;,&quot;Cc&quot;, or &quot;Bcc&quot; address is contained
		if($this-&gt;to==null &amp;&amp; $this-&gt;cc==null &amp;&amp; $this-&gt;bcc==null){
			$this-&gt;addError(&quot;E-mail must contain at least one \&quot;To\&quot;,\&quot;Cc\&quot;, or \&quot;Bcc\&quot; address&quot;);
		}

			//Begin to build the header
		$this-&gt;header = &quot;&quot;;
			//Set a MIME-version
		$this-&gt;header .= &quot;MIME-version: 1.0&quot; . $this-&gt;nl;

			//Setup Sender, From, Bcc, CC, and ReplyTo regardless of mail format
		$this-&gt;replyTo = $this-&gt;clean_email($this-&gt;replyTo);
		if($this-&gt;replyTo != null){
			if($this-&gt;verify_email($this-&gt;replyTo)){
				$this-&gt;header .= &quot;Reply-To: $this-&gt;replyTo&quot; . $this-&gt;nl;
			} else{
				$this-&gt;addError(&quot;Invalid Reply-To Header: $this-&gt;replyTo&quot;);
			}
		}

			//Setup sender
		$this-&gt;sender = $this-&gt;clean_email($this-&gt;sender);
		if($this-&gt;sender != null){
			if($this-&gt;verify_email($this-&gt;sender)){
				$this-&gt;header .= &quot;Sender: $this-&gt;sender&quot; . $this-&gt;nl;
			} else{
				$this-&gt;addError(&quot;Invalid Sender Header: $this-&gt;sender&quot;);
			}
		}

			//Setup from
		$this-&gt;from = $this-&gt;clean_email($this-&gt;from);
		if($this-&gt;from != null){
			if($this-&gt;verify_email($this-&gt;from)){
				$this-&gt;header .= &quot;From: $this-&gt;from&quot; . $this-&gt;nl;
			} else{
				$this-&gt;addError(&quot;Invalid From Header: $this-&gt;from&quot;);
			}
		}

			//Verify all addresses in cc
		if($this-&gt;cc!=null){
			foreach($this-&gt;cc as $email_addr){
				$email_addr = $this-&gt;clean_email($email_addr);
				$this-&gt;verify_email($email_addr);
				$email_addr = $email_addr;
				$this-&gt;header .= &quot;Cc: $email_addr&quot; . $this-&gt;nl;
			}
		}

			//Verify all addresses in bcc
		if($this-&gt;bcc != null){
			foreach($this-&gt;bcc as $email_addr){
				$email_addr = $this-&gt;clean_email($email_addr);
				$this-&gt;verify_email($email_addr);
				$email_addr = $email_addr;
				$this-&gt;header .= &quot;Bcc: $email_addr&quot; . $this-&gt;nl;
			}
		}
			//If contains attachments, generate mail with multiple parts
		if($this-&gt;attachments!=null){
				//Generate a boundary to separate the message body
				//  and attachments
			$this-&gt;mime_boundary = &quot;==Multipart_Boundary_x{&quot;.md5(time()).&quot;}x&quot;;

				//Set Content type to multipart for attachments
			$this-&gt;header .= &quot;Content-type: multipart/mixed;&quot; . $this-&gt;nl;
				//Put boundary in header of e-mail
			$this-&gt;header .= &quot; boundary=\&quot;{$this-&gt;mime_boundary}\&quot;&quot;;

				//Setup the boundary for the body content
            $this-&gt;message .= &quot;--{$this-&gt;mime_boundary}&quot; . $this-&gt;nl;

				//If html set content type to that in message, else plain text
			if($this-&gt;isHTML){
	            $this-&gt;message .= &quot;Content-Type: text/html; charset=ISO-8859-1&quot; . $this-&gt;nl;
			} else{
				$this-&gt;message .= &quot;Content-type: text/plain; charset=ISO-8859-1&quot; . $this-&gt;nl;
			}
				//Set transfer encoding
			$this-&gt;message .= &quot;Content-Transfer-Encoding: 7bit&quot; . $this-&gt;nl . $this-&gt;nl;

				//Add the body to the message
			$this-&gt;message .= $this-&gt;body . $this-&gt;nl . $this-&gt;nl;

				//Add attachments
			for($i=0;$i&lt;sizeOf($this-&gt;attachments);$i++){
					//Put boundary before each attachment
				$this-&gt;message .= &quot;--{$this-&gt;mime_boundary}&quot; . $this-&gt;nl;
					//Set content type of attachment
				$this-&gt;message .= &quot;Content-Type: {$this-&gt;attachments[$i][2]};&quot; . $this-&gt;nl;
					//Set name for the attachment
				$this-&gt;message .= &quot; name=\&quot;&quot;.$this-&gt;attachments[$i][1].&quot;\&quot;&quot; . $this-&gt;nl;
					//Let message know this is an attachment
				$this-&gt;message .= &quot;Content-Disposition: attachment;&quot; . $this-&gt;nl;
					//Set filename for the attachment
				$this-&gt;message .= &quot; filename=\&quot;&quot;.$this-&gt;attachments[$i][1].&quot;\&quot;&quot; . $this-&gt;nl;
					//Set to base64 content encoding
				$this-&gt;message .= &quot;Content-Transfer-Encoding: base64&quot; . $this-&gt;nl . $this-&gt;nl;
					//Add attachment and encode to base64
				$this-&gt;message .= chunk_split(base64_encode($this-&gt;attachments[$i][0])) . $this-&gt;nl;
			}
				//Close off attachments
			$this-&gt;message .= &quot;--{$this-&gt;mime_boundary}--&quot; . $this-&gt;nl . $this-&gt;nl;
		}
			//Does not contain attachments, generate mail normally
		else {
				//If html set header to define it
			if($this-&gt;isHTML){
				$this-&gt;header .= &quot;Content-type: text/html; charset=iso-8859-1&quot; . $this-&gt;nl;
			} else{
				$this-&gt;header .= &quot;Content-type: text/plain; charset=ISO-8859-1&quot; . $this-&gt;nl;
			}
				//Add body to the message
			$this-&gt;message = $this-&gt;body;
		}

			//Generate To: recipients
			$to_string = &quot;&quot;;
		if($this-&gt;to!=null){
			$this-&gt;count=0;
			foreach($this-&gt;to as $email_addr){
				$email_addr = $this-&gt;clean_email($email_addr);
				if($this-&gt;verify_email($email_addr)){
					if($this-&gt;count&gt;0){
						$to_string .= ', ';
					}
					$to_string .= $email_addr;
					$this-&gt;count++;
				}
			}
		}
			//If an error has occurred, do not send the message and return the last error
		if($this-&gt;errors!=null){
			return false;
		} else{
				//Close off the header of the message
			$this-&gt;header .= $this-&gt;nl;
				//Send the message
			return mail($to_string, $this-&gt;subject, $this-&gt;message, $this-&gt;header);
		}
	}

/******************************************************************************\
--
--	Error Functions
--		Purpose: Internal functions to store errors and public ones to retrieve
--			them.
--
\******************************************************************************/
		//Returns the array of errors
	function getErrors(){
		return $this-&gt;errors;
	}

		//Returns only the last error which was logged
	function getLastError(){
		if($this-&gt;errors!=null){
			return $this-&gt;errors[sizeOf($this-&gt;errors)-1];
		} else {
			return false;
		}
	}

		//Adds an error to the error array
	function addError($errorIn){
		$this-&gt;errors[sizeOf($this-&gt;errors)] = $errorIn;
	}

/******************************************************************************\
--
--	Message Compilation Functions
--		Purpose: Functions which return different components of the message
--
\******************************************************************************/
		//Returns the message header
	function getHeader(){
		return $this-&gt;header;
	}

		//Returns the message contents, not generated until after mail is sent
	function getMessage(){
		return $this-&gt;message;
	}

		//Returns the body portion of the e-mail
	function getBody(){
		return $this-&gt;body;
	}

/******************************************************************************\
--
--	Error Checking/Cleansing Functions
--		Purpose: Functions to remove common errors from input and to verify
--			different portions of the message with regular expressions
--
\******************************************************************************/
		//Removes e-mail addresses of commas and semi-colons which may cause
		// problems in the message headers
	function clean_email($email_addr){
		if($email_addr!=null){
			$email_addr = str_replace(&quot;,&quot;,&quot; &quot;,$email_addr);
			$email_addr = str_replace(&quot;;&quot;,&quot; &quot;,$email_addr);
		}
		return $email_addr;
	}

		//Verifies that e-mail addresses in arguments match one form of
		// e-mail via regular expressions
	function verify_email($email_addr){
		if (eregi($this-&gt;regex_email, $email_addr)) return true;
		else if (eregi($this-&gt;regex_email2, $email_addr)) return true;
		else {
			$this-&gt;addError(&quot;Invalid E-mail Address: $email_addr&quot;);
			return false;
		}
	}

		//Verifies that the body portion of message matches a given
		// regular expression.  Nice for setting a minimum message length.
	function verify_body($body){
		if (eregi($this-&gt;regex_body, $body)) return true;
		else {
			$this-&gt;addError(&quot;Invalid Body Content: $body&quot;);
			return false;
		}
	}

		//Verifies that the subject portion of message matches a given
		// regular expression.  Nice for setting a minimum subject length.
	function verify_subject($subject){
		if (eregi($this-&gt;regex_subject, $subject)) return true;
		else {
			$this-&gt;addError(&quot;Invalid Subject Content: $subject&quot;);
			return false;
		}
	}

/******************************************************************************\
\******************************************************************************/


	//Close Class Definition
}
</pre>
<p>Usage Examples:</p>
<pre class="brush: php; title: ; notranslate">
/******************************************************************************\
--
--	Program Use Examples
--		Purpose: The following are a few examples on using the eMail class in
--			an application.
--
\******************************************************************************/
/******************************************************************************\

Example 1:  Basic Text E-mail
		//Initialize e-mail object
	$email = new eMail();

		//Add a To recipient
	$email-&gt;addTo(&quot;example@example.com&quot;);

		//Add a subject for the e-mail
	$email-&gt;subject = &quot;Test E-mail Subject&quot;;

		//Set the body portion of the e-mail
	$email-&gt;setBody('
	This is a text body in an e-mail.
	Nothing else is required, it can now be sent.
	');

		//Send the e-mail
	$email-&gt;sendMail();

--------------------------------------------------------------------------------

Example 2:  Basic Html E-mail
		//Initialize e-mail object
	$email = new eMail();

		//Add a To recipient
	$email-&gt;addTo(&quot;example@example.com&quot;);

		//Add a subject for the e-mail
	$email-&gt;subject = &quot;Test E-mail Subject&quot;;

		//Set the body portion of the e-mail, setting it to HTML with the
		// second parameter.
	$email-&gt;setBody('
	This is now a html body in an e-mail.&lt;HR&gt;
	Nothing else is required, it can now be sent.
	', true);

		//Send the e-mail
	$email-&gt;sendMail();

--------------------------------------------------------------------------------

Example 3:  Basic Attachment Example with an Html body
		//Initialize e-mail object
	$email = new eMail();

		//Add a To recipient
	$email-&gt;addTo(&quot;example@example.com&quot;);

		//Add a subject for the e-mail
	$email-&gt;subject = &quot;Test E-mail Subject&quot;;

		//Set the body portion of the e-mail, setting it to HTML with the
		// second parameter.
	$email-&gt;setBody('
	This is now a html body in an e-mail.&lt;HR&gt;
	Nothing else is required, it can now be sent.
	', true);

		//Add an attachment to the e-mail
	$email-&gt;addAttachment(&quot;Text in the attachment&quot;,&quot;filename.txt&quot;,&quot;text/plain&quot;);

		//Send the e-mail
	$email-&gt;sendMail();

--------------------------------------------------------------------------------

Example 4:  Multiple Attachments
		//Initialize e-mail object
	$email = new eMail();

		//Add a To recipient
	$email-&gt;addTo(&quot;example@example.com&quot;);

		//Add a subject for the e-mail
	$email-&gt;subject = &quot;Test E-mail Subject&quot;;

		//Set the body portion of the e-mail, setting it to HTML with the
		// second parameter.
	$email-&gt;setBody('
	This is now a html body in an e-mail.&lt;HR&gt;
	Nothing else is required, it can now be sent.
	', true);

		//Attach an html file containing the body of the message
	$email-&gt;addAttachment($email-&gt;body,&quot;email_body.html&quot;,&quot;text/html&quot;);

		//Attach a second file
	$email-&gt;addAttachment(&quot;File Data&quot;,&quot;Attachment01.txt&quot;);

		//Send the e-mail
	$email-&gt;sendMail();

\******************************************************************************/
?&gt;
</pre>
<p>Useful Links:</p>
<ul>
<li><a href="http://www.php.net/quickref.php">PHP Quick Reference</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/07/21/easy-to-use-yet-powerful-php-e-mail-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple VBScript Progress Bar</title>
		<link>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/</link>
		<comments>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 17:26:17 +0000</pubDate>
		<dc:creator><![CDATA[Jeff Gibeau]]></dc:creator>
				<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Progress Bar]]></category>

		<guid isPermaLink="false">http://www.northatlantawebdesign.com/?p=69</guid>
		<description><![CDATA[Recently I had a need for a simple progress bar written in VBScript to let users know what was going on in a multi-step application. To my surprise, VBScript has nothing built in for a progress bar.  After much searching, I was able to find this thread that linked to yet another thread with a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Recently I had a need for a simple progress bar written in <a type="amzn">VBScript</a> to let users know what was going on in a multi-step application.  To my surprise, VBScript has nothing built in for a progress bar.  After much searching, I was able to find <a title="Copy Files with Progress Bar" href="http://www.tek-tips.com/viewthread.cfm?qid=1196550&amp;page=1">this thread</a> that linked to yet <a title="Adding some kind of progress" href="http://www.tek-tips.com/viewthread.cfm?qid=898604">another thread</a> with a simple progress bar done in HTML using InternetExplorer.Application.  I have taken this code and modified it to show an actual progess bar, with percentages, that can be updated as desired.  I&#8217;ve wrapped it up in a nice easy-to-use class for reusability.  Enjoy!</p>
<p><span id="more-69"></span></p>
<div id="attachment_82" style="width: 322px" class="wp-caption aligncenter"><img class="size-full wp-image-82" title="Simple VBScript Progress Bar" src="http://www.northatlantawebdesign.com/wp-content/uploads/2009/07/vbscript_progress_bar.gif" alt="Simple VBScript Progress Bar" width="312" height="99" /><p class="wp-caption-text">Simple VBScript Progress Bar</p></div>
<p>VBScript Progress Bar Class:</p>
<pre class="brush: vb; title: ; notranslate">
Class ProgressBar
Private m_PercentComplete
Private m_CurrentStep
Private m_ProgressBar
Private m_Title
Private m_Text
Private m_StatusBarText

'Initialize defaults
Private Sub ProgessBar_Initialize
m_PercentComplete = 0
m_CurrentStep = 0
m_Title = &quot;Progress&quot;
m_Text = &quot;&quot;
End Sub

Public Function SetTitle(pTitle)
m_Title = pTitle
End Function

Public Function SetText(pText)
m_Text = pText
End Function

Public Function Update(percentComplete)
m_PercentComplete = percentComplete
UpdateProgressBar()
End Function

Public Function Show()
Set m_ProgressBar = CreateObject(&quot;InternetExplorer.Application&quot;)
'in code, the colon acts as a line feed
m_ProgressBar.navigate2 &quot;about:blank&quot; : m_ProgressBar.width = 315 : m_ProgressBar.height = 40 : m_ProgressBar.toolbar = false : m_ProgressBar.menubar = false : m_ProgressBar.statusbar = false : m_ProgressBar.visible = True
m_ProgressBar.document.write &quot;&lt;body Scroll=no style='margin:0px;padding:0px;'&gt;&lt;div style='text-align:center;'&gt;&lt;span name='pc' id='pc'&gt;0&lt;/span&gt;&lt;/div&gt;&quot;
m_ProgressBar.document.write &quot;&lt;div id='statusbar' name='statusbar' style='border:1px solid blue;line-height:10px;height:10px;color:blue;'&gt;&lt;/div&gt;&quot;
m_ProgressBar.document.write &quot;&lt;div style='text-align:center'&gt;&lt;span id='text' name='text'&gt;&lt;/span&gt;&lt;/div&gt;&quot;
End Function

Public Function Close()
m_ProgressBar.quit
m_ProgressBar = Nothing
End Function

Private Function UpdateProgressBar()
If m_PercentComplete = 0 Then
m_StatusBarText = &quot;&quot;
End If
For n = m_CurrentStep to m_PercentComplete - 1
m_StatusBarText = m_StatusBarText &amp; &quot;|&quot;
m_ProgressBar.Document.GetElementById(&quot;statusbar&quot;).InnerHtml = m_StatusBarText
m_ProgressBar.Document.title = n &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;pc&quot;).InnerHtml = n &amp; &quot;% Complete : &quot; &amp; m_Title
wscript.sleep 10
Next
m_ProgressBar.Document.GetElementById(&quot;statusbar&quot;).InnerHtml = m_StatusBarText
m_ProgressBar.Document.title = m_PercentComplete &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;pc&quot;).InnerHtml = m_PercentComplete &amp; &quot;% Complete : &quot; &amp; m_Title
m_ProgressBar.Document.GetElementById(&quot;text&quot;).InnerHtml = m_Text
m_CurrentStep = m_PercentComplete
End Function

End Class
</pre>
<p>Example of Usage:</p>
<pre class="brush: vb; title: ; notranslate">
'Declare progressbar and percentage complete
Dim pb
Dim percentComplete
'Setup the initial progress bar
Set pb = New ProgressBar
percentComplete = 0
pb.SetTitle(&quot;Step 1 of 5&quot;)
pb.SetText(&quot;Copying bin/Debug Folder&quot;)
pb.Show()

'Loop to update the percent complete of the progress bar
'Just add the pb.Update in your code to update the bar
'Text can be updated as well by pb.SetText
Do While percentComplete &lt;= 100
wscript.sleep 500
pb.Update(percentComplete)
percentComplete = percentComplete + 10
Loop
wscript.sleep 3000

'This shows how you can use the code for multiple steps
'In a future iteration I will add a second bar to measure overall progress
percentComplete = 0
pb.SetTitle(&quot;Step 2 of 5&quot;)
pb.SetText(&quot;Copying bin/Release Folder&quot;)
pb.Update(percentComplete)
Do While percentComplete &lt;= 100
wscript.sleep 500
pb.Update(percentComplete)
percentComplete = percentComplete + 10
Loop
pb.Close()
wscript.quit
</pre>
<p>In a future release, I may add another progress bar to keep track of the steps that are completed.  Feel free to use and modify this code as you desire.</p>
<p>Useful Links:</p>
<ul>
<li><a title="Microsoft VBScript Reference" href="http://msdn.microsoft.com/en-us/library/d1wf56tt%28VS.85%29.aspx">Microsoft VBScript Reference</a></li>
<li><a title="W3Schools VBScript Reference" href="http://www.w3schools.com/Vbscript/default.asp">W3Schools VBScript Reference</a></li>
<li><a title="Copy Files with a Progress Bar" href="http://www.tek-tips.com/viewthread.cfm?qid=1196550&amp;page=1">Copy Files with a Progress Bar</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
