<?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>Graphic Maniacs &#187; PHP</title>
	<atom:link href="http://graphicmaniacs.com/cat/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://graphicmaniacs.com</link>
	<description></description>
	<lastBuildDate>Fri, 18 May 2012 08:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP &#8220;__PHP_Incomplete_Class&#8221; error</title>
		<link>http://graphicmaniacs.com/note/php-incomplete-class-error/</link>
		<comments>http://graphicmaniacs.com/note/php-incomplete-class-error/#comments</comments>
		<pubDate>Fri, 18 May 2012 08:21:06 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://graphicmaniacs.com/?p=920</guid>
		<description><![CDATA[Had this error when loading an object from the $_SESSION? Here&#8217;s why, from official PHP docs: It&#8217;s possible to set a callback-function which will be called, if an undefined class should be instantiated during unserializing. (to prevent getting an incomplete object &#8220;__PHP_Incomplete_Class&#8221;.) Use your php.ini, ini_set() or .htaccess to define &#8216;unserialize_callback_func&#8217;. Everytime an undefined class [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/php-incomplete-class-error/' addthis:title='PHP &#8220;__PHP_Incomplete_Class&#8221; error '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Had this error when loading an object from the $_SESSION?<br />
Here&#8217;s why, from official PHP docs:</p>
<blockquote><p>It&#8217;s possible to set a callback-function which will be called, if an undefined class should be instantiated during unserializing. (to prevent getting an incomplete object &#8220;__PHP_Incomplete_Class&#8221;.) Use your php.ini, ini_set() or .htaccess to define &#8216;unserialize_callback_func&#8217;. Everytime an undefined class should be instantiated, it&#8217;ll be called. To disable this feature just empty this setting.</p></blockquote>
<p>A simple fix would be to load the session_start AFTER the object class declaration, but if it is not possible, then you could simply double-serialize the object. Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// some code running in your application</span>
<span style="color: #666666; font-style: italic;">// then,</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'myobject'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// then when we need it</span>
<span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'myobject'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The reason of the error is because the objects stored in sessions are converted to serialized string, and when we call session_start(), it tries to initialize the object with the class definition which isn&#8217;t available yet.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/php-incomplete-class-error/' addthis:title='PHP &#8220;__PHP_Incomplete_Class&#8221; error '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://graphicmaniacs.com/note/php-incomplete-class-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting XLSX date-containing field to a real date</title>
		<link>http://graphicmaniacs.com/note/converting-xlsx-date-containing-field-to-a-real-date/</link>
		<comments>http://graphicmaniacs.com/note/converting-xlsx-date-containing-field-to-a-real-date/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 08:29:59 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://graphicmaniacs.com/?p=912</guid>
		<description><![CDATA[Lately, i was importing an XLSX file using a simple xml-based parser and noticed a strange thing.. The date fields were actually containing integers like 40305, which is actually 2010-05-07 (what??). A bit of investigation, and there&#8217;s what that means: the date fields have integers that are the amount of days from 1900-00-00. That means [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/converting-xlsx-date-containing-field-to-a-real-date/' addthis:title='Converting XLSX date-containing field to a real date '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Lately, i was importing an XLSX file using a simple xml-based parser and noticed a strange thing.. The date fields were actually containing integers like 40305, which is actually 2010-05-07 (what??). A bit of investigation, and there&#8217;s what that means: the date fields have integers that are the amount of days from 1900-00-00. That means that to convert it to a date we should make</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$value</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1900</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The reason why i subtract 1 from the $value because php counts from 1900-01-01, while XLSX has a date from 1900-00-00. So after that conversion we have a valid date.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/converting-xlsx-date-containing-field-to-a-real-date/' addthis:title='Converting XLSX date-containing field to a real date '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://graphicmaniacs.com/note/converting-xlsx-date-containing-field-to-a-real-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a list of WordPress hook actions</title>
		<link>http://graphicmaniacs.com/note/getting-a-list-of-wordpress-hook-actions/</link>
		<comments>http://graphicmaniacs.com/note/getting-a-list-of-wordpress-hook-actions/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 13:08:40 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://graphicmaniacs.com/?p=907</guid>
		<description><![CDATA[Sometimes content is outputted somewhere where I don&#8217;t need (when I run do_action), and I can&#8217;t really see what action does that. So to get the list of WordPress actions attached to a hook, use this kind of code: global $wp_filter; var_dump&#40;$wp_filter&#91;'comment_form'&#93;&#41;; You will get then something like this: array&#40;1&#41; &#123; &#91;10&#93;=&#62; array&#40;2&#41; &#123; &#91;&#34;wp_comment_form_unfiltered_html_nonce&#34;&#93;=&#62; [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/getting-a-list-of-wordpress-hook-actions/' addthis:title='Getting a list of WordPress hook actions '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Sometimes content is outputted somewhere where I don&#8217;t need (when I run <strong>do_action</strong>), and I can&#8217;t really see what action does that. So to get the list of WordPress actions attached to a hook, use this kind of code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_filter</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_filter</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment_form'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You will get then something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;wp_comment_form_unfiltered_html_nonce&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;function&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
      string<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">37</span><span style="color: #009900;">&#41;</span> <span style="color: #0000ff;">&quot;wp_comment_form_unfiltered_html_nonce&quot;</span>
      <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;accepted_args&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
      int<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;akismet_add_comment_nonce&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;function&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
      string<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span> <span style="color: #0000ff;">&quot;akismet_add_comment_nonce&quot;</span>
      <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;accepted_args&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=&gt;</span>
      int<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Pretty cool, now we know what produces all that output.</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/getting-a-list-of-wordpress-hook-actions/' addthis:title='Getting a list of WordPress hook actions '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://graphicmaniacs.com/note/getting-a-list-of-wordpress-hook-actions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Issue with Flash uploader and Suhosin PHP patch</title>
		<link>http://graphicmaniacs.com/note/issue-with-flash-uploader-and-suhosin-php-patch/</link>
		<comments>http://graphicmaniacs.com/note/issue-with-flash-uploader-and-suhosin-php-patch/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 10:36:54 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://graphicmaniacs.com/?p=892</guid>
		<description><![CDATA[This is a very simply situation: we use multiple files Flash uploader to display progress, and for other extended functionality when uploading files. But this issue was killing me. After installing Suhosin patch, the session was breaking after any file upload. This was made because Suhosin checks the User-Agent also, and Flash has a different [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/issue-with-flash-uploader-and-suhosin-php-patch/' addthis:title='Issue with Flash uploader and Suhosin PHP patch '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>This is a very simply situation: we use multiple files Flash uploader to display progress, and for other extended functionality when uploading files. But this issue was killing me. After installing Suhosin patch, the session was breaking after any file upload.</p>
<p>This was made because <strong>Suhosin checks the User-Agent</strong> also, and Flash has a different user agent from the browser. Even providing a session id to Flash won&#8217;t solve the issue because Suhosin checks the user agents when session_id/session_start is called.</p>
<p>To solve this issue, simply disable user agent encrypting, but leave the IP address encrypting in php.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">suhosin<span style="color: #339933;">.</span>session<span style="color: #339933;">.</span>encrypt <span style="color: #339933;">=</span> On
suhosin<span style="color: #339933;">.</span>session<span style="color: #339933;">.</span>cryptraddr <span style="color: #339933;">=</span> On
suhosin<span style="color: #339933;">.</span>session<span style="color: #339933;">.</span>cryptua <span style="color: #339933;">=</span> Off</pre></div></div>

<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/issue-with-flash-uploader-and-suhosin-php-patch/' addthis:title='Issue with Flash uploader and Suhosin PHP patch '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://graphicmaniacs.com/note/issue-with-flash-uploader-and-suhosin-php-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove &#8220;on behalf of&#8221; in PHP mail for Outlook 2007 and 2010</title>
		<link>http://graphicmaniacs.com/note/how-to-remove-on-behalf-of-in-php-mail-for-outlook-2007-and-2010/</link>
		<comments>http://graphicmaniacs.com/note/how-to-remove-on-behalf-of-in-php-mail-for-outlook-2007-and-2010/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 08:00:16 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://graphicmaniacs.com/?p=846</guid>
		<description><![CDATA[Anyone noticed that stupid &#8220;admin@domain.com; on behalf of; noreply@domain.com&#8221; bug in subject when you received email with Outlook 2007 and 2010? Well, the fix is pretty simple. While we were setting the From: &#60;email@domain.com&#62; header, now we need to set the Sender header too. So it looks like: $header=''; $header.=&#34;Sender: $from\r\n&#34;; $header.=&#34;From: $from\r\n&#34;; $header.=&#34;MIME-Version: 1.0\r\n&#34;; [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/how-to-remove-on-behalf-of-in-php-mail-for-outlook-2007-and-2010/' addthis:title='How to remove &#8220;on behalf of&#8221; in PHP mail for Outlook 2007 and 2010 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Anyone noticed that stupid &#8220;<strong>admin@domain.com; on behalf of; noreply@domain.com</strong>&#8221; bug in subject when you received email with Outlook 2007 and 2010?</p>
<p>Well, the fix is pretty simple. While we were setting the <strong>From: &lt;email@domain.com&gt;</strong> header, now we need to set the Sender header too. So it looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$header</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;Sender: <span style="color: #006699; font-weight: bold;">$from</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;From: <span style="color: #006699; font-weight: bold;">$from</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;MIME-Version: 1.0<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;Content-Type: text/html; charset=utf-8<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: 8bit<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'=?UTF-8?B?'</span><span style="color: #339933;">.</span><span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subject</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?='</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$header</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And that&#8217;s it. It took me a while googling for the issue to find it, but hopefully it saves your day!</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://graphicmaniacs.com/note/how-to-remove-on-behalf-of-in-php-mail-for-outlook-2007-and-2010/' addthis:title='How to remove &#8220;on behalf of&#8221; in PHP mail for Outlook 2007 and 2010 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://graphicmaniacs.com/note/how-to-remove-on-behalf-of-in-php-mail-for-outlook-2007-and-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

