<?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>Shaked Klein Orbach</title>
	<atom:link href="http://www.shakedos.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.shakedos.com</link>
	<description>echo &#039;Just smile&#039;;</description>
	<lastBuildDate>Sat, 21 Jan 2012 20:13:09 +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>Zend Framework, Gmail, SMTP and SSL</title>
		<link>http://www.shakedos.com/archives/437?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zend-framework-gmail-smtp-and-ssl</link>
		<comments>http://www.shakedos.com/archives/437#comments</comments>
		<pubDate>Sat, 21 Jan 2012 20:13:09 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[gmail smtp php]]></category>
		<category><![CDATA[openssl and smtp]]></category>
		<category><![CDATA[zend framework smtp]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=437</guid>
		<description><![CDATA[Topic says everything, isn't it? Description I had a problem sending emails while using Zend Framework with Gmail account. So I had to handle different types of errors: "Unable to connect via TLS" - being created by Zend Framework Exception. "Unable to find the socket transport "https" - did you forget to enable it when [...]]]></description>
			<content:encoded><![CDATA[<p>Topic says everything, isn't it?</p>
<h2>Description</h2>
<p>I had a problem sending emails while using Zend Framework with Gmail account. So I had to handle different types of errors:</p>
<ul>
<li>"Unable to connect via TLS" - being created by Zend Framework Exception.</li>
<li>"Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?" - PHP built in error message</li>
</ul>
<h2>Suggestions</h2>
<p><span id="more-437"></span></p>
<p>Before starting to code, you have to configure your PHP to work with <a title="PHP OpenSSL " href="http://www.php.net/manual/en/openssl.installation.php" target="_blank">php-openssl</a>.</p>
<p style="padding-left: 30px;"><span style="text-decoration: underline;">Linux</span>:</p>
<p style="padding-left: 30px;">Install openssl</p>
<p style="padding-left: 30px;">Install php5_openssl. I`m not sure about all of the distributions I did it only on OpenSuse:</p>
<p style="padding-left: 30px;"><em>zypper install php5_openssl</em></p>
<p style="padding-left: 30px;">I`m guessing that on CentOS it would be something like</p>
<p style="padding-left: 30px;"><em>yum install php5_openssl</em></p>
<p style="padding-left: 30px;"><em></em>And Ubuntu</p>
<p style="padding-left: 30px;"><em>apt-get install php5_openssl</em></p>
<p style="padding-left: 30px;"><span style="text-decoration: underline;">Windows</span>:</p>
<p style="padding-left: 30px;">Add<strong> <em>extension=php_openssl.dll</em></strong> to your <em>php.ini</em></p>
<p> After finishing it, please restart your apache<em>.</em></p>
<p>&nbsp;</p>
<p>Now check if the SSL module is installed:</p>
<p><em>php -m | grep ssl</em></p>
<p>will output:</p>
<p><em>openssl</em></p>
<p>Or try to check your <em>phpinfo</em>.</p>
<p>&nbsp;</p>
<p>Now you can use my code as an example:</p>
<h3><em>application.ini</em></h3>
<pre class="brush: php; gutter: true; first-line: 1">email.host 			= &#039;smtp.gmail.com&#039;
email.from		 	= &#039;info@yourdomain.com&#039;
email.name 			= &#039;Display Name&#039;
email.params.auth		= &#039;login&#039;
email.params.username 		= &#039;info@yourdomain.com&#039;
email.params.password 		= &#039;Password&#039;
email.params.ssl 		= &#039;ssl&#039;
email.params.port 		= 465

helper.perfix[] = &#039;My_Helper&#039;;</pre>
<h3><em>Bootstrap.php</em></h3>
<pre class="brush: php; gutter: true; first-line: 1">class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected  function _initConfig(){
    	 $config = new Zend_Config_Ini(
            APPLICATION_PATH . &#039;/configs/application.ini&#039;,
            APPLICATION_ENV
        );
        Zend_Registry::set(&#039;appConfig&#039;,$config);
    }
    protected function _initHelpers(){
    	 $perfix = Zend_Registry::get(&#039;appConfig&#039;)-&gt;helper-&gt;perfix-&gt;toArray();
    	 Zend_Controller_Action_HelperBroker::addPrefix($perfix[0]);
    }
}</pre>
<h3><em>IndexController.php</em></h3>
<pre class="brush: php; gutter: true; first-line: 1">class IndexController {
 	public function indexAction(){
		$helper = $this-&gt;_helper-&gt;mail(array(
				 			&#039;email&#039;		=&gt; &#039;myemail@gmail.com&#039;,
				 			&#039;subject&#039; 	=&gt; &#039;test subject&#039;,
				 			&#039;message&#039;	=&gt; &#039;just a test message&#039;
				 		));
		var_dump($helper);die;
	}
}</pre>
<h3><em>Mailer.php (helper)</em></h3>
<pre class="brush: php; gutter: true; first-line: 1">class My_Helper_Mail extends Zend_Controller_Action_Helper_Abstract {
	/**
	 * @var array email has to contain those values
	 */
	private static $_keys = array(&#039;email&#039;,&#039;subject&#039;,&#039;message&#039;);
	/**
	 * @var Zend_Mail
	 */
	private $_mail;

	const MAIL_BODY_CHARSET 	= &#039;utf8&#039;;
	const VALIDATION_DATA_ERROR = &#039;Email error, key %s is required and cannot be empty.&#039;;

	/**
	 * Execute everything, enables our class to work as helper ($this-&gt;_helper-&gt;mail(array()))
	 * @params array $data (Should contain self::$_keys)
	 * @return Zend_Mail
	 */
	public function direct(array $data){
		//validate keys and values
		self::_checkData($data);

		//prepare
		$this-&gt;_prepare($data);

		return $this-&gt;_send(self::_createTransportSmtp());
	}

	/**
	 * Validate data before send
	 * @param array $data
	 * @throws My_Helper_Mail_Exception
	 */
	private static function _checkData(array $data){
		foreach(self::$_keys as $value){
			if (empty($data[$value])){
				throw new My_Helper_Mail_Exception(sprintf(
					self::VALIDATION_DATA_ERROR,
					$value
				));
			}
		}
	}

	/**
	 * Prepre mail data
	 * @param array $data
	 */
	private function _prepare(array $data){
		$oAppConfig = Zend_Registry::get(&#039;appConfig&#039;)-&gt;email;

		$this-&gt;_mail = new Zend_Mail();
		$this-&gt;_mail-&gt;addTo($data[&#039;email&#039;]);
		$this-&gt;_mail-&gt;setSubject($data[&#039;subject&#039;]);
		$this-&gt;_mail-&gt;setBodyHtml($data[&#039;message&#039;],self::MAIL_BODY_CHARSET);
		$this-&gt;_mail-&gt;setFrom($oAppConfig-&gt;from,$oAppConfig-&gt;name);
	}

	/**
	 * Setup mail settings
	 * @return Zend_Mail_Transport_Smtp
	 */
	private static function _createTransportSmtp(){
		$config = Zend_Registry::get(&#039;appConfig&#039;); 

		$host  	= $config-&gt;email-&gt;host;
		$params	= $config-&gt;email-&gt;params;

		return new Zend_Mail_Transport_Smtp($host,$params-&gt;toArray());
	}

	/**
	 * Send mail
	 * @param Zend_Mail_Transport_Smtp $transport
	 * @return Zend_Mail
	 */
	private function _send(Zend_Mail_Transport_Smtp $transport){
		return $this-&gt;_mail-&gt;send($transport);
	}
}
class My_Helper_Mail_Exception extends Zend_Exception {}</pre>
<div style="font-size: 20px;">Or you may download the files <a title="Zend Framework Mail Helper" href="http://db.tt/R15OkDdR" target="_blank">Here</a></div>
<h2>Summary</h2>
<p>Using Zend Framework is pretty straight-forward when you have all of your server settings enabled.</p>
<p>You are more then welcome to update me if you would found any other solution or a problem.</p>
<p>&nbsp;</p>
<p>-Shak</p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/437" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/437/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress &#8211; avoiding wpautop method</title>
		<link>http://www.shakedos.com/archives/417?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-avoiding-wpautop-method</link>
		<comments>http://www.shakedos.com/archives/417#comments</comments>
		<pubDate>Sun, 08 Jan 2012 09:11:16 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[auto p]]></category>
		<category><![CDATA[automatic p tags]]></category>
		<category><![CDATA[remove p tag]]></category>
		<category><![CDATA[remove p tags]]></category>
		<category><![CDATA[wordpress p tag]]></category>
		<category><![CDATA[wpautop]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=417</guid>
		<description><![CDATA[Long time ha? So I`m working on a WordPress plugin for a while, and I found some common issues with plugins that need to be integrated with WordPress's posts. One of the main issues is the wpautop method. Description From WordPress's website: Changes double line-breaks in the text into HTML paragraphs (&#60;p&#62;...&#60;/p&#62;). WordPress uses it to [...]]]></description>
			<content:encoded><![CDATA[<p>Long time ha?</p>
<p>So I`m working on a <a title="Wordpress's website" href="http://www.wordpress.org" target="_blank">WordPress</a> plugin for a while, and I found some common issues with plugins that need to be integrated with WordPress's posts.</p>
<p>One of the main issues is the <em><a title="Codex - Function Reference/wpautop" href="http://codex.wordpress.org/Function_Reference/wpautop" target="_blank">wpautop</a></em> method.</p>
<h2>Description</h2>
<p>From WordPress's website:</p>
<blockquote><p>Changes double line-breaks in the text into HTML paragraphs (<tt>&lt;p&gt;...&lt;/p&gt;</tt>).</p>
<p>WordPress uses it to filter <a title="Template Tags/the content" href="http://codex.wordpress.org/Template_Tags/the_content">the content</a> and <a title="Template Tags/the excerpt" href="http://codex.wordpress.org/Template_Tags/the_excerpt">the excerpt</a>.</p></blockquote>
<p>Now lets dig a bit more inside ha?</p>
<pre class="brush: php; gutter: true; first-line: 1">function wpautop($pee, $br = 1) {
        if ( trim($pee) === &#039;&#039; )
                return &#039;&#039;;
        $pee = $pee . &quot;\n&quot;; // just to make things a little easier, pad the end
        $pee = preg_replace(&#039;|&lt;br /&gt;\s*&lt;br /&gt;|&#039;, &quot;\n\n&quot;, $pee);
        // Space things out a little
        $allblocks = &#039;(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)&#039;;
        $pee = preg_replace(&#039;!(&lt;&#039; . $allblocks . &#039;[^&gt;]*&gt;)!&#039;, &quot;\n$1&quot;, $pee);
        $pee = preg_replace(&#039;!(&lt;/&#039; . $allblocks . &#039;&gt;)!&#039;, &quot;$1\n\n&quot;, $pee);
        $pee = str_replace(array(&quot;\r\n&quot;, &quot;\r&quot;), &quot;\n&quot;, $pee); // cross-platform newlines
        if ( strpos($pee, &#039;&lt;object&#039;) !== false ) {
                $pee = preg_replace(&#039;|\s*&lt;param([^&gt;]*)&gt;\s*|&#039;, &quot;&lt;param$1&gt;&quot;, $pee); // no pee inside object/embed
                $pee = preg_replace(&#039;|\s*&lt;/embed&gt;\s*|&#039;, &#039;&lt;/embed&gt;&#039;, $pee);
        }
        $pee = preg_replace(&quot;/\n\n+/&quot;, &quot;\n\n&quot;, $pee); // take care of duplicates
        // make paragraphs, including one at the end
        $pees = preg_split(&#039;/\n\s*\n/&#039;, $pee, -1, PREG_SPLIT_NO_EMPTY);
        $pee = &#039;&#039;;
        foreach ( $pees as $tinkle )
                $pee .= &#039;&lt;p&gt;&#039; . trim($tinkle, &quot;\n&quot;) . &quot;&lt;/p&gt;\n&quot;;
        $pee = preg_replace(&#039;|&lt;p&gt;\s*&lt;/p&gt;|&#039;, &#039;&#039;, $pee); // under certain strange conditions it could create a P of entirely whitespace
        $pee = preg_replace(&#039;!&lt;p&gt;([^&lt;]+)&lt;/(div|address|form)&gt;!&#039;, &quot;&lt;p&gt;$1&lt;/p&gt;&lt;/$2&gt;&quot;, $pee);
        $pee = preg_replace(&#039;!&lt;p&gt;\s*(&lt;/?&#039; . $allblocks . &#039;[^&gt;]*&gt;)\s*&lt;/p&gt;!&#039;, &quot;$1&quot;, $pee); // don&#039;t pee all over a tag
        $pee = preg_replace(&quot;|&lt;p&gt;(&lt;li.+?)&lt;/p&gt;|&quot;, &quot;$1&quot;, $pee); // problem with nested lists
        $pee = preg_replace(&#039;|&lt;p&gt;&lt;blockquote([^&gt;]*)&gt;|i&#039;, &quot;&lt;blockquote$1&gt;&lt;p&gt;&quot;, $pee);
        $pee = str_replace(&#039;&lt;/blockquote&gt;&lt;/p&gt;&#039;, &#039;&lt;/p&gt;&lt;/blockquote&gt;&#039;, $pee);
        $pee = preg_replace(&#039;!&lt;p&gt;\s*(&lt;/?&#039; . $allblocks . &#039;[^&gt;]*&gt;)!&#039;, &quot;$1&quot;, $pee);
        $pee = preg_replace(&#039;!(&lt;/?&#039; . $allblocks . &#039;[^&gt;]*&gt;)\s*&lt;/p&gt;!&#039;, &quot;$1&quot;, $pee);
        if ($br) {
                $pee = preg_replace_callback(&#039;/&lt;(script|style).*?&lt;\/\\1&gt;/s&#039;, &#039;_autop_newline_preservation_helper&#039;, $pee);
                $pee = preg_replace(&#039;|(?&lt;!&lt;br /&gt;)\s*\n|&#039;, &quot;&lt;br /&gt;\n&quot;, $pee); // optionally make line breaks
                $pee = str_replace(&#039;&lt;WPPreserveNewline /&gt;&#039;, &quot;\n&quot;, $pee);
        }
        $pee = preg_replace(&#039;!(&lt;/?&#039; . $allblocks . &#039;[^&gt;]*&gt;)\s*&lt;br /&gt;!&#039;, &quot;$1&quot;, $pee);
        $pee = preg_replace(&#039;!&lt;br /&gt;(\s*&lt;/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^&gt;]*&gt;)!&#039;, &#039;$1&#039;, $pee);
        if (strpos($pee, &#039;&lt;pre&#039;) !== false)
                $pee = preg_replace_callback(&#039;!(&lt;pre[^&gt;]*&gt;)(.*?)&lt;/pre&gt;!is&#039;, &#039;clean_pre&#039;, $pee );
        $pee = preg_replace( &quot;|\n&lt;/p&gt;$|&quot;, &#039;&lt;/p&gt;&#039;, $pee );
        return $pee;
}</pre>
<p>You may find more at <a href="http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/formatting.php">http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/formatting.php</a></p>
<p>As you can see, this function changes a lot of things in WordPress's posts, such as:</p>
<ul>
<li>Adding \n after (almost) each HTML tag</li>
<li>Fixing new lines to cross platform newlines (\r\n to \n)</li>
<li>Changing the &lt;object&gt; tag</li>
<li><strong>Adding &lt;p&gt; tags</strong>.</li>
<li>Cleaning empty &lt;pre&gt; tags</li>
</ul>
<p>So I marked the most important issue about this function "Adding &lt;p&gt; tags".</p>
<h4>Why is it so important for me?</h4>
<p>As I wrote before it seems that one of the biggest problems for developers that develop WordPress plugins is the <em>wpautop</em> plugin. When they are trying to modify the user's posts, they always need to struggle with the &lt;p&gt; tags and sometimes they don't know how to handle them right.</p>
<h2>Suggestions...</h2>
<p><span id="more-417"></span></p>
<h3>What to do</h3>
<p>If I remember correctly , <em>wpautop</em> priority is set to 11 by default.</p>
<p>I have split my solution into 4 steps:</p>
<ol>
<li>Mark your posts with your own "signature"</li>
<li>Create your own HTML template and don't use &lt;p&gt; tags</li>
<li>Changing <em>the_posts</em></li>
<li>Removing the &lt;p&gt; tags from my plugin's HTML</li>
</ol>
<h5>How?</h5>
<h5>Marking your posts:</h5>
<p>Include special statement inside <em>post_content</em>, for example when adding new post you may add a text "my-plugin-text-needs-to-be-manipulated", so the user's post will look like:</p>
<blockquote><p>This is a new post</p>
<p>my-plugin-text-needs-to-be-manipulated</p>
<p>Thank you all!</p></blockquote>
<h5>Changing the posts:</h5>
<p><a href="http://pastebin.com/w58WqjHP">http://pastebin.com/w58WqjHP</a></p>
<pre class="brush: php; gutter: true; first-line: 1">/**
 * Require more work but does the job.
*/
class Posts {
	const CATCH_POST_PRIORITY = -32767;
	const TEXT_TO_CHANGE = &#039;my-plugin-text-needs-to-be-manipulated&#039;;
	/*
	 * Manipulate our plugin&#039;s text\data
	 * @param array $posts
	 * @return array
	 */
	public function manipulate($posts){
		$newPosts = array();
		foreach ($posts AS $post) {
			if (false === strpos($post-&gt;post_content,self::TEXT_TO_CHANGE)
				 || !self::IsPreviewMode($post-&gt;ID)){
				$newPosts[] = $post
				continue ;
			}

			//remove new lines
			//TODO: extract your data to your HTML (real plugin uses a View object and render&#039;s the data)
			$html = str_replace(&quot;\n&quot;,&quot;&quot;,file_get_content(&quot;some.html&quot;));
			//assign back to post content
			$post-&gt;post_content = str_replace(self::TEXT_TO_CHANGE,$html,$post-&gt;post_content);
			$newPosts[] = $post;
		}
		return $newPosts;
	}

	/**
	 * Check if we are in preview mode of current post id
	 * @param int $postID
	 * @return bool
	*/
	private static function IsPreviewMode($postID){
 		return isset($_GET[&#039;preview&#039;]) &amp;&amp; isset($_GET[&#039;p&#039;]) &amp;&amp; $_GET[&#039;p&#039;] != $postID;
	}
}

$posts = new Posts;
add_action(&#039;the_posts&#039; , array($posts, &#039;manipulate&#039;), Posts::CATCH_POST_PRIORITY);</pre>
<h5>Removing the &lt;p&gt; tags</h5>
<p><a href="http://pastebin.com/afk9SJNk">http://pastebin.com/afk9SJNk</a></p>
<pre class="brush: php; gutter: true; first-line: 1">/**
 * DOM Handler
*/
class Extended_DOMDocument extends DOMDocument {
	/**
	 * @var DOMElement $pluginStauts
	*/
	private $pluginStatus = false; 

	const CONTAINER = &quot;our_plugins_class_wrapper&quot;;
	const UTF8_META = &#039;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;&#039;; 

	public function __construct($post){
		parent::__construct(&quot;1.0&quot;, &quot;UTF-8&quot;);
		if (!@$this-&gt;loadHTML(self::UTF8_META.$post)){
			return ;
		}
		$this-&gt;isPluginInvolved();
	}

	private function isPluginInvolved(){
		$this-&gt;pluginStatus = $this-&gt;getElementByClassName(self::CONTAINER);
	}	

	/**
 	 * Remove p tags
	 * @return string
	 */
	public function removeWpAutoP(){
		$content = $this-&gt;saveHTML();
		if (!$this-&gt;pluginStatus){
			return $content;
		}
		$html = self::DOMinnerHTML($this-&gt;pluginStatus);
		return str_replace($html,preg_replace(&#039;#&lt;p&gt;(.*?)&lt;\/p&gt;#&#039;,&#039;$1&#039;,$html),$content);
	}

	/**
	 * @see http://stackoverflow.com/questions/5404941/php-domdocument-outerhtml-for-element
	 */
	public static function DOMinnerHTML($n, $outer=true) {
	    $d = new DOMDocument(&#039;1.0&#039;);
	    $b = $d-&gt;importNode($n-&gt;cloneNode(true),true);
	    $d-&gt;appendChild($b); $h = $d-&gt;saveHTML();
	    // remove outter tags
	    if (!$outer) $h = substr($h,strpos($h,&#039;&gt;&#039;)+1,-(strlen($n-&gt;nodeName)+4));
	    return $h;
	}

	/**
	* Get all elements that have a tag of $tag and class of $className
	*
	* @param string $className The class name to search for
	* @param string $tag       Tag of the items to search
	* @return array            Array of DOMNode items that match
	*/
	public function getElementsByClassName($className, $tag=&quot;*&quot;) {
		$nodes = array();
		$domNodeList = $this-&gt;getElementsByTagName($tag);
		for ($i = 0; $i &lt; $domNodeList-&gt;length; $i++) {
			$item = $domNodeList-&gt;item($i)-&gt;attributes-&gt;getNamedItem(&#039;class&#039;);
			if ($item) {
				$classes = explode(&quot; &quot;, $item-&gt;nodeValue);
				for ($j = 0; $j &lt; count($classes); $j++) {
					if ($classes[$j] == $className) {
						$nodes[] = $domNodeList-&gt;item($i);
					}
				}
			}
		}
		return $nodes;
	}

	/**
	 * Convenience method to return a single element by class name when we know there&#039;s only going to be one
	 *
	 * @param string $className The class name to search for
	 * @param string $tag       Tag of the items to search
	 * @return array            Array of DOMNode items that match
	 */
	public function getElementByClassName($className, $tag=&quot;*&quot;) {
		$nodes = $this-&gt;getElementsByClassName($className, $tag);
		return count($nodes) == 1 ? $nodes[0] : $nodes;
	}
}

// setting this filter to priority 12
add_filter(&#039;the_content&#039; , array(&#039;removeWpAutoP&#039;), 12);
/**
 * remove auto wp p tags
 * @param string $content
 * @return string
 */
function rm_wpautop($content) {
	$dom = new Extended_DOMDocument($content);
	$content = $dom-&gt;removeWpAutoP();
	return $content;
}</pre>
<h3>What not to do</h3>
<p>It's pretty easy -don't remove the filter.</p>
<h4>Why?</h4>
<p>Because removing the filter most of the time creates bugs and problems with other posts and plugins. For example, when disabling the function you would notice that sometimes the post won't have any newlines at all.</p>
<h2>Summarize</h2>
<p>Using WordPress's <em>wpautop</em> making our life very hard. As I see it, WordPress should give their developers more freedom while writing their plugins.<br />
This might not be the most useful way to write this fix, but then you may ask if its useful to use WordPress <img src='http://www.shakedos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Some of the functions were found on Google or in different websites, I didn't write them all although I did write the "logic". I have tried to keep my sources written in the code's comments (such as <a title="Stackoverflow" href="http://www.stackoverflow.com" target="_blank">stackoverflow</a>), so if you would find something that belongs to you, please contact me to add your name or remove the script.</p>
<p>Hope this guide will help other as it helped me.</p>
<p>-Shak</p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/417" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/417/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Managing zip files with ZipArchive</title>
		<link>http://www.shakedos.com/archives/396?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-managing-zip-files-with-ziparchive</link>
		<comments>http://www.shakedos.com/archives/396#comments</comments>
		<pubDate>Sun, 18 Dec 2011 01:17:44 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[OpenSuse]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[pear zip]]></category>
		<category><![CDATA[pecl zip]]></category>
		<category><![CDATA[php zip]]></category>
		<category><![CDATA[ZipArchive]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=396</guid>
		<description><![CDATA[Requirements PHP 5.2 or greater (would be a bit sad to know that someone is still using PHP 4)  Upgrade PEAR to latest version  Upgrade PECL to latest version  Installing PHP ZipArchive library by using PECL's zip package Installation  I will use pecl to install ZipArchive PHP library. Open terminal and execute pecl install zip Updating your php.ini: Linux: [...]]]></description>
			<content:encoded><![CDATA[<h2><span style="text-decoration: underline;">Requirements</span></h2>
<ol>
<li><span style="font-size: medium;"><a title="php.net website " href="http://www.php.net" target="_blank">PHP 5.2</a> or greater (would be a bit sad to know that someone is still using PHP 4) </span></li>
<li><span style="font-size: medium;">Upgrade <a title="PHP - PEAR" href="http://pear.php.net" target="_blank">PEAR</a> to latest version </span></li>
<li><span style="font-size: medium;">Upgrade <a title="PHP - PECL" href="http://pecl.php.net" target="_blank">PECL</a> to latest version </span></li>
<li><span style="font-size: medium;">Installing <a title="PHP ZipArchive library" href="http://www.php.net/manual/en/class.ziparchive.php" target="_blank">PHP ZipArchive</a> library by using <a title="PECL Zip Package" href="http://pecl.php.net/package/zip" target="_blank">PECL's zip package</a></span></li>
</ol>
<h2><span style="text-decoration: underline;">Installation</span> </h2>
<p><span style="font-size: medium;">I will use <em>pecl </em>to install <em>ZipArchive PHP</em> library.</span></p>
<ol>
<li><span style="font-size: medium;">Open terminal and execute <em>pecl install zip</em></span></li>
<li><span style="font-size: medium;">Updating your <em>php.ini</em>:</span></li>
<ol>
<li><span style="font-size: medium;">Linux: <a title="Find your php.ini file" href="http://www.shakedos.com/archives/402" target="_blank">find your php.ini file</a> and add "<em>extension=zip.so"</em></span></li>
<li><span style="font-size: medium;">Windows: same as one, just add "<em>extension=zip.dll</em>" </span></li>
</ol>
<li><span style="font-size: medium;">Restart httpd\apache </span></li>
<ol>
<li><span style="font-size: medium;"><em>service httpd restart</em></span></li>
<li><span style="font-size: medium;"><em>apache2ctl restart</em></span></li>
<li><span style="font-size: medium;">or any other way that you like</span></li>
</ol>
</ol>
<h2><span style="text-decoration: underline;">Usage Example</span></h2>
<p><span style="font-size: medium;">There are many different ways to use and build Zip helpers. I will just demonstrate an example for using ZipArchive. </span></p>
<p><span style="font-size: medium;"> Pastebin: <a href="http://pastebin.com/J2M0jjQG">http://pastebin.com/J2M0jjQG</a></span></p>
<p><span style="font-size: medium;"> Inline... </span></p>
<p><span id="more-396"></span></p>
<pre class="brush: php; gutter: true; first-line: 1">/**
 * ZipArchiveHelper class
*/
class ZipArchiveHelper {
	/**
	 * @var ZipArchive $_zipArchive
	*/
	private $_zipArchive;
	/**
	 * @var array $_excludeList
	*/
	private $_excludeList;

	const TIMEOUT = 5000; 

	/**
	 * Get files list by path
	 * @param string $sourcePath
	 * @return RecursiveIteratorIterator
	*/
	private function _getFilesList($sourcePath){
		$dirlist = new RecursiveDirectoryIterator($sourcePath);
		$filelist = new RecursiveIteratorIterator($dirlist);

		return $filelist;
	}

	/**
	 * Create Zip File
	 * @param string $zipFileName
	 * @param string $sourcePath
	 * @param array[optional] $excludeList
	 * @return string|false
	*/
	public function createZipFile($zipFileName,$sourcePath,array $excludeList = array()){
			//Set PHP timeout
			ini_set(&#039;max_execution_time&#039;, self::TIMEOUT);

			//set exclude list
			$this-----&gt;_excludeList = $excludeList; 

			//set new zip archive object
			$this-&gt;_setZipArchive(); 

			//generate new file
			$this-&gt;_newZipFile($zipFileName); 

			//compress
			$this-&gt;_compress($sourcePath); 

			//get status
			$retValue = $this-&gt;_zipArchive-&gt;getStatusString(); 

			//close zip archive manager
			$this-&gt;_zipArchive-&gt;close();

			return $retValue;
	}

	/**
	 * Set new ZipArchive instance
	 * Seperated and protected for future unit tests
	 * @return void
	*/
	protected function _setZipArchive(){
		$this-&gt;_zipArchive = new ZipArchive;
	}

	/**
	 * Open new|existing zip file
	 * @param int $type - 	Overwrite by default. (you may use other options, e.g ZipArchive::CREATE)
	 * @throw Exception
	 * @return void
	*/
	protected function _newZipFile($zipFileName,$type=ZipArchive::OVERWRITE){
		if ($this-&gt;_zipArchive-&gt;open(&quot;$zipFileName&quot;, $type) !== TRUE) {
				throw new Exception(&quot;Could not open archive&quot;);
		}
	}

	/**
	 * Validate file by checking if exists and not excluded type
	 * @param string $fileName
	 * @return bool
	*/
	private function _isValidFile($fileName){
		if (!is_file($fileName)){
			return false ;
		} 

		foreach($this-&gt;_excludeList as $toExclude){
			if (strpos($fileName,$toExclude) !== false){
				return false;
			}
		}	

		return true;
	}

	/**
	 * Compress to ZIP file
	 * @return bool
	*/
	private function _compress($sourcePath){
		//get file list
		$filelist = $this-&gt;_getFilesList($sourcePath); 

		//add files to new zip file
		foreach ($filelist as $fileName=&gt;$value) {
			if(!$this-&gt;_isValidFile($fileName)){
				continue ;
			}

			//you should use sprintf for this to work on both *NIX and Windows OS
			//note that str_replace is just for my example, you don&#039;t really have to use it.
			$value = sprintf(&quot;%s&quot;,str_replace($sourcePath,&#039;&#039;,$value));

			if (!$this-&gt;_zipArchive-&gt;addFile($fileName,$value)){
				 throw new Exception(&quot;ERROR: Could not add file: $fileName&quot;);
			}
		}

		return true;
	}
}
//PHP &gt;= 5.3 just throws this annoying warning
date_default_timezone_set(&#039;Asia/Jerusalem&#039;);

$zipHelper = new ZipArchiveHelper();
try {
	var_dump($zipHelper-&gt;createZipFile(
		&#039;shakedos.zip&#039;,
		&#039;/tmp/zend_debug&#039;,
		array(&#039;.svn&#039;)
	));
} catch (Exception $e){
	var_dump($e-&gt;getMessage());
}
</pre>
<h2><span style="text-decoration: underline;">Known Issues</span></h2>
<ol>
<li><span style="font-size: medium;">Did you define your PHP extension directory correct ? </span></li>
<li><span style="font-size: medium;">Windows and *NIX system works different by using the opposite slash  "/"(*NIX) or "\"(Windows) - my solution is to use <em>sprintf()</em> </span><br /><span style="font-size: medium;"> <a href="http://stackoverflow.com/questions/4620205/php-ziparchive-corrupt-in-windows">http://stackoverflow.com/questions/4620205/php-ziparchive-corrupt-in-windows</a></span></li>
<li><span style="font-size: medium;">Downloading the script sometimes requires to send some different header, the following example was taken from the <a title="Stackoverflow" href="http://stackoverflow.com" target="_blank">stackoverflow</a> link above:</span></li>
</ol>
<div><span style="font-size: small;"><br /></span></div>
<pre class="brush: bash; gutter: true; first-line: 1">header(&quot;Cache-Control: public&quot;);
header(&quot;Pragma: public&quot;);
header(&quot;Expires: 0&quot;);
header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);
header(&quot;Cache-Control: public&quot;);
//header(&quot;Content-Description: File Transfer&quot;);
//header(&quot;Content-type: application/zip&quot;);
header(&quot;Content-Disposition: attachment; filename=\&quot;YOUR_FILE_NAME_HERE.zip\&quot;&quot;);
//header(&quot;Content-Transfer-Encoding: binary&quot;);
header(&quot;Content-length: &quot; . filesize($filename));
</pre>
<p>&nbsp;</p>
<p><span style="font-size: small;">Hope I helped, </span></p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/396" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/396/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find your php.ini file</title>
		<link>http://www.shakedos.com/archives/402?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-find-your-php-ini-file</link>
		<comments>http://www.shakedos.com/archives/402#comments</comments>
		<pubDate>Sun, 18 Dec 2011 00:15:03 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[edit php.ini]]></category>
		<category><![CDATA[find php.ini]]></category>
		<category><![CDATA[php.ini]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=402</guid>
		<description><![CDATA[Finding your php.ini is pretty straight forward task:  open terminal or cmd  execute php --ini if php is undefined you should add it to your PATH or just execute "/your/path/to/php --ini" php.ini has several modes (path is different sometimes...): using one file:  Configuration File (php.ini) Path: /etc/php5/cliLoaded Configuration File: /etc/php5/cli/php.ini using several different files (will help to maintain [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium; font-family: verdana, geneva;">Finding your <em>php.ini</em> is pretty straight forward task: </span></p>
<ol>
<li><span style="font-size: medium; font-family: verdana, geneva;">open terminal or cmd </span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;">execute <em>php --ini</em> if <em>php</em> is undefined you should add it to your PATH or just execute "<em>/your/path/to/php --ini"</em></span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;"><em>php.ini </em>has several modes (path is different sometimes...):</span></li>
<ol>
<li><span style="font-size: medium; font-family: verdana, geneva;">using one file: </span>
<p><span style="font-size: medium; font-family: verdana, geneva;">Configuration File (php.ini) Path: /etc/php5/cli</span><br /><span style="font-size: medium; font-family: verdana, geneva;">Loaded Configuration File: /etc/php5/cli/php.ini</span></p>
</li>
<li><span style="font-size: medium; font-family: verdana, geneva;">using several different files (will help to maintain common settings between <em>cli php</em><em>.ini</em> and <em>httpd</em> <em>php.ini</em></span>
<p><span style="font-size: medium; font-family: verdana, geneva;">Scan for additional .ini files in: /etc/php5/conf.d</span><br /><span style="font-size: medium; font-family: verdana, geneva;">Additional .ini files parsed: /etc/php5/conf.d/ctype.ini,</span><br /><span style="font-size: medium; font-family: verdana, geneva;">/etc/php5/conf.d/curl.ini, </span><br /><span style="font-size: medium; font-family: verdana, geneva;">/etc/php5/conf.d/dom.ini,</span><br /><span style="font-size: medium; font-family: verdana, geneva;">/etc/php5/conf.d/gd.ini,</span><br /><span style="font-size: medium; font-family: verdana, geneva;">/etc/php5/conf.d/hash.ini,</span><br /><span style="font-size: medium; font-family: verdana, geneva;">............more .ini files here............  </span></p>
<p><span style="font-size: medium; font-family: verdana, geneva;">files content could be "<em>extension=gd.so" (unix) </em>or "<em>extension=gd.dll</em>" (<em>windows</em>)</span></li>
</ol>
<li><span style="font-size: medium; font-family: verdana, geneva;">there are two more options to get your <em>ini</em> files: </span></li>
<ol>
<li><span style="font-size: medium; font-family: verdana, geneva;">execute in cli mode: "<em>php --i | grep .ini</em>"</span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;">write your own script and check via browser:</span><br /><span style="font-size: medium; font-family: verdana, geneva;"><em>&lt;?php phpinfo(); ?&gt; </em> </span></li>
</ol>
</ol>
<p><span style="font-size: medium;"><span style="font-family: verdana, geneva;">That's it, now you can just edit your </span><em style="font-family: verdana, geneva;">php.ini</em><span style="font-family: verdana, geneva;"> with anything you think you will need for future PHP programming. </span><br /><span style="font-family: verdana, geneva;">More about </span><em><span style="font-family: verdana, geneva;">php.ini</span></em> may be found at <a href="http://php.net/manual/en/ini.php">http://php.net/manual/en/ini.php</a><em><span style="font-family: verdana, geneva;"> </span></em></span></p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/402" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/402/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Split String Function Fix (split_str)</title>
		<link>http://www.shakedos.com/archives/367?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-split-string-function-fix-split_str</link>
		<comments>http://www.shakedos.com/archives/367#comments</comments>
		<pubDate>Wed, 23 Nov 2011 23:20:57 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MySQL Split String]]></category>
		<category><![CDATA[MySQL split utf8]]></category>
		<category><![CDATA[split string]]></category>
		<category><![CDATA[split_str]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=367</guid>
		<description><![CDATA[While working on one my projects, I was needed to use split_str function in MySQL. I Googled for it and found two answers (which are exactly the same - one is leading to the other):  Federico Cargnelutti - MySQL Split String Function Stackoverflow - MYSQL - Array data type, split string Everything worked great while [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: verdana, geneva; font-size: medium;">While working on one my projects, I was needed to use split_str function in MySQL. I Googled for it and found two answers (which are exactly the same - one is leading to the other): </span></p>
<p><span style="font-family: verdana, geneva; font-size: medium;"><a title="Federico Cargnelutti - MySQL Split String Function" href="http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/" target="_blank">Federico Cargnelutti - MySQL Split String Function</a></span><br/><br/><br />
<span style="font-family: verdana, geneva; font-size: medium;"><a title="Stackoverflow - MYSQL - Array data type, split string" href="http://stackoverflow.com/questions/4078838/mysql-array-data-type-split-string" target="_blank">Stackoverflow - MYSQL - Array data type, split string</a></span><br/></p>
<pre><span style="font-family: verdana, geneva; font-size: medium;">Everything worked great while using different delimiters, such as: "," , "||", "@@@", "###" or any other delimiter. I was using delimiters which their length > 1, exmaple: </span></pre>
<pre class="brush: sql; gutter: true; first-line: 1">
select split_str(‘ABC,,BA,,abc’,',,’,3);
//result: “abc”
</pre>
<p><span style="font-size: medium; font-family: verdana, geneva;">Seems good, ha? But then I`v noticed that there is a problem. When my full string contains two bytes characters (e.g: ¼), everything is breaking a part. Lets see the following exmaple:</span></p>
<pre class="brush: sql; gutter: true; first-line: 1">
select split_str(‘ABC¼,,BA,,abc’,',,’,3);
//result: “,abc” (delimiter was still there)
</pre>
<p><span style="font-size: medium; font-family: verdana, geneva;">So how do we fix it?  Seems that we need to change split_str function, all we have to do is to use <a title="MySQL CHAR_LENGHT()" href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length" target="_blank">CHAR_LENGTH</a>() and not <a title="MySQL LENGTH()" href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_length" target="_blank">LENGTH()</a>. There is a difference between those functions which you can read at <a title="MySQL - CHAR_LENGTH()" href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length" target="_blank">MySQL.com</a> website or just read the following quote: </span></p>
<blockquote>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length"><code>CHAR_LENGTH(<em><code>str</code></em>)</code></a></p>
<p>Returns the length of the string <em><code>str</code></em>, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_length"><code>LENGTH()</code></a> returns <code>10</code>, whereas <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length"><code>CHAR_LENGTH()</code></a>returns <code>5</code>.</p>
</blockquote>
<p><span style="font-size: medium; font-family: verdana, geneva;"> Enough talking. This is the function after my little fix: </span></p>
<pre class="brush: sql; gutter: true; first-line: 1; highlight: [9]">
<br/>
CREATE FUNCTION SPLIT_STR(
  x VARCHAR(255),
  delim VARCHAR(12),
  pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
       CHAR_LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
       delim, '');
</pre>
<p>
<span style="font-family: verdana, geneva; font-size: medium;"><br />
Then using the same example I`v used above:<br />
</span>
</p>
<pre class="brush: sql; gutter: true; first-line: 1; highlight: [3]">
<br/>
select split_str(‘ABC¼,,BA,,abc’,',,’,3);
//result: “abc”
<br/>
</pre>
<p>
<span style="font-family: verdana, geneva; font-size: medium;"><br />
I want to say thank to <a title="Federico Cargnelutti" href="http://blog.fedecarg.com/" target="_blank">Federico Cargnelutti</a> that helped us by writing the above function.<br />
<br/><br />
Shak.<br />
</span></p>
<div class="al2fb_likers"><a href="http://www.facebook.com/profile.php?id=1042185552" rel="nofollow">Or Ovadia</a> <span class="al2fb_liked">liked this post</span></div><div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/367" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/367/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup\Configure Zend Debugger</title>
		<link>http://www.shakedos.com/archives/380?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setupconfigure-zend-debugger</link>
		<comments>http://www.shakedos.com/archives/380#comments</comments>
		<pubDate>Sun, 20 Nov 2011 21:44:58 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[php debugger]]></category>
		<category><![CDATA[zend debugger]]></category>
		<category><![CDATA[zend studio]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=380</guid>
		<description><![CDATA[Using a debugger is very important while writing code, so lets see how to do it with PHP and Zend Debugger:  Install Eclipse or Zend Studio  If you have installed Eclipse, you should install two more things:  PDT (PHP Development Tools) Zend Debugger After extracting everything, search for ZendDebugger.so path Edit your php.ini or create another [...]]]></description>
			<content:encoded><![CDATA[<style>
#zend_debuger_setup_configure img { width: 450px; }
</style>
<div id="zend_debuger_setup_configure">
<p><span style="font-size: medium;">Using a debugger is very important while writing code, so lets see how to do it with PHP and Zend Debugger: </span></p>
<ol>
<li><span style="font-size: medium;">Install <a title="Eclipse" href="http://www.eclipse.org/" target="_blank">Eclipse</a> or <a title="Zend - The PHP Company " href="http://www.zend.com/" target="_blank">Zend Studio</a> </span></li>
<li><span style="font-size: medium;">If you have installed Eclipse, you should install two more things:</span></li>
<ol>
<li><span style="font-size: medium;"> <a title="PDT - PHP Development Tools" href="http://eclipse.org/pdt/downloads/" target="_blank">PDT</a> (PHP Development Tools)</span></li>
<li><span style="font-size: medium;"><a title="Zend Debugger" href="http://www.zend.com/en/community/pdt" target="_blank">Zend Debugger</a></span></li>
</ol>
<li><span style="font-size: medium;">After extracting everything, search for <em>ZendDebugger.so</em> path</span></li>
<li><span style="font-size: medium;">Edit your <em>php.ini</em> or create another ini --> <em>zend.ini</em> which will <a title="Loading .ini files with PHP" href="http://stackoverflow.com/questions/1391808/how-do-i-include-a-php-ini-file-in-another-php-ini-file" target="_blank">have to be loaded by your PHP</a> and add:</span><br /> 
<pre class="brush: shell; gutter: true; first-line: 1">; Loading Zend Debugger Extension
zend_extension=/your/path/to/ZendDebugger.so
;
; use 127.0.0.1 for local host, or you another local network IP
zend_debugger.allow_hosts=127.0.0.1
;
;
Expose Zend Debugger
;
;
never - do not expose (default)
;
always - expose to whoever want to know
;
allowed_hosts - expose only if request comes from an IP listed above
;
zend_debugger.expost_remotely=always
</pre>
</li>
<li><span style="font-size: medium;">Save &amp; Restart Apache</span></li>
<li><span style="font-size: medium;">Verify your<em> <a title="phpinfo();" href="http://php.net/manual/en/function.phpinfo.php" target="_blank">phpinfo()</a></em></span></li>
<ol>
<li><a title="PHP: phpinfo() Zend Debugger settings " href="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger4.png&amp;_wpnonce=4f2457de9f" target="_blank"><img src="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger4.png&_wpnonce=78f30c3135" /></a></li>
</ol>
<li><span style="font-size: medium;">Download <a title="Zend Debugger - FireFox Extension (Addon\Toolbar)" href="http://www.zend.com/en/products/studio/downloads" target="_blank">FireFox</a> or <a title="Zend Debugger - Chrome Extension" href="http://www.d23.nl/zend-debugger-toolbar-extension-for-chrome/" target="_blank">Chrome Extension</a> (Chrome extension is <span style="text-decoration: underline;"><strong>not</strong></span> official extension by Zend) </span></li>
<li><span style="font-size: medium;">Configure Eclipse \ Zend Studio settings:</span></li>
<ol>
<li><a title="Zend Studio Settings for Zend Debugger" href="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger_2.png&amp;_wpnonce=4f2457de9f" target="_blank"><img src="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger_2.png&_wpnonce=78f30c3135" /></a></li>
<li><a title="Zend Studio Settings for Zend Deugger" href="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger.png&amp;_wpnonce=4f2457de9f" target="_blank"><img src="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger.png&_wpnonce=78f30c3135" /></a></li>
</ol>
<li><span style="font-size: medium;">Configure your extension settings:</span></li>
<ol>
<li><a title="Zend Extension Settings for Zend Debugger" href="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger_3.png&amp;_wpnonce=4f2457de9f" target="_blank"><img src="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/zend_debugger_3.png&_wpnonce=78f30c3135" /></a></li>
</ol>
<li><span style="font-size: medium;">Start debugging!:) </span></li>
</ol>
<div><span style="font-size: medium;">Helpful links: </span></div>
<div><span style="font-size: medium;"><a title="cmanon.com" href="http://cmanon.com/blog/computer/programming/zend-debugger-eclipse-apache/" target="_blank">cmanon.com</a></span></div>
<div><span style="font-size: medium;"><a title="Stackoverflow - PHP 5.3.5 and Zend Debugger" href="http://stackoverflow.com/questions/7188149/php-5-3-5-with-zend-debugger" target="_blank">stackoverflow - PHP 5.3.5 and Zend Debugger</a></span></div>
<div> </div>
<div><span style="font-size: medium;"><a title="How to install Zend Debugger on Windows without Zend Core/Platform" href="http://www.devcha.com/2008/01/how-to-install-zend-debugger-on-windows.html" target="_blank">devcha.com - Installing Zend Debugger on Windows</a></span></div>
<p>&nbsp;</p>
<p><span style="font-size: medium;"><span style="text-decoration: underline;">Note for Zend Studio 8.x users</span>: </span></p>
<p><span style="font-size: medium;">I suggest that you will update your Zend Studio application by using the following instructions: </span></p>
<p><span style="font-size: medium;"><a href="http://forums.zend.com/viewtopic.php?f=59&amp;t=10468">http://forums.zend.com/viewtopic.php?f=59&amp;t=10468</a></span></p>
<p>Enjoy!</p>
</div>
<div class="al2fb_likers"><a href="http://www.facebook.com/profile.php?id=595370654" rel="nofollow">Yuval Halfon</a> <span class="al2fb_liked">liked this post</span></div><div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/380" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/380/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: Insert\Update MySQL BIT(1) field</title>
		<link>http://www.shakedos.com/archives/356?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-insertupdate-mysql-bit1-field</link>
		<comments>http://www.shakedos.com/archives/356#comments</comments>
		<pubDate>Fri, 18 Nov 2011 21:03:00 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bit data type]]></category>
		<category><![CDATA[BIT datatype]]></category>
		<category><![CDATA[BIT field]]></category>
		<category><![CDATA[MySQL bool]]></category>
		<category><![CDATA[MySQL boolean]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=356</guid>
		<description><![CDATA[Today I`v noticed to interested things:  A nice sentence or a motto that I really liked:  "When you do a search, and it comes back with no results, it’s a sign that you need to write something." (Taken from Here  Didn't find any straight answer on Google for my question: "How to insert\update a bit field [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium;">Today I`v noticed to interested things: </span></p>
<ol>
<li><span style="font-size: medium;">A nice sentence or a motto that I really liked: </span>
<p><span style="font-size: medium;">"When you do a search, and it comes back with no results, it’s a sign that you need to write something." (Taken from <a title="Gordon P. Hemsley Linguist by day. Web developer by night." href="http://gphemsley.wordpress.com/2010/02/08/php-mysql-and-the-bit-field-type/" target="_blank">Here</a></span><br /> </li>
<li><span style="font-size: medium;">Didn't find any straight answer on Google for my question: "How to insert\update a bit field with PHP": </span></li>
</ol>
<p style="padding-left: 30px;"><span style="font-size: medium;">So with MySQL you would use:</span></p>
<pre class="brush: sql; gutter: true; first-line: 1">INSERT INTO t SET b = b'1'; // Or b'0' </pre>
<p style="padding-left: 30px;"> <span style="font-size: medium;">And with PHP you would use boolean type: </span></p>
<pre class="brush: php; gutter: true; first-line: 1">

//$db instanceof ActiveRecord, that's only for the following example
//you can use other ways to insert\update your MySQL DB. 

$db-&gt;insert(array('b'=&gt;true,'c'=&gt;false)); //true = b'1' , false = b'0'

$db-&gt;update(array('b'=&gt;true,'c'=&gt;false)); //true = b'1' , false = b'0'
</pre>
<p>Hope I helped, </span><br />
Shak.</span></p>
<div><code><br /></code></div>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/356" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/356/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework &#8211; How to redirect/get application base URL</title>
		<link>http://www.shakedos.com/archives/335?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zend-framework-how-to-redirectget-application-base-url</link>
		<comments>http://www.shakedos.com/archives/335#comments</comments>
		<pubDate>Fri, 14 Oct 2011 10:04:49 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[base URL]]></category>
		<category><![CDATA[homepage]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[Zend Framwork]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=335</guid>
		<description><![CDATA[What is exactly base URL ?  Base URL is sub.domain.end, for example:  if your full URI is http://www.yoursite.com/some/params/id/1, so base URL will be www.yoursite.com Redirect to application base URL Sometimes you would want to be able to redirect from one page to  your main homepage, for example: User A enter Site B.com login page User B enter username and [...]]]></description>
			<content:encoded><![CDATA[<h3>What is exactly base URL ? </h3>
<pre>Base URL is sub.domain.end, for example: </pre>
<pre>if your full URI is <em><strong>http://www.yoursite.com/some/params/id/1</strong></em>, so base URL will be <em><strong>www.yoursite.com</strong></em></pre>
<h3>Redirect to application base URL</h3>
<p>Sometimes you would want to be able to redirect from one page to  your main homepage, for example:</p>
<ol>
<li><strong>User A</strong> enter <strong>Site B.com</strong> login page</li>
<li><strong>User B</strong> enter username and password and he had been successfully logged in</li>
<li><strong>User B </strong>is being redirect to <strong>Site B.com</strong></li>
</ol>
<p>As I like to say, if you are reading this post, you would probably need some help about its subject:</p>
<p>There are two ways:</p>
<pre class="brush: php; gutter: true;  highlight: [5,7]; html-script: true">
public function loginAction(){
.
.
  if (user is logged in successfully) {
      $this->_helper->redirector->gotoUrl();    //Option 1
      // OR setGotoUrl() uses gotoUrl() when no param is being passed
      $this->_helper->redirector->setGotoUrl(); //Option 2
  }
.
.
}
</pre>
<h3> How do I get base URL string?  </h3>
<pre class="brush: php; gutter: true; highlight: [2]; html-script: true">
public function loginAction(){
 $baseURL = $this->getRequest()->getHttpHost();
 /*
   When using redirect helper and full URL
   you will have to attach http(s)://
   which means you will have to use isSSL() method
 */
}
</pre>
<p>&nbsp;</p>
<h5>Note:</h5>
<p>My suggestion is to create  BaseControoler that will handle your current HTTP request &amp; base URL: </p>
<pre class="brush: php; gutter: true; highlight: [9,11];  html-script: true">
class BaseController extends Zend_Controller_Action{
 	/**
 	 *  @var Zend_Controller_Request_Http $_request
         */
	protected $_request;

	protected function init(){
 	 	//Save request
 	 	$this->_request = $this->getRequest();
 	        //Save httpHost (base URL)
 	 	$this->_httpHost = $this->_request->getHttpHost();
 	 	$this->siteInit();
  	} 

 	protected siteInit(){
 	 	/*
 	 	 	You don't really need it
 	 	 	I just prefer to know that if someone creates
 	 	 	another controller he won't have to call parent::init()
 	 	*/
 	}
}
</pre>
<p>After creating BaseController you have to setup your own controller(s): </p>
<pre class="brush: php; gutter: true; highlight: [2,5]">
//Extend BaseController
class IndexController extends BaseController {

 	public function indexAction(){
 	 	var_dump($this->_httpHost,$this->_request->getParams());
 	}
}</pre>
<p>That it for today, </p>
<p>Shak</p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/335" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/335/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Opensuse &#8211; Asus yXXy (n53j) &#8211; Speakers Audio</title>
		<link>http://www.shakedos.com/archives/329?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=opensuse-asus-yxxy-n53j-speakers-audio</link>
		<comments>http://www.shakedos.com/archives/329#comments</comments>
		<pubDate>Thu, 13 Oct 2011 21:08:33 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSuse]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[alsa]]></category>
		<category><![CDATA[Asus N53J]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[opensuse]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=329</guid>
		<description><![CDATA[Hey,  For long time I had an annoying problem with my speakers on my Asus n53j laptop. I`v googled this problem for long time and nothing. But finally I`v found the VERY-EASY solution:  Open alsamixer in terminal Choose your sound card (F6)  Continue till you see this screen:  Go to "Speakers" and make volume up [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium; font-family: verdana, geneva;">Hey, </span></p>
<p><span style="font-size: medium; font-family: verdana, geneva;">For long time I had an annoying problem with my speakers on my Asus n53j laptop. I`v googled this problem for long time and nothing. But finally I`v found the VERY-EASY solution: </span></p>
<ol>
<li><span style="font-size: medium; font-family: verdana, geneva;">Open <em>alsamixer</em> in terminal</span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;">Choose your sound card (F6) </span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;">Continue till you see this screen:</span><br /><span style="font-size: medium; font-family: verdana, geneva;"> <img src="http://www.shakedos.com/wp-content/plugins/pressbox/pressbox.php?display=/public/uploads/alsamixer.png&_wpnonce=78f30c3135" /></span></li>
<li><span style="font-size: medium; font-family: verdana, geneva;">Go to "Speakers" and make volume up to 100 </span></li>
</ol>
<div><span style="font-size: medium; font-family: verdana, geneva;">Thats it. I hope that it will help you.</span></div>
<div><span style="font-size: medium; font-family: verdana, geneva;">Shak</span></div>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/329" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/329/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Highlight your text and share short URL</title>
		<link>http://www.shakedos.com/archives/322?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=highlight-your-text-and-share-short-url</link>
		<comments>http://www.shakedos.com/archives/322#comments</comments>
		<pubDate>Thu, 06 Oct 2011 01:15:43 +0000</pubDate>
		<dc:creator>Shaked</dc:creator>
				<category><![CDATA[Chrome Extensions]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Highlight]]></category>
		<category><![CDATA[highlight text]]></category>
		<category><![CDATA[Short url]]></category>

		<guid isPermaLink="false">http://www.shakedos.com/?p=322</guid>
		<description><![CDATA[Today I wanted to share a text with my brother so I thought about making new tool that will highlight my text and create short URL. After some googling I have found a very nice tool that already implement it "Yellow highlighter pen for web". This plugin is working on Chrome and may be found [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wanted to share a text with my brother so I thought about making new tool that will highlight my text and create short URL. After some googling I have found a very nice tool that already implement it "Yellow highlighter pen for web". This plugin is working on Chrome and may be found at<a title="Marker.to web page" href="http://www.marker.to" target="_blank">http://www.marker.to</a> or at <a title="Google web store" href="https://chrome.google.com/webstore/detail/lnmengjdnfjbochkdkcjbbpildacancp" target="_blank">Google chrome extension web store</a> </p>
<p>Use it carefully <img src='http://www.shakedos.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<p>&nbsp;</p>
<p>Shak. </p>
<div class="al2fb_like_button"><div id="fb-root"></div><script type="text/javascript">
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=188624057851679";
  fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
</script>
<fb:like href="http://www.shakedos.com/archives/322" layout="standard" show_faces="true" width="450" action="like" font="verdana" colorscheme="light" ref="AL2FB"></fb:like></div>]]></content:encoded>
			<wfw:commentRss>http://www.shakedos.com/archives/322/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

