{"id":72148,"date":"2026-02-17T03:01:00","date_gmt":"2026-02-16T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=72148"},"modified":"2026-02-16T18:33:23","modified_gmt":"2026-02-16T08:33:23","slug":"document-root-relative-folder-listing-links-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/document-root-relative-folder-listing-links-tutorial\/","title":{"rendered":"Document Root Relative Folder Listing Links Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Document Root Relative Folder Listing Links Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/one_line_links.gif\" title=\"Document Root Relative Folder Listing Links Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Document Root Relative Folder Listing Links Tutorial<\/p><\/div>\n<p>Regular readers will &#8220;know the drill&#8221; with today&#8217;s work, on top of yesterday&#8217;s <a title='Document Root Relative Folder Listing Tutorial' href='#drrflt'>Document Root Relative Folder Listing Tutorial<\/a>.<\/p>\n<p>The new word in the posting title is &#8230;<\/p>\n<p><code><br \/>\nLinks<br \/>\n<\/code><\/p>\n<p> &#8230; and those regular readers would know &#8230;<\/p>\n<ul>\n<li>yesterday&#8217;s Document Root Relative Folder Listing output was placed into a <i>textarea<\/i> element &#8230; clue 1<\/li>\n<li>that <i>textarea<\/i> element we all admire for it&#8217;s textual data line feed talents and it&#8217;s talents for resizing capabilities &#8230; clue 2<\/li>\n<li>that <i>textarea<\/i> element textual data is unembellishable (if that is a word) &#8230; clue 3<\/li>\n<li>whereas your meek and mild <i>div<\/i> element, say, could <a target=\"_blank\" href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/overlay\" rel=\"noopener\">overlay<\/a> that <i>textarea<\/i> element, except for the right hand resizer, <span><a target=\"_blank\" title='?' class=\"audioytplay\" href='https:\/\/www.youtube.com\/watch?v=PtR4cWb4HNg' rel=\"noopener\">that is<\/a><\/span> &#8230; clue 4<\/li>\n<li>and the <i>div<\/i> element could latch onto that <i>textarea<\/i> basis of content and enhance filenames into filename links too <font size=1>(but am not sure about the <a target=\"_blank\" title=\"?\" href='https:\/\/www.youtube.com\/watch?v=LDWXfVcXmb4' rel=\"noopener\">Singing Glasses idea<\/a> in the &#8220;talent quest section&#8221; &#8230; that seems a bridge too far)<\/font> &#8230; clue 5<\/li>\n<\/ul>\n<p> &#8230; leaving us <a target=\"_blank\" title=\"?\" href='https:\/\/www.youtube.com\/watch?v=8toaz_9BHrY' rel=\"noopener\">clueless<\/a> as to what else to say &#8230; chortle, chortle?!<\/p>\n<p>Also helpful would be, to our minds &#8230;<\/p>\n<ul>\n<li>still restrict the file specification to a &#8220;buttoned down&#8221; setting (because of security concerns) &#8230; but &#8230;<\/li>\n<li>add complexity to the extension part &#8230;<br \/>\n&lt;?php<br \/>\n<code><br \/>\n     $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';<br \/>\n<\/code><br \/>\n?&gt;<br \/>\n &#8230;to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now &#8230;<br \/>\n&lt;?php<br \/>\n<code><br \/>\n    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));<br \/>\n<\/code><br \/>\n?&gt;\n<\/ul>\n<p> &#8230; in the <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/one_line_find.php-GETME\" rel=\"noopener\">&#8220;second draft&#8221;<\/a> <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php-GETME\" rel=\"noopener\">one_line_find.php<\/a> <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php\" rel=\"noopener\">Document Root Relative Folder Listing<\/a> web application you can <a href='#myif' onclick=\"document.getElementById('myif').src='\/one_line_find.php?rand=' + Math.floor(Math.random() * 1675645); document.getElementById('myif').style.display='block'; document.getElementById('myif').scrollIntoView(); \">&#8220;crank up&#8221; below<\/a>, again, if you like.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=\"_blank\" href='\/\/www.rjmprogramming.com.au\/ITblog\/document-root-relative-folder-listing-links-tutorial\/' rel=\"noopener\">Document Root Relative Folder Listing Links Tutorial<\/a>.<\/p-->\n<hr>\n<p id='drrflt'>Previous relevant <a target=\"_blank\" title='Document Root Relative Folder Listing Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/document-root-relative-folder-listing-tutorial\/' rel=\"noopener\">Document Root Relative Folder Listing Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Document Root Relative Folder Listing Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.gif\" title=\"Document Root Relative Folder Listing Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Document Root Relative Folder Listing Tutorial<\/p><\/div>\n<p>The Apache web server has, for it&#8217;s PHP environment, if that is it&#8217;s server language, the concept of &#8230;<\/p>\n<p><code><br \/>\n<a target=\"_blank\" title='Document Root' href='https:\/\/httpd.apache.org\/docs\/2.4\/urlmapping.html' rel=\"noopener\">Document Root<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming&#8217;s Landing Page&#8217;s URL &#8230;<\/p>\n<p><code><br \/>\n<a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/\" rel=\"noopener\">https:\/\/www.rjmprogramming.com.au\/<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; scours that Document Root folder to find the <i>index.php<\/i> webpage code to display that Landing Page.<\/p>\n<p>You can &#8220;abstract&#8221;, and we do also with our Difference Reporting, what that Document Root is as a folder path &#8230; bit forlorn we know, as we&#8217;ve shown what it is, probably, in many tutorial images &#8230; but the thing here is that a <i>URL<\/i> such as &#8230;<\/p>\n<p><code><br \/>\n<a target=\"_blank\" href=\"\/index.php\" rel=\"noopener\">\/index.php<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf &#8230; if you like Document Root is the left hand beach flag at Surfers Paradise <font size=1>(or perhaps the right hand beach flag in the <a target=\"_blank\" href='https:\/\/www.google.com\/search?q=todd+river+floods&#038;rlz=1C5OZZY_en&#038;oq=todd+river+floods&#038;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIICAEQABgWGB4yCAgCEAAYFhgeMggIAxAAGBYYHjINCAQQABiGAxiABBiKBTINCAUQABiGAxiABBiKBTINCAYQABiGAxiABBiKBTIKCAcQABiABBiiBNIBCDYyMjVqMGo0qAIAsAIB&#038;sourceid=chrome&#038;ie=UTF-8' rel=\"noopener\">Todd River<\/a> &#8230; when it gets water, <span><a target=\"_blank\" title='?' class=\"audioytplay\" href='https:\/\/www.youtube.com\/watch?v=PtR4cWb4HNg' rel=\"noopener\">that is<\/a><\/span>?!)<\/font>.<\/p>\n<p>Okay, that&#8217;s one theme of today&#8217;s new PHP web application.  The other we wrote out to ourself was &#8230;<\/p>\n<blockquote><p>\nOne line ls -clt https:\/\/www.rjmprogramming.com.au\/*.txt via find $_SERVER[&#8216;DOCUMENT_ROOT&#8217;] -type d -name &#8216;*&#8217;\n<\/p><\/blockquote>\n<p> &#8230; as a presentation idea whereby just the one table row of data is used to present &#8230;<\/p>\n<ul>\n<li>https:\/\/www.rjmprogramming.com.au\/<\/li>\n<li>dropdown of list of folders off Document Root (&#8220;abstracting&#8221; Document Root itself &#8230; ie. relative referencing)<\/li>\n<li>a file specification (minus the path) of interest &#8230; we are, for now, locking in as &#8230;<br \/>\n<code><br \/>\n*.txt<br \/>\n<\/code><br \/>\n &#8230; as the input data, to the output data that is &#8230;\n<\/li>\n<li>output folder listing (as for Linux and macOS)<\/li>\n<\/ul>\n<p>The concept of &#8220;one table row&#8221; for a multiple file listing is a mute point, but in our defence &#8230;<\/p>\n<ul>\n<li>the textarea it is presented in (via <i>rows=1<\/i>) is user resizable<\/li>\n<li>the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea<\/li>\n<\/ul>\n<p>This was a PHP project definitely needing the mildly better outcomes of PHP <a target=\"_blank\" title='PHP shell_exec() method information' href='http:\/\/php.net\/manual\/en\/function.shell-exec.php' rel=\"noopener\"><i>shell_exec<\/i><\/a> (where multiple line outputs are possible) as distinct from <a target=\"_blank\" title='PHP shell_exec() method information' href='http:\/\/php.net\/manual\/en\/function.exec.php' rel=\"noopener\"><i>exec<\/i><\/a> where only the last output line is returned, but is the usual method we use around here.<\/p>\n<p>Keeping the report to one row also asks for &#8230;<\/p>\n<ul>\n<li>use of elements that have CSS styling display:inline; as a default (eg. span element) &#8230; or &#8230;<\/li>\n<li>user supplying CSS display:inline; or  display:inline-block; as applicable &#8230; and &#8230;<\/li>\n<li>table cell <i>text-align:right;<\/i> came in handy &#8230; as well as &#8230;<\/li>\n<li>select element &#8220;dynamic shrinker&#8221; &#8230;<br \/>\n<code><br \/>\nfunction resizeSelect(sel) { \/\/ thanks to https:\/\/www.google.com\/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8<br \/>\n  \/\/ 1. Create a temporary span to measure text width<br \/>\n  var tempSpan = document.createElement('span');<br \/>\n  tempSpan.style.visibility = 'hidden';<br \/>\n  tempSpan.style.position = 'absolute';<br \/>\n  tempSpan.style.whiteSpace = 'pre';<br \/>\n  \/\/ 2. Set font styles to match the select box<br \/>\n  tempSpan.style.font = window.getComputedStyle(sel).font;<br \/>\n  \/\/ 3. Set content to selected text<br \/>\n  tempSpan.innerText = sel.options[sel.selectedIndex].text;<br \/>\n  document.body.appendChild(tempSpan);<br \/>\n  <br \/>\n  \/\/ 4. Update width (with extra space for the dropdown arrow)<br \/>\n  sel.style.width = (tempSpan.offsetWidth + 30) + 'px';<br \/>\n  document.body.removeChild(tempSpan);<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p> &#8230; in the &#8220;proof of concept&#8221; <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php_GETME\" rel=\"noopener\">one_line_find.php<\/a> first draft <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/one_line_find.php\" rel=\"noopener\">Document Root Relative Folder Listing<\/a> web application you can <a href='#myif' onclick=\"document.getElementById('myif').src='\/one_line_find.php?rand=' + Math.floor(Math.random() * 1675645); document.getElementById('myif').style.display='block'; \">&#8220;crank up&#8221; below<\/a> if you like &#8230;<\/p>\n<div id=dmyif style=width:1200px;overflow:visible;z-index:876;height:80px;>\n<iframe scrolling=yes frameborder=0 name=myif id=myif src=\/About_Us.html style=zoom:0.7;z-index:876;display:none;width:80%;height:80px;overflow-y:visible;><\/iframe>\n<\/div>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d72124' onclick='var dv=document.getElementById(\"d72124\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/report\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d72124' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d72148' onclick='var dv=document.getElementById(\"d72148\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/link\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d72148' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Regular readers will &#8220;know the drill&#8221; with today&#8217;s work, on top of yesterday&#8217;s Document Root Relative Folder Listing Tutorial. The new word in the posting title is &#8230; Links &#8230; and those regular readers would know &#8230; yesterday&#8217;s Document Root &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/document-root-relative-folder-listing-links-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,29,37],"tags":[2458,85,1580,234,281,336,342,1750,367,5423,418,3336,435,450,2487,3580,2533,1807,707,5422,5421,5424,885,894,2120,932,997,2945,1045,1054,1059,1075,1866,3942,1238,1581,5085,1254,1319,1345,1411],"class_list":["post-72148","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-operating-system","category-tutorials","tag-abstraction","tag-apache","tag-cell","tag-command-line","tag-css","tag-directory","tag-div","tag-document-root","tag-dropdown","tag-extensio","tag-file","tag-filename","tag-find","tag-folder","tag-inline","tag-inline-block","tag-line-feed","tag-link","tag-linux","tag-listing","tag-ls","tag-one-row","tag-operating-system-2","tag-overlay","tag-path","tag-php","tag-programming","tag-relative","tag-relative-url","tag-report","tag-resize","tag-row","tag-select","tag-shell_exec","tag-table","tag-table-cell","tag-talent","tag-text","tag-tutorial","tag-url","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72148"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=72148"}],"version-history":[{"count":6,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72148\/revisions"}],"predecessor-version":[{"id":72155,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72148\/revisions\/72155"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=72148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=72148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=72148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}