<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Komentarze do wpisu: Czyszczenie/usuwanie katalogu w PHP</title>
	<atom:link href="http://wronx.net/blog/2008/10/09/czyszczenieusuwanie-katalogu-w-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://wronx.net/blog/2008/10/09/czyszczenieusuwanie-katalogu-w-php/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=czyszczenieusuwanie-katalogu-w-php</link>
	<description>bo nic nie zastąpi kodu źródłowego...</description>
	<lastBuildDate>Tue, 27 Jul 2010 09:56:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>Przez: marek</title>
		<link>http://wronx.net/blog/2008/10/09/czyszczenieusuwanie-katalogu-w-php/comment-page-1/#comment-194</link>
		<dc:creator>marek</dc:creator>
		<pubDate>Wed, 23 Sep 2009 11:14:42 +0000</pubDate>
		<guid isPermaLink="false">http://wronx.net/blog/?p=91#comment-194</guid>
		<description>Problem w tym, że nie wywala podkatalogów. Trzeba zapętlić funkcję w funkcji. To podobno obciąża serwer, ale jest do zrobienia. czyli:

&lt;pre lang=&quot;php&quot;&gt;
function EmptyDir($dirName, $rmDir = false)
{
  if($dirHandle = opendir($dirName)) 
  {
    while(false !== ($dirFile = readdir($dirHandle)))
      if ($dirFile != &quot;.&quot; &amp;&amp; $dirFile != &quot;..&quot;) 
      
      // tu moje, bo problem z katalogiem wewnątrz
      if(is_dir($dirName . &quot;/&quot; . $dirFile)){EmptyDir($dirName . &quot;/&quot; . $dirFile, true);}
      else
      //koniec mojego z katalogiem wewnątrz
      
        if(!unlink($dirName . &quot;/&quot; . $dirFile))
          return false;
    closedir($dirHandle); 
    if($rmDir)
      if(!rmdir($dirName))
        return false;
    return true;
  }
  else
    return false;
}
&lt;/pre&gt;

&lt;em&gt;edit (WRonX): &lt;strong&gt;oczywiście nie ponoszę odpowiedzialności za ten kod, bo nie chciało mi się go przetestować :)&lt;/stron&gt;&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>Problem w tym, że nie wywala podkatalogów. Trzeba zapętlić funkcję w funkcji. To podobno obciąża serwer, ale jest do zrobienia. czyli:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> EmptyDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rmDir</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirFile</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirFile</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$dirFile</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span> 
&nbsp;
      <span style="color: #666666; font-style: italic;">// tu moje, bo problem z katalogiem wewnątrz</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dirFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>EmptyDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dirFile</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</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: #666666; font-style: italic;">//koniec mojego z katalogiem wewnątrz</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dirFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirHandle</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;">$rmDir</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">rmdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</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: #b1b100;">else</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></pre></div></div>

<p><em>edit (WRonX): <strong>oczywiście nie ponoszę odpowiedzialności za ten kod, bo nie chciało mi się go przetestować :)</strong></em></p>
]]></content:encoded>
	</item>
</channel>
</rss>
