<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11934] trunk/wp-admin/includes: Include 'hidden'
  directories in filesystem dirlist by default, props dd32, fixes #10774</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11934">11934</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2009-09-15 02:21:00 +0000 (Tue, 15 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Include 'hidden' directories in filesystem dirlist by default, props dd32, fixes <a href="http://trac.wordpress.org/ticket/10774">#10774</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpfilesystemdirectphp">trunk/wp-admin/includes/class-wp-filesystem-direct.php</a></li>
<li><a href="#trunkwpadminincludesclasswpfilesystemftpextphp">trunk/wp-admin/includes/class-wp-filesystem-ftpext.php</a></li>
<li><a href="#trunkwpadminincludesclasswpfilesystemftpsocketsphp">trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php</a></li>
<li><a href="#trunkwpadminincludesclasswpfilesystemssh2php">trunk/wp-admin/includes/class-wp-filesystem-ssh2.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpfilesystemdirectphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-direct.php (11933 => 11934)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-direct.php        2009-09-14 21:13:25 UTC (rev 11933)
+++ trunk/wp-admin/includes/class-wp-filesystem-direct.php        2009-09-15 02:21:00 UTC (rev 11934)
</span><span class="lines">@@ -307,31 +307,36 @@
</span><span class="cx">                 return @rmdir($path);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function dirlist($path, $incdot = false, $recursive = false) {
</del><ins>+        function dirlist($path, $include_hidden = true, $recursive = false) {
</ins><span class="cx">                 if ( $this-&gt;is_file($path) ) {
</span><del>-                        $limitFile = basename($path);
</del><ins>+                        $limit_file = basename($path);
</ins><span class="cx">                         $path = dirname($path);
</span><span class="cx">                 } else {
</span><del>-                        $limitFile = false;
</del><ins>+                        $limit_file = false;
</ins><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 if ( ! $this-&gt;is_dir($path) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><del>-                $ret = array();
</del><span class="cx">                 $dir = @dir($path);
</span><span class="cx">                 if ( ! $dir )
</span><span class="cx">                         return false;
</span><ins>+
+                $ret = array();
+
</ins><span class="cx">                 while (false !== ($entry = $dir-&gt;read()) ) {
</span><span class="cx">                         $struc = array();
</span><span class="cx">                         $struc['name'] = $entry;
</span><span class="cx"> 
</span><span class="cx">                         if ( '.' == $struc['name'] || '..' == $struc['name'] )
</span><del>-                                continue; //Do not care about these folders.
-                        if ( '.' == $struc['name'][0] &amp;&amp; !$incdot)
</del><span class="cx">                                 continue;
</span><del>-                        if ( $limitFile &amp;&amp; $struc['name'] != $limitFile)
</del><ins>+
+                        if ( ! $include_hidden &amp;&amp; '.' == $struc['name'][0] )
</ins><span class="cx">                                 continue;
</span><span class="cx"> 
</span><ins>+                        if ( $limit_file &amp;&amp; $struc['name'] != $limit_file)
+                                continue;
+
</ins><span class="cx">                         $struc['perms']         = $this-&gt;gethchmod($path.'/'.$entry);
</span><span class="cx">                         $struc['permsn']        = $this-&gt;getnumchmodfromh($struc['perms']);
</span><span class="cx">                         $struc['number']         = false;
</span><span class="lines">@@ -345,7 +350,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if ( 'd' == $struc['type'] ) {
</span><span class="cx">                                 if ( $recursive )
</span><del>-                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
</del><ins>+                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
</ins><span class="cx">                                 else
</span><span class="cx">                                         $struc['files'] = array();
</span><span class="cx">                         }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpfilesystemftpextphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ftpext.php (11933 => 11934)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ftpext.php        2009-09-14 21:13:25 UTC (rev 11933)
+++ trunk/wp-admin/includes/class-wp-filesystem-ftpext.php        2009-09-15 02:21:00 UTC (rev 11934)
</span><span class="lines">@@ -323,12 +323,12 @@
</span><span class="cx">                 return $b;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function dirlist($path = '.', $incdot = false, $recursive = false) {
</del><ins>+        function dirlist($path = '.', $include_hidden = true, $recursive = false) {
</ins><span class="cx">                 if ( $this-&gt;is_file($path) ) {
</span><del>-                        $limitFile = basename($path);
</del><ins>+                        $limit_file = basename($path);
</ins><span class="cx">                         $path = dirname($path) . '/';
</span><span class="cx">                 } else {
</span><del>-                        $limitFile = false;
</del><ins>+                        $limit_file = false;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $list = @ftp_rawlist($this-&gt;link, '-a ' . $path, false);
</span><span class="lines">@@ -342,36 +342,31 @@
</span><span class="cx">                         if ( empty($entry) )
</span><span class="cx">                                 continue;
</span><span class="cx"> 
</span><del>-                        if ( '.' == $entry[&quot;name&quot;] || '..' == $entry[&quot;name&quot;] )
</del><ins>+                        if ( '.' == $entry['name'] || '..' == $entry['name'] )
</ins><span class="cx">                                 continue;
</span><span class="cx"> 
</span><ins>+                        if ( ! $include_hidden &amp;&amp; '.' == $entry['name'][0] )
+                                continue;
+
+                        if ( $limit_file &amp;&amp; $entry['name'] != $limit_file)
+                                continue;
+
</ins><span class="cx">                         $dirlist[ $entry['name'] ] = $entry;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( ! $dirlist )
</span><span class="cx">                         return false;
</span><del>-                if ( empty($dirlist) )
-                        return array();
</del><span class="cx"> 
</span><span class="cx">                 $ret = array();
</span><del>-                foreach ( $dirlist as $struc ) {
-
</del><ins>+                foreach ( (array)$dirlist as $struc ) {
</ins><span class="cx">                         if ( 'd' == $struc['type'] ) {
</span><del>-                                $struc['files'] = array();
-
-                                if ( $incdot ) {
-                                        //We're including the doted starts
-                                        if ( '.' != $struc['name'] &amp;&amp; '..' != $struc['name'] ) { //Ok, It isnt a special folder
-                                                if ($recursive)
-                                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
-                                        }
-                                } else { //No dots
-                                        if ($recursive)
-                                                $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
-                                }
</del><ins>+                                if ( $recursive )
+                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+                                else
+                                        $struc['files'] = array();
</ins><span class="cx">                         }
</span><del>-                        //File
-                        $ret[$struc['name']] = $struc;
</del><ins>+
+                        $ret[ $struc['name'] ] = $struc;
</ins><span class="cx">                 }
</span><span class="cx">                 return $ret;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpfilesystemftpsocketsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php (11933 => 11934)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php        2009-09-14 21:13:25 UTC (rev 11933)
+++ trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php        2009-09-15 02:21:00 UTC (rev 11934)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">                 $this-&gt;ftp-&gt;SetType($type);
</span><span class="cx"> 
</span><span class="cx">                 $temp = wp_tempnam( $file );
</span><del>-                if ( ! $temphandle = fopen($temp, 'w+') ){
</del><ins>+                if ( ! $temphandle = fopen($temp, 'w+') ) {
</ins><span class="cx">                         unlink($temp);
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><span class="lines">@@ -166,11 +166,12 @@
</span><span class="cx">                 if ( ! $recursive || ! $this-&gt;is_dir($file) ) {
</span><span class="cx">                         return $this-&gt;ftp-&gt;chmod($file, $mode);
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 //Is a directory, and we want recursive
</span><span class="cx">                 $filelist = $this-&gt;dirlist($file);
</span><del>-                foreach($filelist as $filename){
</del><ins>+                foreach ( $filelist as $filename )
</ins><span class="cx">                         $this-&gt;chmod($file . '/' . $filename, $mode, $recursive);
</span><del>-                }
</del><ins>+
</ins><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -282,39 +283,38 @@
</span><span class="cx">                 return $this-&gt;ftp-&gt;mdel($path);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function dirlist($path = '.', $incdot = false, $recursive = false ) {
</del><ins>+        function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
</ins><span class="cx">                 if ( $this-&gt;is_file($path) ) {
</span><del>-                        $limitFile = basename($path);
</del><ins>+                        $limit_file = basename($path);
</ins><span class="cx">                         $path = dirname($path) . '/';
</span><span class="cx">                 } else {
</span><del>-                        $limitFile = false;
</del><ins>+                        $limit_file = false;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $list = $this-&gt;ftp-&gt;dirlist($path);
</span><span class="cx">                 if ( ! $list )
</span><span class="cx">                         return false;
</span><del>-                if ( empty($list) )
-                        return array();
</del><span class="cx"> 
</span><span class="cx">                 $ret = array();
</span><span class="cx">                 foreach ( $list as $struc ) {
</span><span class="cx"> 
</span><ins>+                        if ( '.' == $struct['name'] || '..' == $struc['name'] )
+                                continue;
+
+                        if ( ! $include_hidden &amp;&amp; '.' == $struc['name'][0] )
+                                continue;
+
+                        if ( $limit_file &amp;&amp; $srtuc['name'] != $limit_file )
+                                continue;
+
</ins><span class="cx">                         if ( 'd' == $struc['type'] ) {
</span><del>-                                $struc['files'] = array();
</del><ins>+                                if ( $recursive )
+                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+                                else
+                                        $struc['files'] = array();
+                        }
</ins><span class="cx"> 
</span><del>-                                if ( $incdot ){
-                                        //We're including the doted starts
-                                        if ( '.' != $struc['name'] &amp;&amp; '..' != $struc['name'] ){ //Ok, It isnt a special folder
-                                                if ($recursive)
-                                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
-                                        }
-                                } else { //No dots
-                                        if ($recursive)
-                                                $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
-                                }
-                        }
-                        //File
-                        $ret[$struc['name']] = $struc;
</del><ins>+                        $ret[ $struc['name'] ] = $struc;
</ins><span class="cx">                 }
</span><span class="cx">                 return $ret;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpfilesystemssh2php"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-filesystem-ssh2.php (11933 => 11934)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-filesystem-ssh2.php        2009-09-14 21:13:25 UTC (rev 11933)
+++ trunk/wp-admin/includes/class-wp-filesystem-ssh2.php        2009-09-15 02:21:00 UTC (rev 11934)
</span><span class="lines">@@ -322,29 +322,34 @@
</span><span class="cx">                 return $this-&gt;delete($path, $recursive);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function dirlist($path, $incdot = false, $recursive = false) {
</del><ins>+        function dirlist($path, $include_hidden = true, $recursive = false) {
</ins><span class="cx">                 if ( $this-&gt;is_file($path) ) {
</span><del>-                        $limitFile = basename($path);
</del><ins>+                        $limit_file = basename($path);
</ins><span class="cx">                         $path = dirname($path);
</span><span class="cx">                 } else {
</span><del>-                        $limitFile = false;
</del><ins>+                        $limit_file = false;
</ins><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 if ( ! $this-&gt;is_dir($path) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 $ret = array();
</span><span class="cx">                 $dir = @dir('ssh2.sftp://' . $this-&gt;sftp_link .'/' . ltrim($path, '/') );
</span><ins>+
</ins><span class="cx">                 if ( ! $dir )
</span><span class="cx">                         return false;
</span><ins>+
</ins><span class="cx">                 while (false !== ($entry = $dir-&gt;read()) ) {
</span><span class="cx">                         $struc = array();
</span><span class="cx">                         $struc['name'] = $entry;
</span><span class="cx"> 
</span><span class="cx">                         if ( '.' == $struc['name'] || '..' == $struc['name'] )
</span><span class="cx">                                 continue; //Do not care about these folders.
</span><del>-                        if ( '.' == $struc['name'][0] &amp;&amp; !$incdot)
</del><ins>+
+                        if ( ! $include_hidden &amp;&amp; '.' == $struc['name'][0] )
</ins><span class="cx">                                 continue;
</span><del>-                        if ( $limitFile &amp;&amp; $struc['name'] != $limitFile)
</del><ins>+
+                        if ( $limit_file &amp;&amp; $struc['name'] != $limit_file )
</ins><span class="cx">                                 continue;
</span><span class="cx"> 
</span><span class="cx">                         $struc['perms']         = $this-&gt;gethchmod($path.'/'.$entry);
</span><span class="lines">@@ -360,7 +365,7 @@
</span><span class="cx"> 
</span><span class="cx">                         if ( 'd' == $struc['type'] ) {
</span><span class="cx">                                 if ( $recursive )
</span><del>-                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $incdot, $recursive);
</del><ins>+                                        $struc['files'] = $this-&gt;dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
</ins><span class="cx">                                 else
</span><span class="cx">                                         $struc['files'] = array();
</span><span class="cx">                         }
</span></span></pre>
</div>
</div>

</body>
</html>