<?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>Piotr Zaniewicz &#187; Web</title>
	<atom:link href="http://piotr.eldora.pl/category/web/feed" rel="self" type="application/rss+xml" />
	<link>http://piotr.eldora.pl</link>
	<description>Ideas not to be forgotten...</description>
	<lastBuildDate>Sun, 25 Apr 2010 16:50:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fractions in PHP and whole numbers</title>
		<link>http://piotr.eldora.pl/2010/04/20/fractions-in-php-and-whole-numbers</link>
		<comments>http://piotr.eldora.pl/2010/04/20/fractions-in-php-and-whole-numbers#comments</comments>
		<pubDate>Tue, 20 Apr 2010 16:52:38 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/?p=117</guid>
		<description><![CDATA[I have been searching for a good PHP class for fraction handling and found Math_Fraction in the PEAR database.
However, it was still lacking a possibility to display the whole numbers of a fraction and I had to rewrite the last function in the Fraction.php file.
Here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function toString&#40;$whole=false&#41;
&#123;
    $n = $this-&#62;getNum&#40;&#41;;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I have been searching for a good PHP class for fraction handling and found <a href="http://pear.php.net/package/Math_Fraction/">Math_Fraction</a> in the PEAR database.<br />
However, it was still lacking a possibility to display the whole numbers of a fraction and I had to rewrite the last function in the Fraction.php file.<br />
Here it is:</p>

<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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> toString<span style="color: #009900;">&#40;</span><span style="color: #000088;">$whole</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$whole</span> <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: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$d</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: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$n</span>/<span style="color: #006699; font-weight: bold;">$d</span>&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: #000088;">$n</span><span style="color: #339933;">==</span><span style="color: #000088;">$d</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$d</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #990000;">floatval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$d</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: #000088;">$w</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">/</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #339933;">*</span><span style="color: #000088;">$w</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$w</span> <span style="color: #006699; font-weight: bold;">$n</span>/<span style="color: #006699; font-weight: bold;">$d</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I have also informed the maintainer about it, so he might update it some time.<br />
Meanwhile I invite you to use this simple, yet effective solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2010/04/20/fractions-in-php-and-whole-numbers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php strpos array</title>
		<link>http://piotr.eldora.pl/2009/03/26/php-strpos-array</link>
		<comments>http://piotr.eldora.pl/2009/03/26/php-strpos-array#comments</comments>
		<pubDate>Thu, 26 Mar 2009 05:57:20 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/?p=65</guid>
		<description><![CDATA[I needed a PHP function to check whether a string contained one of the array values. As we know strpos does&#8217;t accept input as an array so I had to tweak it  bit. Below is an example of what I did:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function strpos_array&#40;$string, $values&#41; &#123;
    $hits = 0; //will give number of values [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a PHP function to check whether a string contained one of the array values. As we know strpos does&#8217;t accept input as an array so I had to tweak it  bit. Below is an example of what I did:</p>

<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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> strpos_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$hits</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will give number of values found in a string</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$values</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$try</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$try</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pos</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$hits</span><span style="color: #339933;">++;</span> <span style="color: #666666; font-style: italic;">// you can do array_push here to get the values</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$hits</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//if none value from array was found returns false</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</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: #666666; font-style: italic;">//I just needed a simple true/false boolean</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></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2009/03/26/php-strpos-array/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>FPDF polskie wolne czcionki</title>
		<link>http://piotr.eldora.pl/2009/01/19/fpdf-polskie-wolne-czcionki</link>
		<comments>http://piotr.eldora.pl/2009/01/19/fpdf-polskie-wolne-czcionki#comments</comments>
		<pubDate>Mon, 19 Jan 2009 11:13:26 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[linux fpdf gpl wolne]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/?p=39</guid>
		<description><![CDATA[Postanowiłem wreszcie trochę uporządkować czcionki używane do generowania dokumentów pdf oraz obrazków wykorzystujących czcionki ttf. Załączam zestaw gotowej do zainstalowania czytelnej czcionki z pakietu liberation-fonts. Które są upowszechnione na licencji GPL.
Pobierz
]]></description>
			<content:encoded><![CDATA[<p>Postanowiłem wreszcie trochę uporządkować czcionki używane do generowania dokumentów pdf oraz obrazków wykorzystujących czcionki ttf. Załączam zestaw gotowej do zainstalowania czytelnej czcionki z pakietu <a href="https://fedorahosted.org/liberation-fonts/">liberation-fonts</a>. Które są upowszechnione na licencji GPL.</p>
<p><a href="http://piotr.eldora.pl/weblog/wp-content/uploads/2009/01/fonttar.bz2">Pobierz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2009/01/19/fpdf-polskie-wolne-czcionki/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Suhosin and maximum $_POST variables limit</title>
		<link>http://piotr.eldora.pl/2008/04/23/suhosin-maximum-post-variables-php-limit</link>
		<comments>http://piotr.eldora.pl/2008/04/23/suhosin-maximum-post-variables-php-limit#comments</comments>
		<pubDate>Wed, 23 Apr 2008 21:30:54 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[max]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[suhosin]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/2008/04/23/suhosin-saved-my-day-again</guid>
		<description><![CDATA[I had a problem of more than 200 $_POST variables in one of my php scripts. Something was limiting the script not to process more than 200 in the $_POST array.
After unsuccessfully trying to find some info about how to change it in php.ini or apache.conf I found a solution using Suhosin:
You simply add the [...]]]></description>
			<content:encoded><![CDATA[<p>I had a problem of more than 200 $_POST variables in one of my php scripts. Something was limiting the script not to process more than 200 in the $_POST array.</p>
<p>After unsuccessfully trying to find some info about how to change it in php.ini or apache.conf I found a solution using Suhosin:</p>
<p>You simply add the following to your php.ini file after loading the suhosin module:</p>
<p>[suhosin]<br />
suhosin.post.max_vars = 2000<br />
suhosin.request.max_vars = 2000</p>
<p>That&#8217;s easy now <img src='http://piotr.eldora.pl/weblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update: remember to restart Apache after making these changes.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2008/04/23/suhosin-maximum-post-variables-php-limit/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Suhosin &#8211; customize php security</title>
		<link>http://piotr.eldora.pl/2008/04/09/suhosin-customize-php-security</link>
		<comments>http://piotr.eldora.pl/2008/04/09/suhosin-customize-php-security#comments</comments>
		<pubDate>Wed, 09 Apr 2008 19:46:37 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/2008/04/09/suhosin-customize-php-security</guid>
		<description><![CDATA[I was trying to configure my virtualhosts to have different php options regarding shell access. After some research I came up with Suhosin solution, which solved problems with setting disable_functions per virtualhost. Look it up!
]]></description>
			<content:encoded><![CDATA[<p>I was trying to configure my virtualhosts to have different php options regarding shell access. After some research I came up with Suhosin solution, which solved problems with setting <em>disable_functions</em> per virtualhost. <a href="http://www.hardened-php.net/suhosin.127.html" target="_blank">Look it up</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2008/04/09/suhosin-customize-php-security/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A php function to return random values</title>
		<link>http://piotr.eldora.pl/2007/09/22/14</link>
		<comments>http://piotr.eldora.pl/2007/09/22/14#comments</comments>
		<pubDate>Sat, 22 Sep 2007 09:24:14 +0000</pubDate>
		<dc:creator>Piotr Zaniewicz</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://piotr.eldora.pl/2007/09/22/14</guid>
		<description><![CDATA[I was looking for a method in php that would return unequal numbers using the rand() function. I found an answer on php.net and all credit goes to alishahnovin at hotmail dot com. The method is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function randiff&#40;$min, $max, $num&#41; &#123;
    if &#40;$min&#60;$max &#38;&#38; $max-$min+1 &#62;= $num &#38;&#38; $num&#62;0&#41; &#123;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a method in php that would return unequal numbers using the rand() function. I found an answer on php.net and all credit goes to alishahnovin at hotmail dot com. The method is as follows:</p>

<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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> randiff<span style="color: #009900;">&#40;</span><span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</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;">$min</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$max</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$max</span><span style="color: #339933;">-</span><span style="color: #000088;">$min</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$num</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$random_nums</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>
        <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$rand_num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">$rand_num</span><span style="color: #339933;">,</span> <span style="color: #000088;">$random_nums</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$random_nums</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rand_num</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$random_nums</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: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$nums</span> <span style="color: #339933;">=</span> randiff<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$var1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$nums</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: #000088;">$var2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$nums</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://piotr.eldora.pl/2007/09/22/14/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
