views:

585

answers:

10

Hi, I am using SVN to manage a copy of my web site. The site runs a typo3 installation, which uses PHP to create the backend.

The problem is, all the stupid .SVN folders show up in the directory listing of PHP. I DO NOT mean the build in apache listing. I mean a directoy listing created by the PHP backend.

So, is there any way to hide special directories from PHP?

[NOTE] Changing the PHP source code is not an option. Typo3 is too big, and each extensions uses its own code. Would be much more effort than an SVN export script.

Chris

PS: I do not want to setup a svn export --> web_root just to get rid of the files. And I know that I can prevent apache from serving the .SVN directories, I did that. But they still show up in the backend, when browsing the directory tree (which is created by PHP). And they are very annoying...

A: 

Try this.

<locationmatch "/.svn/">
    order allow,deny
    deny from all
</locationmatch>

Btw in your loop in PHP you can do a logic check to see if the filename is not ".svn", usually PHP directory tools do that to exclude "." and ".." directories.

Ólafur Waage
I believe he mentioned that his problem wasn't with apache directory listings. Your config would block access, but the user would still see them if his application is doing some kind of directory listing of its own.
Zoredache
@Zoredache thats why i added the comment below.
Ólafur Waage
A: 

The problem is, all the stupid .SVN folders show up in the directory listing of PHP. I DO NOT mean the build in apache listing. I mean a directoy listing created by the PHP backend.

What application is doing the directory listing? Have you considered looking into the code of the PHP backend and adding something to prevent the display of the .svn directories?

Zoredache
Yes, I thought about it... But that would mean to hack into the core of typo3, a very big content management system. I would really like to avoid this!
Oh, and by the way, I cant be sure that that this will work, because typo3 supports an extension system. This means, there are plugins which are doing the directory listing on their own, so I would have to change all extensions..
If that is the case, then it sounds like your only choice to hide the .svn folders is to simply, make sure they are not there. Delete them or something.
Zoredache
@Zoredache: Yeah, that has been mentioned, but that is apparently not an appropriate solution. So the answer to his only question is a resounding no. You can't hide .svn directories from PHP.
X-Istence
A: 

If you don't need the .svn folders, you can just delete them.

find ./ -name ".svn" | xargs rm -f *.svn
Dana the Sane
Even if the user PHP runs under has no read privileges to the actual folders, if the parent folder of the .svn is readable the directory will still show up in a file listing. You just won't be able to cd into it and then read its directory listing.
X-Istence
So use the second suggestion to actually delete the svn directories. Is there any reason that won't work?
Noah Goodrich
This is not solving the problem obviously. Subversion is used for versioning so the folder has to stay in place.
Caffeine
He still needs the .svn directories, he just wants to hide them from certain pieces of software.
X-Istence
+3  A: 

So, is there any way to hide special directories from PHP?

No.

As long as the user PHP is run under has read access to the directory it will always produce all the files/directories in that directory. There is no way to hide files from certain processes, were this possible writing a root kit to hide from ls and other file system tools would be a lot easier.

The option you would want/need is a way to define files that Typo3 ignores, and have it be system wide and thus used by the extensions as well. You have specified however that you do not want to change the source code, and do not want to do svn export.

You are thus stuck with the .svn directories.

X-Istence
+4  A: 

This is difficult, since you will have to change behavior of something somewhere between the filesystem and Typo3. You have:

Filesystem → Operating System → PHP → Typo3

The files must stay in the filesystem and must stay visible by the operating system, so you can use SVN. Changing Typo3 is not an option for you, and changing PHP has many other major undesirable consequences that you should avoid. So, what you have left is to insert something in between OS→PHP or PHP→Typo3.

The first case is actually possible, depending on what operating system you use, and if you have administrator (root) access. FUSE is part of the Linux kernel, and is also available for many other operating systems. Then, with fuse, you may install a filter like rofs-filtered, that allows you to filter which files and directories are visible in a mounted volume. You use it to create a filesystem that mirrors your SVN checkout directory, filtering the .svn directories.

Juliano
Isn't that a major slowdown? Given that Typo3 itself isn't really fast due to it's php initialize-complete-application-on-each-request nature...
hurikhan77
A: 

Just find or write a very simple application that will synchronize your current directory with a new directory that will be exposed to the Web. You could have a service that watches for changes or use something like an rsync with exclusions or what have you. This would be much simpler since, based on another question, you are on Windows.

BobbyShaftoe
A: 

ther's an extension called np_subversion which will take care of fileadmin changes via subversion. As a nice plus it will hide folders for you

freddy K.
+2  A: 

The short answer is "Not easily, simply, or sanely".

Run the website from an export of SVN, not a checkout, instead.

David Dorward
A: 

I do not want to setup a svn export --> web_root just to get rid of the files

Are you sure? That’s how SVN is designed: you check code out of SVN to work on it, and export code from SVN to deploy it. If you don’t like that, then SVN probably isn’t the right choice. As gahooa said, maybe switch to Git?

It’s a bit like saying “I want to save my Word document, but I don’t want this stupid .doc file showing up on my computer.” That’s just how the software works.

Paul D. Waite
And what will be solved by switching to git?
Juliano
I believe Git stores its version tracking data in a single file (or folder?) in the root of the working copy. So with Git, you wouldn’t get “the stupid .SVN folders show[ing] up in the directory listing of PHP”. Which is the problem Chris was having. You would get a stupid Git file or folder though, but just the one, in the root.
Paul D. Waite
In other words, it solves nothing. You still have the .git folder, and worse, it contains the whole revision history of the application for the users to download at will. Svk would be a better answer for that matter, since its working copies are *completely* clean of versioning data (it is kept in a completely different place) *and* it is fully compatible o Svn, meaning that he wouldn't need to switch VCSes. Switching VCSes because of this small issue is like suggesting you to replace your car because of a flat tire...
Juliano
Oh, is typo3 a user interface to the site? I see your point. Yeah, SVK sounds like a better option than Git. And I agree switching VCSes isn’t a great solution. It’s just that the solution without switching VCSes (i.e. using Subversion’s export feature) was rather roundly rejected, as I quoted in my answer.
Paul D. Waite
You would probably make the projects structure in git the following way: root dir with ".git" outside document root where you would store other private data too - and let the project go into a "public_html" or "www" folder. Additionally deny download .git folders with apache.
hurikhan77
A: 

Sara Golemon's Runkit can do this. You can remap functions like glob(). However, I am not sure if it's a good idea to run it in a production server.

mst