<?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>Bohack &#187; Programming</title>
	<atom:link href="http://www.bohack.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bohack.com</link>
	<description>Check In and Tune Out!</description>
	<lastBuildDate>Sun, 08 Jan 2012 20:59:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>A Simple PHP mail() Function For Testing SMTP Delivery</title>
		<link>http://www.bohack.com/2010/01/a-simple-php-mail-function-for-testing-smtp-delivery/</link>
		<comments>http://www.bohack.com/2010/01/a-simple-php-mail-function-for-testing-smtp-delivery/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:05:00 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=385</guid>
		<description><![CDATA[Making sure mail is sent properly from a PHP website is a bit difficult when it’s not your server, like shared hosting. So I created a simple php script called testmail.php that sends mail via the mail() function.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2010/01/a-simple-php-mail-function-for-testing-smtp-delivery/' addthis:title='A Simple PHP mail() Function For Testing SMTP Delivery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Making sure mail is sent properly from a PHP website is a bit difficult when it’s not your server, like shared hosting. You never have access to the mail logs, so you can’t see mail moving. I host several websites on shared hosting and recently found my CMS was not sending emails to me. So I opened a ticket and I concluded it to be a SNAFU.</p>
<p><span id="more-385"></span>I’m never satisfied when I conclude something doesn’t work because it’s complex. The best thing to do is to snap into diagnostic mode. The first rule of diagnosis of the problem is start simple and work from there. The saying of getting to the root of the problem is accurate.</p>
<p>I looked at the CMS code and concluded that the function being called to send mail is the PHP function of mail(). So I needed to check the PHP mail function by itself, without the complexity of the CMS. If the mail() function sends mail, then the problem is the CMS or my email. If the mail() function does not send mail, then my provider has something that they can work with and I can present the problem to them. Simple I created a simple PHP script called testmail.php with this short little string of code:</p>
<pre>&lt;?php
$to = 'youraccount@youremail.com';
$subject = 'Sent on '.date("F j, Y, g:i a");
$message = 'Test message';

mail($to, $subject, $message);
?&gt;
</pre>
<p>This routine will send mail to the $to variable and also tag the date in the subject. This is all done via the sendmail variable in php, you can do a phpinfo() to find which program sends mail. This can be handy if you need to see when it left the other system and came into yours. Just look the original header and you will be able to see all details.</p>
<p>In the end my problem resulted in my SPAM filter catching the email thus never showing up in the Inbox. Stupid problem, but until you verify the flow of mail with your hosting provider and scale your complexity back… You won’t solve the problem.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2010/01/a-simple-php-mail-function-for-testing-smtp-delivery/' addthis:title='A Simple PHP mail() Function For Testing SMTP Delivery ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2010/01/a-simple-php-mail-function-for-testing-smtp-delivery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Save A Webpage In HTML To A File In VBScript</title>
		<link>http://www.bohack.com/2009/12/how-to-save-a-webpage-in-html-to-a-file-in-vbscript/</link>
		<comments>http://www.bohack.com/2009/12/how-to-save-a-webpage-in-html-to-a-file-in-vbscript/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 18:45:31 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=361</guid>
		<description><![CDATA[The VBScript code will get a webpage from Google and save the HTML to a file using the msxml2.xmlhttp.6.0 object.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/12/how-to-save-a-webpage-in-html-to-a-file-in-vbscript/' addthis:title='How To Save A Webpage In HTML To A File In VBScript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I had just finished working on a project where I needed to programmatically get a web page and save the HTML to a file. I started toying around with some code I used for parsing XML and totally rewrote the code. I found that I kept getting an error of “Microsoft VBScript runtime error: Invalid procedure call or argument”. I couldn’t understand what was going on. I was passing the parameters correctly to the File System Object, but I kept getting the error. All FSO was doing was creating a file and writing the string out. So I checked the length and then started writing the left(string,number) and found it was a character that was in Unicode. So I wrote a Unicode to Ascii function that is not all that efficient, but it is very effective. The sample code below will get a webpage from Google and save it to a file.</p>
<p><span id="more-361"></span>You can modify the code to accept arguments and make a VBScript replacement for wget the UNIX command. However wget is much more versatile and allows for a lot more features like agent string and referrer string modification. I use the “msxml2.xmlhttp.6.0” object, but you can replace it with “msxml2.xmlhttp.3.0” if you run into a problem. I had tested it on XP and Vista, so I think the “msxml2.xmlhttp.6.0” is tied to the IE version of IE version 6. Maybe someone can clarify that. The code does work and enjoy.</p>
<pre>
Dim FSO, dFile, sHTML

sHTML = Get_HTML ("http://www.google.com")

Set FSO = CreateObject("Scripting.FileSystemObject")
Set dFile = FSO.CreateTextFile("SaveFile.html", True)

dFile.Write UniToAsc(sHTML)
dFile.Close

Set dFile = Nothing
Set FSO = Nothing

Private Function Get_HTML (up_http)
 Dim xmlhttp
 Set xmlhttp = createobject("msxml2.xmlhttp.6.0")

 xmlhttp.open "get", up_http, False
 xmlhttp.send
 Get_HTML = xmlhttp.responsetext

 set xmlhttp = Nothing
End Function

Private Function UniToAsc(sString)
 Dim nLen, nPTR, sAsc
 nLen = Len(sString)

 For nPTR = 1 To nLen
  sAsc = sAsc &amp; Chr(Asc(Mid(sString, nPTR, 1)))
 Next

 UniToAsc = sAsc
End Function
</pre>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/12/how-to-save-a-webpage-in-html-to-a-file-in-vbscript/' addthis:title='How To Save A Webpage In HTML To A File In VBScript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/12/how-to-save-a-webpage-in-html-to-a-file-in-vbscript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Get the URL from a hyperlink in Excel</title>
		<link>http://www.bohack.com/2009/06/get-the-url-from-a-hyperlink-in-excel/</link>
		<comments>http://www.bohack.com/2009/06/get-the-url-from-a-hyperlink-in-excel/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 17:01:59 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=324</guid>
		<description><![CDATA[Recently I needed to extract a links from a web page; normally I would use some Linux commands ported to windows and get the job done. In the end I needed to format the relative link to a full URL, so I decided to use Excel. However when I imported the web page into excel [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/06/get-the-url-from-a-hyperlink-in-excel/' addthis:title='Get the URL from a hyperlink in Excel ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to extract a links from a web page; normally I would use some Linux commands ported to windows and get the job done. In the end I needed to format the relative link to a full URL, so I decided to use Excel. However when I imported the web page into excel I found that the URL was embedded in the friendly name of the hyperlink.</p>
<p><span id="more-324"></span>The hyperlink command in excel actually does the reverse of what I needed; it creates a hyperlink out of the URL and a friendly name and I needed the URL from the friendly name. So I dug in a little deeper and treated the URL like an object. It has properties and those properties can be exposed. The hyperlinkcell object has a type of range so it is passed to the function of GETURL. The first hyperlink in the range we will want the property of the address. Then we simply pass it back to the function so that we can display it.</p>
<p>To install this all you need to do is:</p>
<ol>
<li>Hit ALT + F11 (Opens Visual Basic Editor)</li>
<li>Click on Insert -&gt; Module (adds a module to your excel file)</li>
<li>Paste the code below for the function of GETURL</li>
<li>Hit ALT + Q (Closes the Visual Basic Editor)</li>
</ol>
<p>Now use the =GETURL(cell) to get the URL</p>
<p>Example: =GETURL(A1) will return the URL for the Hyperlink displayed in cell A1</p>
<pre>Function GETURL(HyperlinkCell As Range)

 GETURL = HyperlinkCell.Hyperlinks(1).Address

End Function</pre>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/06/get-the-url-from-a-hyperlink-in-excel/' addthis:title='Get the URL from a hyperlink in Excel ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/06/get-the-url-from-a-hyperlink-in-excel/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

