<?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>php Архиви - rosen4o.net</title>
	<atom:link href="https://rosen4o.net/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://rosen4o.net/category/php/</link>
	<description></description>
	<lastBuildDate>Wed, 12 Feb 2025 15:49:51 +0000</lastBuildDate>
	<language>bg-BG</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Opencart losing cart on redirect after payment</title>
		<link>https://rosen4o.net/2025/02/12/opencart-losing-cart-on-redirect-after-payment/</link>
					<comments>https://rosen4o.net/2025/02/12/opencart-losing-cart-on-redirect-after-payment/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Wed, 12 Feb 2025 15:41:46 +0000</pubDate>
				<category><![CDATA[Opencart]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[opencart]]></category>
		<category><![CDATA[session]]></category>
		<guid isPermaLink="false">https://rosen4o.net/?p=1173</guid>

					<description><![CDATA[<p>Opencart has issue with Samesite session cookie which can be resolved in OC version 2.X by adding those two lines code There is a lot of info about PHP example for SameSite=None; Secure https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md Or even in the OpenCart forums</p>
<p>Материалът <a href="https://rosen4o.net/2025/02/12/opencart-losing-cart-on-redirect-after-payment/">Opencart losing cart on redirect after payment</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Opencart has issue with Samesite session cookie which can be resolved in OC version 2.X by adding those two lines code</p>



<pre class="wp-block-code"><code>if(isset($_COOKIE&#91;"PHPSESSID"])){
    header('Set-Cookie: PHPSESSID='.$_COOKIE&#91;"PHPSESSID"].'; SameSite=None');
}
</code></pre>



<p>There is a lot of info about PHP example for SameSite=None; Secure</p>



<p><a href="https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md">https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md</a></p>



<p>Or even in the OpenCart forums</p>
<p>Материалът <a href="https://rosen4o.net/2025/02/12/opencart-losing-cart-on-redirect-after-payment/">Opencart losing cart on redirect after payment</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2025/02/12/opencart-losing-cart-on-redirect-after-payment/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>search for short open tags</title>
		<link>https://rosen4o.net/2020/06/08/search-for-short-open-tags/</link>
					<comments>https://rosen4o.net/2020/06/08/search-for-short-open-tags/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Mon, 08 Jun 2020 15:19:07 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shortopentags]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=1134</guid>

					<description><![CDATA[<p>If you use Linux and try to search for all php files containing short open tags you can use following command find -type f -exec grep -IlP &#8216;&#60;\?(?!(php&#124;xml&#124;=))&#8217; {} +</p>
<p>Материалът <a href="https://rosen4o.net/2020/06/08/search-for-short-open-tags/">search for short open tags</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you use Linux and try to search for all php files containing short open tags you can use following command</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>find -type f -exec grep -IlP &#8216;&lt;\?(?!(php|xml|=))&#8217; {} +</p></blockquote>
<p>Материалът <a href="https://rosen4o.net/2020/06/08/search-for-short-open-tags/">search for short open tags</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2020/06/08/search-for-short-open-tags/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>restore wordpress widdget from database backup</title>
		<link>https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/</link>
					<comments>https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Wed, 30 Nov 2016 15:12:16 +0000</pubDate>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[sidebars_widgets]]></category>
		<category><![CDATA[widget_text]]></category>
		<category><![CDATA[widgets]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=1078</guid>

					<description><![CDATA[<p>If you wish to restore wordpress text widget from backup you need to follow those steps 1. Copy content from wp_options of the widget for example option_name=widget_text 2. Paste it on the new site 3. Restore all widgets on positions<span class="ellipsis">&#8230;</span></p>
<div class="read-more"><a href="https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/">Прочетете повече ›</a></div>
<p><!-- end of .read-more --></p>
<p>Материалът <a href="https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/">restore wordpress widdget from database backup</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you wish to restore wordpress text widget from backup you need to follow those steps</p>
<p>1. Copy content from wp_options of the widget for example option_name=widget_text</p>
<p>2. Paste it on the new site</p>
<p>3. Restore all widgets on positions &#8211; copy sidebars_widgets value. This value contain all widgets positions </p>
<p>Материалът <a href="https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/">restore wordpress widdget from database backup</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2016/11/30/restore-wordpress-widdget-from-database-backup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>catch spam from apache</title>
		<link>https://rosen4o.net/2014/05/20/catch-spam-from-apache/</link>
					<comments>https://rosen4o.net/2014/05/20/catch-spam-from-apache/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Tue, 20 May 2014 08:53:53 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[spam]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=1006</guid>

					<description><![CDATA[<p>Sometimes is very hard to debug from which virtual host spam is This can be check very easy with this trick create a new file  vim /usr/local/bin/phpsendmail place inside it #!/usr/bin/php &#60;?php $sendmail = &#8216;/usr/sbin/sendmail&#8217;; $logfile = &#8216;/var/log/mail.form&#8217;; /* Get<span class="ellipsis">&#8230;</span></p>
<div class="read-more"><a href="https://rosen4o.net/2014/05/20/catch-spam-from-apache/">Прочетете повече ›</a></div>
<p><!-- end of .read-more --></p>
<p>Материалът <a href="https://rosen4o.net/2014/05/20/catch-spam-from-apache/">catch spam from apache</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes is very hard to debug from which virtual host spam is<br />
This can be check very easy with this trick</p>
<p>create a new file</p>
<p style="padding-left: 30px;"> <strong>vim /usr/local/bin/phpsendmail</strong></p>
<p>place inside it</p>
<p style="padding-left: 30px;"><strong>#!/usr/bin/php</strong><br />
<strong> &lt;?php</strong></p>
<p style="padding-left: 30px;"><strong>$sendmail = &#8216;/usr/sbin/sendmail&#8217;;</strong><br />
<strong> $logfile = &#8216;/var/log/mail.form&#8217;;</strong></p>
<p style="padding-left: 30px;"><strong>/* Get email content */</strong><br />
<strong> $logline = &#8220;;</strong><br />
<strong> $mail = &#8220;;</strong><br />
<strong> $fp = fopen(&#8216;php://stdin&#8217;, &#8216;r&#8217;);</strong></p>
<p style="padding-left: 30px;"><strong>while ($line = fgets($fp))</strong><br />
<strong> {</strong><br />
<strong> if(preg_match(&#8216;/^to:/i&#8217;, $line) || preg_match(&#8216;/^from:/i&#8217;, $line))</strong><br />
<strong> {</strong><br />
<strong> $logline .= trim($line).&#8217; &#8216;;</strong><br />
<strong> }</strong><br />
<strong> $mail .= $line;</strong><br />
<strong> }</strong></p>
<p style="padding-left: 30px;"><strong>/* Build sendmail command */</strong><br />
<strong> $cmd = &#8216;echo &#8216; . escapeshellarg($mail) . &#8216; | &#8216;.$sendmail.&#8217; -t -i&#8217;;</strong><br />
<strong> for ($i = 1; $i &lt; $_SERVER[&#8216;argc&#8217;]; $i++)</strong><br />
<strong> {</strong><br />
<strong> $cmd .= escapeshellarg($_SERVER[&#8216;argv&#8217;][$i]).&#8217; &#8216;;</strong><br />
<strong> }</strong></p>
<p style="padding-left: 30px;"><strong>/* Log line */</strong><br />
<strong> $path = isset($_ENV[&#8216;PWD&#8217;]) ? $_ENV[&#8216;PWD&#8217;] : $_SERVER[&#8216;PWD&#8217;];</strong><br />
<strong> file_put_contents($logfile, date(&#8216;Y-m-d H:i:s&#8217;) . &#8216; &#8216; . $logline .&#8217;  ==&gt; &#8216; .$path.&#8220;\n&#8220;, FILE_APPEND);</strong></p>
<p style="padding-left: 30px;"><strong>/* Call sendmail */</strong><br />
<strong> return shell_exec($cmd);</strong><br />
<strong> ?&gt;</strong></p>
<p>Then you need to make it executable</p>
<p style="padding-left: 30px;"><strong>chmod +x /usr/local/bin/phpsendmail</strong></p>
<p style="padding-left: 30px;"><strong>touch /var/log/mail.form</strong></p>
<p style="padding-left: 30px;"><strong>chmod a+w /var/log/mail.form</strong></p>
<p>In your php.ini file you need to add</p>
<p style="padding-left: 30px;"><strong>sendmail_path = /usr/local/bin/phpsendmail</strong></p>
<p>Restart apache</p>
<p>This will cause all emails which are send from apache to be logged in the file /var/log/mail.form</p>
<p>Материалът <a href="https://rosen4o.net/2014/05/20/catch-spam-from-apache/">catch spam from apache</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2014/05/20/catch-spam-from-apache/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>idea for id storing of files</title>
		<link>https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/</link>
					<comments>https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Fri, 29 Nov 2013 23:31:06 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[dir]]></category>
		<category><![CDATA[file storing]]></category>
		<category><![CDATA[how to store multiple files]]></category>
		<category><![CDATA[id storing]]></category>
		<category><![CDATA[multiple files in one dir]]></category>
		<category><![CDATA[separating files]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=979</guid>

					<description><![CDATA[<p>If you have some time of id in your database and you want to save file associated with this id it&#8217;s not a good idea to make dir with id value and save the file there because on some point<span class="ellipsis">&#8230;</span></p>
<div class="read-more"><a href="https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/">Прочетете повече ›</a></div>
<p><!-- end of .read-more --></p>
<p>Материалът <a href="https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/">idea for id storing of files</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you have some time of id in your database and you want to save file associated with this id it&#8217;s not a good idea to make dir with id value and save the file there because on some point you will have too much dirs with same name.</p>
<p>For this if the id is 123456 we can create dir from the id but separating all digit in subdir like 1/2/3/4/5/6/file/file.jpg</p>
<p>The last one dir is called file because we can have 1234567 and then in this dir we will have subdir 😉</p>
<p style="padding-left: 30px;">function gen_id_to_folder_name($id){</p>
<p style="padding-left: 30px;">$split = str_split($id);</p>
<p style="padding-left: 30px;">foreach($split as $spl){<br />
$folder_name .=$spl.&#8220;/&#8220;;<br />
}</p>
<p style="padding-left: 30px;">return $folder_name.&#8220;c/&#8220;;<br />
}</p>
<p>Материалът <a href="https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/">idea for id storing of files</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2013/11/30/idea-for-id-storing-of-files/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>mysql server has gone away or connection timeout</title>
		<link>https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/</link>
					<comments>https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Fri, 29 Nov 2013 23:26:14 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[away]]></category>
		<category><![CDATA[gone]]></category>
		<category><![CDATA[mysql]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=977</guid>

					<description><![CDATA[<p>If you do a lots of things in one php script this usually takes some time and mysql can gone away 😉 for this when you run new query you can run it with this function which will connect again<span class="ellipsis">&#8230;</span></p>
<div class="read-more"><a href="https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/">Прочетете повече ›</a></div>
<p><!-- end of .read-more --></p>
<p>Материалът <a href="https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/">mysql server has gone away or connection timeout</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you do a lots of things in one php script this usually takes some time and mysql can gone away 😉 for this when you run new query you can run it with this function which will connect again to mysql if previous connection is closed from timeout</p>
<p style="padding-left: 30px;"><code><br />
function run_query($sql){<br />
global $link, $db;</code></p>
<p style="padding-left: 30px;">if(!mysql_ping($link)){<br />
$link = mysql_connect($db[&#8216;host&#8217;], $db[&#8216;user&#8217;], $db[&#8216;pass&#8217;], true);<br />
mysql_select_db($db[&#8216;db&#8217;], $link);<br />
}</p>
<p style="padding-left: 30px;">return mysql_query($sql, $link);</p>
<p style="padding-left: 30px;">}</p>
<p>Материалът <a href="https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/">mysql server has gone away or connection timeout</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2013/11/30/mysql-server-has-gone-away-or-connection-timeout/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>php recursive copy</title>
		<link>https://rosen4o.net/2013/11/28/php-recursive-copy/</link>
					<comments>https://rosen4o.net/2013/11/28/php-recursive-copy/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Thu, 28 Nov 2013 18:00:19 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=975</guid>

					<description><![CDATA[<p>This function copy recursive files and folders in php function recursive_copy($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != &#8216;.&#8217; ) &#38;&#38; ( $file != &#8216;..&#8217; )) { if ( is_dir($src<span class="ellipsis">&#8230;</span></p>
<div class="read-more"><a href="https://rosen4o.net/2013/11/28/php-recursive-copy/">Прочетете повече ›</a></div>
<p><!-- end of .read-more --></p>
<p>Материалът <a href="https://rosen4o.net/2013/11/28/php-recursive-copy/">php recursive copy</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This function copy recursive files and folders in php</p>
<p style="padding-left: 30px;">function recursive_copy($src,$dst) {<br />
$dir = opendir($src);<br />
@mkdir($dst);<br />
while(false !== ( $file = readdir($dir)) ) {<br />
if (( $file != &#8216;.&#8217; ) &amp;&amp; ( $file != &#8216;..&#8217; )) {<br />
if ( is_dir($src . &#8216;/&#8217; . $file) ) {<br />
recurse_copy($src . &#8216;/&#8217; . $file,$dst . &#8216;/&#8217; . $file);<br />
}<br />
else {<br />
copy($src . &#8216;/&#8217; . $file,$dst . &#8216;/&#8217; . $file);<br />
}<br />
}<br />
}<br />
closedir($dir);<br />
}</p>
<p>Материалът <a href="https://rosen4o.net/2013/11/28/php-recursive-copy/">php recursive copy</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2013/11/28/php-recursive-copy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>php recursive delete</title>
		<link>https://rosen4o.net/2013/11/28/php-recursive-delete/</link>
					<comments>https://rosen4o.net/2013/11/28/php-recursive-delete/#respond</comments>
		
		<dc:creator><![CDATA[rosen4o]]></dc:creator>
		<pubDate>Thu, 28 Nov 2013 17:59:18 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[recursive delete]]></category>
		<guid isPermaLink="false">http://rosen4o.net/?p=973</guid>

					<description><![CDATA[<p>This function do recursive delete on files and folders in php function recursiveDelete($str){ if(is_file($str)){ return @unlink($str); } elseif(is_dir($str)){ $scan = glob(rtrim($str,&#8217;/&#8217;).&#8217;/*&#8217;); foreach($scan as $index=&#62;$path){ recursiveDelete($path); } return @rmdir($str); } }</p>
<p>Материалът <a href="https://rosen4o.net/2013/11/28/php-recursive-delete/">php recursive delete</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This function do recursive delete on files and folders in php</p>
<p style="padding-left: 30px;">function recursiveDelete($str){<br />
if(is_file($str)){<br />
return @unlink($str);<br />
}<br />
elseif(is_dir($str)){<br />
$scan = glob(rtrim($str,&#8217;/&#8217;).&#8217;/*&#8217;);<br />
foreach($scan as $index=&gt;$path){<br />
recursiveDelete($path);<br />
}<br />
return @rmdir($str);<br />
}<br />
}</p>
<p>Материалът <a href="https://rosen4o.net/2013/11/28/php-recursive-delete/">php recursive delete</a> е публикуван за пръв път на <a href="https://rosen4o.net">rosen4o.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://rosen4o.net/2013/11/28/php-recursive-delete/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
