{"id":622,"date":"2009-09-09T22:13:00","date_gmt":"2009-09-09T02:13:00","guid":{"rendered":""},"modified":"2013-11-26T15:51:35","modified_gmt":"2013-11-26T07:51:35","slug":"php%e9%81%8d%e5%8e%86%e5%88%97%e6%96%87%e4%bb%b6%e3%80%81%e7%9b%ae%e5%bd%95","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/622.html","title":{"rendered":"PHP\u904d\u5386\u5217\u6587\u4ef6\u3001\u76ee\u5f55"},"content":{"rendered":"<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt; ?php\r\n\/************************************\r\n    Name: ListDir\r\n    Author: Riyao Chen\r\n    Version: 0.0.1\r\n    Date: 2006-05-16\r\n    License: GPL\r\n\r\n\/\/This class is to list all file &amp; directory follow a directory\r\n\/\/Parameter:$strdir ,which directory you want list; $del_url,the manage URL,\r\n*********************************\/\r\nclass ListDir{\r\n\r\nvar $dir;\r\nvar $edit_url=&quot;&quot;;\r\nvar $del_url=&quot;&quot;;\r\n\r\nvar $num = 0;\r\n\r\nfunction ListDir($strdir,$del_url=&quot;&quot;,$edit_url=&quot;&quot;)\r\n{\r\n$this-&gt;dir = $strdir;\r\n$this-&gt;del_url = $del_url;\r\n$this-&gt;edit_url = $edit_url;\r\n}\r\n\r\nfunction MakeDir($StrDir)\r\n{\r\n\/\/global $num;\r\nif (is_dir($StrDir)) {\r\n      if ($dh = @opendir($StrDir)) {\r\n          while (($file = readdir($dh)) !== false) {\r\n\r\n           $newdir = $StrDir.$file;\r\n           if($file == &quot;.&quot; || $file == &quot;..&quot;)\r\n               {\r\n                continue;\r\n               }\r\n\r\n               $this-&gt;num = $this-&gt;num + 1;\r\n               print str_repeat(&quot; &quot;,$this-&gt;num);\r\n\r\n               if(filetype($newdir)==&quot;dir&quot;)\r\n               {\r\n                print &quot;&lt;br&gt;&quot;;\r\n                print &quot;$file &#x5B;\u76ee\u5f55]&lt;br&gt;\\n&quot;;\r\n               }\r\n               else\r\n               {\r\n\r\n                \/\/print &quot;&lt;a href='&quot;.$this-&gt;del_url.&quot;?file=&quot;.$newdir.&quot;'&gt;EDIT&lt;\/a&gt; &lt;a href='&quot;.$newdir.&quot;'&gt;$file&lt;\/a&gt; &lt;br&gt;\\n&quot;;\r\n    \/\/\u8fd9\u91cc\u6539\u6210\u81ea\u5df1\u7684\u663e\u793a\u51fd\u6570\r\n    print &quot;&lt;a href='&quot;.$newdir.&quot;'&gt;$file&lt;\/a&gt; &lt;br&gt;\\n&quot;;\r\n    }\r\n               if(is_dir($newdir))\r\n               {\r\n                $this-&gt;MakeDir($newdir.&quot;\/&quot;);\r\n                }\r\n\r\n               $this-&gt;num = $this-&gt;num - 1;\r\n          }\r\n         print &quot;&lt;br&gt;&quot;;\r\n      closedir($dh);\r\n      }\r\n}\r\n\r\n}\r\n\r\nfunction ShowDir()\r\n{\r\n$this-&gt;MakeDir($this-&gt;dir);\r\n}\r\n}\r\n\r\n\/\/\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\r\n\r\n$dir = new ListDir(&quot;images\/&quot;,&quot;http:\/\/127.0.0.1\/xml_album\/list.php&quot;);\r\n$dir-&gt;ShowDir();\r\n\r\n? &gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt; ?php \/************************************ Name: L [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":5257,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions\/5257"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}