<?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>Zac Vineyard's Blog</title>
	<atom:link href="http://zacvineyard.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://zacvineyard.com/blog</link>
	<description>code, design, videos, and other nonsense</description>
	<lastBuildDate>Thu, 25 Feb 2010 16:52:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Parse Google Calendar XML with Actionscript 3.0 the Right Way</title>
		<link>http://zacvineyard.com/blog/2010/02/25/parse-google-calendar-xml-with-as/</link>
		<comments>http://zacvineyard.com/blog/2010/02/25/parse-google-calendar-xml-with-as/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 16:49:25 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=252</guid>
		<description><![CDATA[If you ever sit down to try and parse Google calendar XML data in Actionscript (specifically AS3), you'll find that there is a lot of misinformation on the web, including many poor, broken examples of code. I'd like to try and demystify some of the problems behind parsing Google calendar XML by showing how it is done the right way.]]></description>
			<content:encoded><![CDATA[<p><img src="http://zacvineyard.com/blog/wp-content/uploads/2010/02/cal.jpg" alt="cal" title="cal" width="150" height="148" class="alignright size-full wp-image-299" />If you ever sit down to try and parse Google calendar XML data in Actionscript (specifically AS3), you&#8217;ll find that there is a lot of misinformation on the web, including many poor, broken examples of code. I&#8217;d like to try and demystify some of the problems behind parsing Google calendar XML by showing how it is done the right way.</p>
<h2>How to Find the URL to Some Google Calendar XML</h2>
<p>Google does a great job of giving you direct access to the XML of any calendar that may appear on your personal calender. You even have the option of making your private calendars public, thereby getting access to your own calendar XML feed. In Google calendar, if you click Settings (Img.1), then click the first orange XML button (Img. 2), Google gives you a URL to your calendar&#8217;s XML. You must make the calendar you want to use in your AS3 project public.</p>
<div id="attachment_253" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-253" title="Click Settings" src="http://zacvineyard.com/blog/wp-content/uploads/2010/01/1.jpg" alt="Click Settings to find the Google Calendar XML URL" width="600" height="220" /><p class="wp-caption-text">Click Settings to find the Google Calendar XML URL for your AS3 project</p></div>
<div id="attachment_254" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-254" title="Click the Orange XML Button" src="http://zacvineyard.com/blog/wp-content/uploads/2010/01/2.jpg" alt="Click the Orange XML Button" width="600" height="220" /><p class="wp-caption-text">Click the Orange XML Button</p></div>
<p>Once you have the URL to your XML, you may want to append some sorting options to your XML.</p>
<h2>Sort Your XML Before You Use It</h2>
<p>By default, Google adds events to your XML by the date the event was created on the calendar, not by the event&#8217;s start date or end date. This is odd but there is a quick fix. By appending a little more data to your calendar URL, you have have sorted XML. I recommend adding this to the end of your URL:</p>
<blockquote><p><code>?orderby=starttime&amp;sortorder=ascending&amp;max-results=5</code></p></blockquote>
<p>Now that you have sorted, usable XML, let&#8217;s add it to your Actionscript.</p>
<h2>The Code</h2>
<p>Here is a short example of how to parse your Google Calender XML in Actionscript 3.0.</p>
<blockquote class="overflow">

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xmlLoader<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> xml_data<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; 
xmlLoader.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, load_xml<span style="color: #000000;">&#41;</span>; 
&nbsp;
xmlLoader.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://www.google.com/calendar/feeds/0p18vi9o7tve7uokobk4irlhb4@group.calendar.google.com/public/full?orderby=starttime&amp;max-results=5&amp;singleevents=true&amp;sortorder=a&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> load_xml<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	xml_data = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">XML</span><span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">target</span>.<span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span>;
	parse_xml<span style="color: #000000;">&#40;</span>xml_data<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> parse_xml<span style="color: #000000;">&#40;</span>xml_data<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #009900;">// Number of XML / Calendar Entries</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> numEntries<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = xml_data.<span style="color: #000000; font-weight: bold;">*::</span>entry.<span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #009900;">// Loop for Event Title and Summary</span>
	<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span>numEntries; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #6699cc; font-weight: bold;">var</span> event_text = xml_data.<span style="color: #000000; font-weight: bold;">*::</span>entry<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #000000; font-weight: bold;">*::</span>title.<span style="color: #004993;">text</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">toXMLString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #6699cc; font-weight: bold;">var</span> eventStartDate = xml_data.<span style="color: #000000; font-weight: bold;">*::</span>entry<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #000000; font-weight: bold;">*::</span>summary.<span style="color: #004993;">text</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">toXMLString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>event_text<span style="color: #000000;">&#41;</span>;
		<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>eventStartDate<span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

</blockquote>
<p>If you have some basic knowledge of AS3 loaders, then this will not look very complicated. First, we create a new AS3 loader, which will grab our XML and load it up so we can put it to use. Once you actually deploy your flash site, you may need to use a PHP XML proxy file to spoof your sever into thinking the Google Calendar XML is local.</p>
<p>After we create the loader, we add an event listener that sends the data to our parse function after the data loads. Then, we&#8217;re off and running. Make sure you replace the Google URL with our own calendar URL (I have a demo in there now). You can also change which XML node data you&#8217;d like to get by the word &#8220;title&#8221; in the event_text variable with the name of another node in the XML. See below:</p>
<blockquote><p><code>xml_data.*::entry[i].*::NODE_YOU_WANT.text().toXMLString();</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2010/02/25/parse-google-calendar-xml-with-as/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back to Basics</title>
		<link>http://zacvineyard.com/blog/2010/02/02/back-to-basics/</link>
		<comments>http://zacvineyard.com/blog/2010/02/02/back-to-basics/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 06:00:16 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=223</guid>
		<description><![CDATA[I'm restructuring my blog to only focus on these languages and environments: Apache, PHP, MySQL, Javascript (usually via jQuery), XML, Actionscript, CSS, and HTML. Very rarely have I had to extend my reach out into other languages to accomplish the creation of a quality web page or web application.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been exploring the depths of web development for quite sometime now, and it occured to me yesterday that almost every single project I have ever worked on only uses the most basic and popular web development languages and environments. These are Apache, PHP, MySQL, Javascript (usually via jQuery), XML, Actionscript, CSS, and HTML. Very rarely have I had to extend my reach out into other languages to accomplish the creation of a quality web page or web application.</p>
<p>In light of this, I&#8217;m restructuring my blog to only focus on these languages and environments. I will also look at content management systems, but only in a limited scope. Most of my content management system talk will probably be connected with <a href="http://typo3.org">Typo3</a>.</p>
<p>And, because I am a higher-ed web professional, I may sneak in a few posts about marketing and web development from the university website perspective. </p>
<p>To kick things off, check out my latest post: <a href="http://zacvineyard.com/blog/2009/12/19/build-a-basic-authorize-net-payment-form/">Building a Basic Authorize.net Payment Form</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2010/02/02/back-to-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build a Basic Authorize.net Payment Form</title>
		<link>http://zacvineyard.com/blog/2009/12/19/build-a-basic-authorize-net-payment-form/</link>
		<comments>http://zacvineyard.com/blog/2009/12/19/build-a-basic-authorize-net-payment-form/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 05:18:52 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[authorize.net]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[payment]]></category>
		<category><![CDATA[test.authorize.net]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=226</guid>
		<description><![CDATA[Getting a payment form that works can be tricky. But once you figure it out, you have the form as a reference forever. I'd like to show you how to build a basic Authorize.net payment form using HTML and PHP. Luckily, Authorize.net does a very good job providing documentation to web developers, making this form creation process very easy. ]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-277" title="shield" src="http://zacvineyard.com/blog/wp-content/uploads/2009/12/shield.jpg" alt="shield" width="150" height="190" />Getting a payment form that works can be tricky. But once you figure it out, you have the form as a reference forever. I&#8217;d like to show you how to build a basic Authorize.net payment form using HTML and PHP.</p>
<p>Luckily, Authorize.net does a very good job providing documentation to web developers, making this form creation process very easy.</p>
<p>This form is for Authorize.Net&#8217;s <a href="http://developer.authorize.net/api/aim/" target="_blank">Advanced Integrated Method</a>, the recommended connection method that offers the most security and flexibility.</p>
<p>The whole point of secure online transactions is that sensative information, especially credit card information, should never be stored in a database. That information should be used to handle a payment then immediately forgotten. Some online retailers save the last 4 digits of a credit card but only for recipt purposes. The form I will help you build will forget the credit card info, making it ultra safe. I will also show you how to log this form data in a database.</p>
<h2>Step 1: Database</h2>
<p>First we need a database. Here is a little SQL to get you going:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">`transaction_log`</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">`id`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`pid`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`response_code`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`payment_data`</span> text <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">`response_data`</span> text <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM  <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">5</span> ;</pre></div></div>

</blockquote>
<p>The record keeping system I use serializes data, which is very basic. This works to keep you out of tax problems (because you have a complete payment record) but it isn&#8217;t the best for a direct download because the data has to be un-serialized.</p>
<h2>Step 2: The HTML Form</h2>
<p>Now on the the HTML. I am going to append a little bit of Javascript and a touch of PHP into this HTML form.</p>
<blockquote class="overflow">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'run'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'payment_validation.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Payment gateway Form&lt;/title&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&lt;form name=&quot;payment&quot; action=&quot;&quot; method=&quot;post&quot; onsubmit=&quot;document.getElementById('submit_button').disabled = 1;&quot;&gt;
	&lt;p&gt;&lt;input type=&quot;hidden&quot; name=&quot;page_id&quot; value=&quot;4&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;First Name&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;first_name&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Last Name&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;last_name&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Comments&lt;/label&gt;&lt;textarea name=&quot;comments&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Card Num&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;cc_card_num&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Expiration Date&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;cc_exp_date&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Amount&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;cc_amount&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;label&gt;Description&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;cc_description&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;input name=&quot;submit&quot; id=&quot;submit_button&quot; type=&quot;submit&quot;&gt;&lt;/p&gt;
	&lt;p&gt;&lt;input type=&quot;hidden&quot; name=&quot;run&quot; value=&quot;true&quot;&gt;&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

</blockquote>
<p>It is good to take special note of the &#8220;onsubmit&#8221; attribute I&#8217;ve added to the form tag. This little snippet of Javascript prevents someone from accidentally clicking the submit button twice, thereby avoiding doubled transactions. The PHP at the top of the example HTML includes our payment validation script once the form is submitted. The &#8220;payment_validation.php&#8221; script it includes validates whether or not we have filled out all the form&#8217;s required fields. Now, some of these fields must be required because Authorize.net has a <a href="http://developer.authorize.net/guides/AIM/" target="_blank">set of required information</a> that they use for payment processing, including name, card number, etc. The PHP below just makes sure we have all that information.</p>
<h2>Step 3: Validation</h2>
<p>I am not going to go into to much more detail about form validation with PHP. That&#8217;s a topic for another tutorial. I will warn you, though, that the validation I use in this script is <em>very basic</em>. You should spend time making it stronger.</p>
<blockquote class="overflow">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$required_fields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'page_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'page_id'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Amount'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'cc_amount'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Credit Card Number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'cc_card_num'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Credit Card Expiration Date'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'cc_exp_date'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'cc_description'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> verify_data_present<span style="color: #009900;">&#40;</span><span style="color: #000088;">$required_fields</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Ensure we have some data</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;No Post! Nothing to send to Authorize.net&lt;/strong&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Make sure that all of the required fields exist as keys in the post array</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$required_fields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; does not exist in post data and is required!&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; is a required field.&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_card_num'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Card number must be numeric!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_amount'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Amount must be a decimal of form x.xx without the dollar sign!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;div&gt;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Verifty Required POST data isn't empty</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>verify_data_present<span style="color: #009900;">&#40;</span><span style="color: #000088;">$required_fields</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gateway.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;div class=&quot;</span>approved<span style="color: #0000ff;">&quot;&gt;Your transaction has been approved.&lt;/div&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</blockquote>
<h2>Step 4: The Gateway</h2>
<p>Near the end of this PHP script, you will see this line: <code>include('gateway.php');</code>. That is the magic PHP include that sends along the payment information to Authorize.net and, even if the payment fails, adds the transaction details to your database. Let&#8217;s take a look at that script now. I warn you, though, this PHP is intimidating at first glance.</p>
<blockquote class="overflow">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Settings</span>
<span style="color: #000088;">$post_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://test.authorize.net/gateway/transact.dll&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;payments&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;transaction_log&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Setup the array with data to post to authorize.net</span>
<span style="color: #000088;">$post_values</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">&quot;x_login&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;********&quot;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Given to you by Authorize.net (make sure you replace!)</span>
	<span style="color: #0000ff;">&quot;x_tran_key&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;****************&quot;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Given to you by Authorize.net (make sure you replace!)</span>
&nbsp;
	<span style="color: #0000ff;">&quot;x_version&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;3.1&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_delim_data&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;TRUE&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_delim_char&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;|&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_relay_response&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;FALSE&quot;</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #0000ff;">&quot;x_type&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;AUTH_CAPTURE&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_method&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;CC&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_card_num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_card_num'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_exp_date&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_exp_date'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #0000ff;">&quot;x_amount&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_amount'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_description&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// The Values Below are Optional</span>
&nbsp;
	<span style="color: #0000ff;">&quot;x_first_name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;John&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_last_name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Doe&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_address&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;1234 Street&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_state&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;CA&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;x_zip&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;90210&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This section takes the input fields and converts them to the proper format</span>
<span style="color: #666666; font-style: italic;">// for an http post. For example: &quot;x_login=username&amp;amp;x_tran_key=a1B2c3D4&quot;</span>
&nbsp;
<span style="color: #000088;">$post_string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_values</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #000088;">$post_string</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$key</span>=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$post_string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&amp;amp; &quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This sample code uses the CURL library for php to establish a connection,</span>
<span style="color: #666666; font-style: italic;">// submit the post, and record the response.</span>
<span style="color: #666666; font-style: italic;">// If you receive an error, you may want to ensure that you have the curl</span>
<span style="color: #666666; font-style: italic;">// library enabled in your php configuration</span>
&nbsp;
<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// initiate curl object</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set to 0 to eliminate header info from response</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Returns response data instead of TRUE(1)</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post_string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// use HTTP POST to send form data</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYPEER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// uncomment this line if you get no gateway response.</span>
	<span style="color: #000088;">$post_response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// execute curl post and store results in $post_response</span>
	<span style="color: #666666; font-style: italic;">// additional options may be required depending upon your server configuration</span>
	<span style="color: #666666; font-style: italic;">// you can find documentation on curl options at http://www.php.net/curl_setopt</span>
	<span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// close curl object</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This line takes the response and breaks it into an array using the specified delimiting character</span>
<span style="color: #000088;">$response_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_values</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;x_delim_char&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$post_response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Before we allow the system to do anything with the
 * rest of the form data we need to make sure that the
 * credit card number gets removed to prevent sensitive
 * information from getting out just in case we are
 * compromised.
 */</span>
&nbsp;
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cc_card_num'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// remove the credit card info</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// **********************************************</span>
<span style="color: #666666; font-style: italic;">//     NOW WE CAN DO STUFF WITH THE RESPONSE</span>
<span style="color: #666666; font-style: italic;">// **********************************************</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Connect to the database</span>
<span style="color: #000088;">$mysqli</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqli<span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_host</span><span style="color: #339933;">,</span><span style="color: #000088;">$db_user</span><span style="color: #339933;">,</span><span style="color: #000088;">$db_pass</span><span style="color: #339933;">,</span><span style="color: #000088;">$db_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Check db connection</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_connect_errno</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_connect_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Store the form info</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$db_table</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; SET pid = '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;', response_code = '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$response_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;', payment_data = '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;', response_data = '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</blockquote>
<p>This script looks scary but it is quite straight forward. It starts with some basic variable declarations, which consist of database connection variables and a very important <code>$post_url</code>. This defines the URL we will use to POST data to Authorize.net. It is currently set to the default Authorize.net <em>test environment</em>. That way we don&#8217;t have to worry about actually spending money to experiment with this payment form.</p>
<p>The next part of this &#8220;gateway.php&#8221; script is an array of data called <code>$post_values</code>. This is the actual array of data that gets sent to Authorize.net. Notice the POST data we are adding from our form. That&#8217;s the real bread and butter of the whole process! More importantly, though, are two parts of this array that identify who you are to Authorize.net. They are the <code>x_login </code> and <code>x_tran_key</code>. I think of these as my username and password to Authorize.net. Make sure that when you get your login and key from Authorize.net (after your account setup) to keep them safe. You will have to add your login and key to this form. You can <a href="http://developer.authorize.net/testaccount/" target="_blank">request a test account</a> from Authorize.net.</p>
<p>After the <code>$post_values</code> array you&#8217;ll begin to see more complicated PHP. You do not need to edit this data. Whet you see is the initialization of a CURL object which handles the POST of our data to Authorize.net. It also handles the response we get, which tells us whether or not our payment was approved. That response gets added the <code>$post_response</code> array defined on line 55 of the &#8220;gateway.php&#8221; script.</p>
<p>After this CURL object (in the PHP) you&#8217;ll see a few lines of code that add the serialized POST data to our database, sans any credit card information. The credit card is stripped from our data on line 71 of the &#8220;gateway.php&#8221; script with the <code>unset($_POST['cc_card_num']);</code> command.</p>
<h2>Finished</h2>
<p>That&#8217;s it! Please take note that I echo the response array after the form is submitted. Interpreting this response can be challenging, but you can do it with help from the <a href="http://developer.authorize.net/guides/AIM/" target="_blank">Authorize.net Developer&#8217;s Guide</a>. This form is available for download.</p>
<h2>Thanks</h2>
<p>Thanks to <a href="http://ben.lobaugh.net/blog/">Ben Lobaugh</a> for his help with this script.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/12/19/build-a-basic-authorize-net-payment-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LitList Reborn</title>
		<link>http://zacvineyard.com/blog/2009/11/03/litlist-re-born/</link>
		<comments>http://zacvineyard.com/blog/2009/11/03/litlist-re-born/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 05:31:57 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=218</guid>
		<description><![CDATA[If you haven't seen it already, LitList, a project I started in 2007, just underwent a massive overhaul. I've been heavily developing a new platform for LitList, taking it away from previous functionality to add in many new features. It is now built on Codeigniter and I'm loving it.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://profile.ak.fbcdn.net/object3/416/29/n95607365613_9800.jpg" alt="" width="200" height="200" />If you haven&#8217;t seen it already, <a href="http://www.litlist.net">LitList</a>, a project I started in 2007, just underwent a massive overhaul. I&#8217;ve been heavily developing a new platform for LitList, taking it away from previous functionality to add in many new features. It is now built on <a href="http://codeigniter.com">Codeigniter</a> and I&#8217;m loving it.</p>
<p>New features include the ability to follow publishers and writers, a re-vamped contest page that&#8217;s sort-able, a place for publishers to add submission guidelines, and an activity wall that lets users see the announcements and updates from writers and publishers they follow.</p>
<p>I invite you to see the new LitList for yourself. Visit <a href="http://www.litlist.net">http://www.litlist.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/11/03/litlist-re-born/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript 3.0 SoundChannel Position Pause Bug</title>
		<link>http://zacvineyard.com/blog/2009/09/26/actionscript-3-0-soundchannel-position-pause-bug/</link>
		<comments>http://zacvineyard.com/blog/2009/09/26/actionscript-3-0-soundchannel-position-pause-bug/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 03:04:20 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Actionscript]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=208</guid>
		<description><![CDATA[I spent my entire morning today trying to discover why I couldn't get a pause function to work properly on an actionscript 3.0 mp3 player. I came to find out that a very significant bug exists in actionscript that keeps channel.position (part of SoundChannel) from reporting the correct position location of a stopped mp3.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-213" title="as3" src="http://zacvineyard.com/blog/wp-content/uploads/2009/09/as3.jpg" alt="as3" width="200" height="200" />I spent my entire morning today trying to discover why I couldn&#8217;t get a pause function to work properly on an actionscript 3.0 mp3 player. I came to find out that a very significant bug exists in actionscript that keeps channel.position (part of <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundChannel.html">SoundChannel</a>) from reporting the correct position location of a stopped mp3. A few bloggers also talk about similar problems, and I list one link below.</p>
<h2>The Problem</h2>
<p>This is the heart of the problem: <strong>channel.position mis-reports the actual position of the audio for mp3 files less than 128kbps</strong>.</p>
<p>Files larger than 128kbps seem to work fine. It has also been suggested that in order for channel.position to work correctly, the mp3 audio must also sampled at 44.100kHz. It is also reported that Adobe has been notified of this bug.What surprised me the most about his endeavor is Adobe&#8217;s over-sight with their <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundChannel.html">SoundChannel</a>. Not only is it, reportedly, loaded with bugs, but it also lacks basic functions. While we have a <em>play()</em> and <em>stop()</em>, for example, we aren&#8217;t given a <em>pause()</em>.</p>
<p>I originally found information about this problem at <a href="http://www.stevensacks.net/2008/08/07/bug-with-sound-channel-position-and-mp3s-less-than-128kbps/">http://www.stevensacks.net/2008/08/07/bug-with-sound-channel-position-and-mp3s-less-than-128kbps/</a>.</p>
<h2>The Solution</h2>
<p>Until Adobe fixes this problem, re-sample your audio greater than 128kbps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/09/26/actionscript-3-0-soundchannel-position-pause-bug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wordpress vs Drupal</title>
		<link>http://zacvineyard.com/blog/2009/07/30/wordpress-vs-drupal/</link>
		<comments>http://zacvineyard.com/blog/2009/07/30/wordpress-vs-drupal/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 16:27:31 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=177</guid>
		<description><![CDATA[This question is usually at the maelstrom of our storm: Which platform is better for my next project? To answer this, I want to point out the differences between Wordpress and Drupal.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-178 thumb" title="wordpress_drupal" src="http://zacvineyard.com/blog/wp-content/uploads/2009/07/wordpress_drupal.jpg" alt="wordpress_drupal" width="256" height="224" />There has been a wide variety of talk on the internet about different blogging platforms and content management systems, including ways to trick out  one system to act like the other. Wordpress, reportedly the most widely used blogging platform, and Drupal, the most commonly used content management system in the US, are no exception to our discussions. This question is usually at the maelstrom of our storm: Which platform is better for my next project? To answer this, I want to point out the differences between Wordpress and Drupal.</p>
<h2>Wordpress</h2>
<p>Wordpress is a system that comes hopped up on easy pills, and because of this, bloggers and developers love it equally. With Wordpress 2.8, you can have a whole system online within a few minutes, including a pre-packaged theme. But this blogging platform also comes with some disadvantages.</p>
<p><strong>The Positives </strong></p>
<ul>
<li>Wordpress is easy to install.</li>
<li>Thousands of extensions make Wordpress flexible.</li>
<li>Online support in the Wordpress Codex  is very good.</li>
<li>Easy to update.</li>
<li> Easy back-end navigation.</li>
<li>You don&#8217;t need to know much PHP.</li>
</ul>
<p>Getting a site out of idea land and into code is very easy with Wordpress. After you run through the short install process, you have thousands of choices on ways to extend your Wordpress install by using any number of extensions, some of which even make Wordpress act more like a CMS. Take, for example, Sitemap Generator, a plugin that builds a site maps for Wordpress sites. Developers would tell you that having a site map ready for Google to consume is essential. Other CMS-like plugins available for Wordpress include user permissions extenders and plugins that give you hierarchical page navigation.</p>
<p>One thing you don&#8217;t need to worry about is Wordpress&#8217; lack of support. Their support site is very thorough. Even learning about Wordpress&#8217; specific functions is quite easy.   One more note about Wordpress&#8217; positive aspects: since Wordpress 2.8, you&#8217;ve been able to update the platform very easily. Literally with the click of a button, Wordpress can get a new back-end.</p>
<p><strong>The Negatives </strong></p>
<ul>
<li>Wordpress is too popular, and thus a major target for spammers.</li>
<li> Limited scope.</li>
</ul>
<p>The reason I mentioned the ease of being able to update Wordpress is because, if left in a legacy state your Worpress install will eventually get hacked. Because of its popularity and its core blogging focus, spammers actively try to take advantage of Wordpress to post spam comments and posts. But as long as you update your platform, the spammers stay at bay. Using Akismet also helps.</p>
<p>Wordpress, too, when compared to other online content platforms, has a very limited scope. Its purpose is really to blog. So, if you are planning to build a site with multiple blogs, each of which have multiple authors, then look for a different platform. Or if you are planning to build a more dynamic site, one which frequently interacts with a database or collects data online, then Wordpress probably isn&#8217;t for you.</p>
<h2>Drupal</h2>
<p>Do you look at a page of PHP and release a high-pitched squeal of excitement? If so, Drupal might throw you into cardiac arrest. While that might sound bad to Wordpress lovers, Drupal is, in fact, very similar to Wordpress in a number of ways. It too has good and bad properties.</p>
<p><strong>The Positives </strong></p>
<ul>
<li>Drupal is easy to install.</li>
<li>You can theme everything, including the back-end.</li>
<li>Online support is is very good.</li>
<li>Thousands of extensions are available.</li>
<li>You can build large sites.</li>
</ul>
<p>Since version 5, Drupal (which is in version 6 now) has had a similar step-though installation process to that of Wordpress. But some call it more challenging. The install processes of both platforms seemed equal to me, neither of which were too complicates. As long as you know your database login information, you are fine.</p>
<p>Similarly too, Drupal has plenty of extensions. Installing extensions, too, is just like installing them in Wordpress. Download the files and copy them into a plugin directory.</p>
<p>The major advantage you get from Drupal over Wordpress is that you can build sites that go far beyond the blogging scope, though you can blog with Drupal too. Everyone from large corporations to small businesses use Drupal to give themselves a usable web space. Shopping cart systems, for example, are much more common in Drupal than in Wordpress. If you use Drupal, however, don&#8217;t expect the ride to be as easy as it is on the Wordpress train. Getting Drupal to do what you want can sometimes take writing your own PHP or modifying extensions, even though it gives you an excellent framework for adding content and pages to your site. And it comes with more robust architecture for you to exploit in sites, like the ability to add pages in a hierarchy.</p>
<p><strong>The Negatives </strong></p>
<ul>
<li> Building extensions requires a thorough knowledge of Drupal&#8217;s hook system.</li>
<li>You must be very well versed in HTML, CSS, and PHP.</li>
<li> Back-end navigation isn&#8217;t as friendly.</li>
<li>Less clear distinction between  front-end and back-end.</li>
</ul>
<p>Drupal, unlike Wordpress, just isn&#8217;t as user friendly. There is less of a distinction between the back-end and the front-end of a Drupal site, which often made me feel confused about my location. I kept looking for a back-end, which is why I recommend skinning the back-end and front-end differently.   Also, Drupal&#8217;s back-end navigation isn&#8217;t as friendly. More clicking is involved to get you into CMS settings and content creation, whereas Wordpress has everything conveniently organized in their back-end menu.</p>
<p>Those are some basic differences between Drupal and Wordpress. Here&#8217;s what you should take to the bank: each of these systems can be used to blog, so take that as an excuse to learn both. Once you start blogging in Drupal, you may just turn into a PHP whiz that will never resort to simple blogging again. Or you might find yourself prepared to build more complicated sites for larger clients.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/07/30/wordpress-vs-drupal/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Microsoft&#8217;s Excuses for IE8</title>
		<link>http://zacvineyard.com/blog/2009/06/23/microsofts-excuses-for-ie8/</link>
		<comments>http://zacvineyard.com/blog/2009/06/23/microsofts-excuses-for-ie8/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 19:43:50 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[IE8]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=169</guid>
		<description><![CDATA[Dear Microsoft, thank you for putting out a waste of code that will, again, send web programmers into cardiac arrest.]]></description>
			<content:encoded><![CDATA[<p>When I first saw Microsoft&#8217;s <a href="http://www.microsoft.com/windows/internet-explorer/get-the-facts/browser-comparison.aspx">browser <span style="text-decoration: line-through;">excuse</span> comparison sheet</a>, I had to laugh. Here is a quick quote:</p>
<blockquote><p>Firefox and Chrome have more support for emerging standards like HTML5 and CSS3, but Internet Explorer 8 invested heavily in having world-class, consistent support for the entire CSS2.1 specification.</p></blockquote>
<p>Dear Microsoft,</p>
<p>Thank you for putting out a waste of code that will, again, send web programmers into cardiac arrest. You should have had CSS 2.1 compliance years ago, with all other popular browsers. The reason programmer&#8217;s don&#8217;t use CSS3 is because CSS3 isn&#8217;t supported by Internet Explorer, essentially making IE8 the new IE6: a turd.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/06/23/microsofts-excuses-for-ie8/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Parse Yahoo Weather Data XML with PHP</title>
		<link>http://zacvineyard.com/blog/2009/05/14/parse-yahoo-weather-data-xml-with-php/</link>
		<comments>http://zacvineyard.com/blog/2009/05/14/parse-yahoo-weather-data-xml-with-php/#comments</comments>
		<pubDate>Thu, 14 May 2009 17:12:51 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Current Temperature]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Weather]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=158</guid>
		<description><![CDATA[I've looked at parsing weather data with PHP before, but I've found that using Yahoo's weather service it more stable and flexible. Luckily PHP has some excellent built in functions to parse complex XML.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a href="http://zacvineyard.com/blog/2008/11/07/show-the-current-temperature-using-xml-and-php/">looked at parsing weather data with PHP before</a>, but I&#8217;ve found that using Yahoo&#8217;s weather service it more stable and flexible. Luckily PHP has some excellent built in functions to parse complex XML.</p>
<p>First, let&#8217;s look at the code. Below is a complete weather XML parsing function that allows you to call the current temperature (or other weather information) using a zip code.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
channel<span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://xml.weather.yahoo.com/ns/rss/1.0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attr</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'day'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attr</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'forecast'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$forecast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$day</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attr</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$forecast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attr</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$forecast</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$forecast</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'condition'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'temp'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;Weather for that zip code is unavailable.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> weather<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;83642&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</blockquote>
<h2>What Is All This?</h2>
<p>All this code is actually pretty easy to understand. Lines three and four of the function are simplexml commands that load some XML for us to work with. For more information about simplexml, <a href="http://us2.php.net/simplexml">dig around on PHP&#8217;s website</a>.</p>
<p>Now, right after we load the XML, we need to break the XML into workable pieces, which is done on line 9. Now, if you look at the raw XML supplied from Yahoo, you&#8217;ll notice that the current temperature is actually an attribute of an XML tag. So, in lines 15 through 19, we use PHP to build an array of the XML items (defined by the  tag) and their attributes, out of which we return the current temperature on line 21.</p>
<p>So, once the data is parsed, you should be able to call back information you want, like the forecast. Try returning something like this on line 21, making sure you grab the right day:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$forecast</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'forecast'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Thu'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

</blockquote>
<h2>That&#8217;s It</h2>
<p>Now, have fun with this. Add weather info wherever you want!</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/05/14/parse-yahoo-weather-data-xml-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force SSL / https on Typo3&#8217;s Backend</title>
		<link>http://zacvineyard.com/blog/2009/04/22/force-ssl-https-on-typo3s-backend/</link>
		<comments>http://zacvineyard.com/blog/2009/04/22/force-ssl-https-on-typo3s-backend/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 17:26:02 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=150</guid>
		<description><![CDATA[Sometimes it is appropraite to secure Typo3's backend login page and editing pages. This is done very easily in your server's .htaccess file.]]></description>
			<content:encoded><![CDATA[<p>Pages that contain sensitive forms or serve personal information are many times secure. It is a wide trend on the internet to look for the lock icon on a page to see if your information is secure. Typo3 is no different, especially when it comes to the back end. Sometimes it is appropriate to secure Typo3&#8217;s back end login page and editing pages. This is done very easily in your server&#8217;s .htaccess file.</p>
<p>Try adding this code, with your domain, to your root .htaccess file:</p>
<blockquote>
<pre name="code" class="html">
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^typo3(/(.*))?$ https://www.example.com/typo3/$2 [R=301,L]
</pre>
</blockquote>
<p>Once working, your /typo3 directory should be secure.</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/04/22/force-ssl-https-on-typo3s-backend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing Imagemagick for Typo3</title>
		<link>http://zacvineyard.com/blog/2009/04/21/installing-imagemagick-for-typo3/</link>
		<comments>http://zacvineyard.com/blog/2009/04/21/installing-imagemagick-for-typo3/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 16:50:10 +0000</pubDate>
		<dc:creator>Zac</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Imagemagick]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://zacvineyard.com/blog/?p=135</guid>
		<description><![CDATA[One of the things you immediately find out about Typo3 is that it uses Imagemagick, a server based image modification tool, to handle thumbnail creation, image resizing, and more. Imagemagick gives Typo3 some great features, but only if you have it installed correctly. Here is a quick guide to installing Imagemagick for Typo3.]]></description>
			<content:encoded><![CDATA[<p>One of the things you immediately find out about Typo3 is that it uses Imagemagick, a server based image modification tool, to handle thumbnail creation, image resizing, and more. Imagemagick gives Typo3 some great features, but only if you have it installed correctly. Typo3 can run without Imagemagick, but you&#8217;ll likely run across a few user-ability problems, especially with image resizing and positioning.</p>
<p><strong>How Do I Know if Imagemagick is Installed?</strong></p>
<p>There are two good ways of seeing whether or not Imagemagick is installed on your sever. Usually, if you host your site on a larger host provider, like GoDaddy,<a href="http://help.godaddy.com/article/208" target="_blank"> Imagemagick will be provided</a>. But if you are not sure, here is how to check your Imagemagick install from the server side and through Typo3.</p>
<p>To check if Imagemagick is installed on your Linux based server, try typing the following command into a terminal window:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">convert</pre></div></div>

</blockquote>
<p>If Imagemagick is installed, you should see a screen of help cascade through the terminal window. If not, you&#8217;ll get an error. You can also check to see if Imagemagick is installed through Typo3&#8217;s Install module. To access the Typo3 Install module you would need to create an empty file named ENABLE_INSTALL_TOOL (there is no file extension) and put it into &#8220;typo3conf&#8221; folder. Once inside, click on &#8220;Image Processing&#8221; and scroll down to &#8220;Current Configuration&#8221;.</p>
<p style="text-align: center;"><img class="size-full wp-image-142 aligncenter" title="typo3_imagemagick_install" src="http://zacvineyard.com/blog/wp-content/uploads/2009/04/typo3_imagemagick_install.jpg" alt="typo3_imagemagick_install" width="368" height="350" /></p>
<p>This section will tell you if Typo3 was able to locate an Imagemagick installation on the server. The image below is an example of the server configuration with Imagemagick.</p>
<p style="text-align: center;"><img class="size-full wp-image-139 aligncenter" title="typo3_imagemagick" src="http://zacvineyard.com/blog/wp-content/uploads/2009/04/typo3_imagemagick.jpg" alt="typo3_imagemagick" width="476" height="298" /></p>
<p><strong>Install Imagemagick</strong></p>
<p>Installing Imagemagick on a Linux server is quite easy. It is even easier on the Windows side. I am only going to cover a Linux installation in this guide.</p>
<p>First, <a href="http://www.imagemagick.org/script/index.php" target="_blank">download the latest version of Imagemagick</a>.</p>
<p>Second, unzip the download files.</p>
<p>Third, open a terminal window and navigate to the files you just unzipped. I unzipped the files to my root directory, so I navigated with a command like:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">cd ImageMagick-6.5.1</pre></div></div>

</blockquote>
<p>Once in the Imagemagick folder, run the following commands to configure the installation, make the install, and install the files.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">./configure</pre></div></div>

</blockquote>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">make</pre></div></div>

</blockquote>
<p>If ImageMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. On a recent attempt to install Imagemagick, I was missing some image libraries, so my first attempt to install Imagemagick failed. Make sure you have all the necessary libraries installed. If you don&#8217;t, you may see some errors at the end of the &#8216;make&#8217; command&#8217;s output.</p>
<p>If you are ready to install, use the following command to get <em>jpg</em> and <em>png </em>support on the server. Sometimes, the default Imagemagick install commands don&#8217;t provide all the necessary features for Typo3. Installing Typo3 with the &#8216;&#8211;with-jpeg&#8217; and &#8216;&#8211;with-png&#8217; tags should fix that problem.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">make install --with-jpeg --with-png</pre></div></div>

</blockquote>
<p>OnceTypo3 is successfully installed, you will need to restart your web server. This will ensure that Apache is looking for and using the Imagemagick extensions. You will also need to return to the Install module in Typo3 and make sure that Typo3 is seeing and using Imagemagick.</p>
<p>Once everything is complete, your thumbnails should be working on the backend (no more yellow question marks) and image resizing should be a breeze!</p>
]]></content:encoded>
			<wfw:commentRss>http://zacvineyard.com/blog/2009/04/21/installing-imagemagick-for-typo3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
