Lots of empty index.html files on server

Hi,

I've got a bespoke CMS running on a server, and for some reason when I log into FTP I can see thousands of empty index.html files.

I have no idea what's creating them, but wondered if there is any part of ob_start() that would output a file for each visit or something?
SheppardDigitalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwad99Commented:
It is most likely a security measure.  If someone browses to one of the directories on your server, and there is no index.html (or index.jsp/index.asp, index.aspx etc etc), then your server will serve up a default page which lists every file and every directory in that path.

You don't really want to be exposing this to visitors, so the presence of an empty page ensures that if anyone browses to a path on your site, all they see is an empty page.

HTH
0
mrwad99Commented:
An example of a site where there is no default index.html is http://rdsrc.us/z1ybSp
0
SheppardDigitalAuthor Commented:
Hi,

I don't think that is the problem.

When I log into the FTP for the site, there is a public_html folder which as you would expect contains all the site files. However, these index files which are being automatically created are being created outside of the public_html folder.

This morning when I logged in to the FTP there were about 12,000 index files with file names such as

index.html
index.html.1
index.html.2
index.html.2.2
index.html.3
and so on
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

RobOwner (Aidellio)Commented:
What did your host say about this?
0
SheppardDigitalAuthor Commented:
it's my own server, which is running cPanel
0
RobOwner (Aidellio)Commented:
So they're just being created in your home directory or everywhere? Any pattern to where the files are being put?
0
Ray PaseurCommented:
Is there any pattern to the content of the files? Or are they all just completely empty (no whitespace)?

Have you scanned the code for all instances of file_put_contents() or fopen() or similar statements that might be used to create a file?
0
Julian HansenCommented:
but wondered if there is any part of ob_start() that would output a file for each visit or something?
That is not the function of ob_start() but interested to know why you asked that particular question.

Other posibilities include a potential caching solution that is not functioning correctly.

Have you scanned your web site files for the phrase index.html (or just index) to see if you can find code that might be doing it.

This is not common behaviour it is very likely something that has been coded so we would need more info to help you track it.
0
Ray PaseurCommented:
Interesting question about ob_start(), given the warning on that man page.  Have you set up any tests around this function?
0
SheppardDigitalAuthor Commented:
The reason I asked about ob_start() is because I know the CMS uses it to cache the output, and then later it modified the HTML before passing it to the browser. I didn't know if this had something to do with the creation of the files.

The files are only created in a single folder outside of the public_html folder.

I'm going to perform a search on the code now for anything that saves or opens a file to see if that could be doing anything.

It seems to be that the application is creating a file for every visit. Hence the reason there were thousands of them.
0
SheppardDigitalAuthor Commented:
I've had a look at some of the files, and it seems some of them contain error messages

The content of one of the files was...

"Error with query:<br /><pre>SELECT * FROM sites WHERE domain LIKE "%[digitalcmscouk.cmsdevsvr.com]%"</pre><br /><br >Unknown MySQL server host '__DEV_DB_HOST' (1)"

So I guess its some kind of error logging or something.
0
Ray PaseurCommented:
Ahh, that should make it easier to diagnose.  Scan the code base for "Error with query" and you will probably find the culprit!
0
SheppardDigitalAuthor Commented:
I did a search for "Error with query" but as we are using a database class, that only appears in one file, and there's no code in there which writes to a file.

I wonder if somewhere I've introduced a custom error handler function which is doing it?
0
SheppardDigitalAuthor Commented:
I think I've tracked the problem down, although I don't fully understand it.

I had set a custom error handler so it pointed to a function of my own. Only the function was empty. So I don't know why the file was being created.

I commented out the custom error handler definition and the files are no longer created.
0
Julian HansenCommented:
That could explain it.
0
Ray PaseurCommented:
Interesting.  Without seeing the code, I can't speculate as to what the empty function caused.  Perhaps there was something throwing an exception that was uncaught?
0
SheppardDigitalAuthor Commented:
In the empty function I put a line of code which emailed me the error message. Each time an error occurred I was sent an email and a file created on the server.

When I commented out the custom error handler decleration I didn't receive an email and neither was a file created.

At least I've found the problem, but it puzzles me why a file was being created.
0
Ray PaseurCommented:
Dunno.  Could be a hiccup in the mail server.  You might try other automated mail commands and see if they cause the same files to appear.
0
Slick812Commented:
It is likely that your CMS has some "Default" sub code that runs for any "Custom Error" that you initiate, your documentation for the CMS may have "How to overide" the "Default" sub code that runs for any "Custom Error" that you initiate. I have seen this ""Default" sub code that runs for any "Custom Error" that you initiate" in several frame works, but this is just a guess, and it is a fact that some code is producing the index files that you did not write, you may do a search for the folder (directory) name where the index are produced, since there are very many methods to create a file in PHP.
Also it is a very bad practice to have any Function be an empty function.
0
SheppardDigitalAuthor Commented:
Just to wrap this one up.

The CMS was defining a custom error method, which was empty. For some reason PHP was creating a file each time this function was executed. There was no-code in the CMS to create a file (the function was empty).

When I edited the function and told it to do something (like email me), it no longer created the files. So it seems it was creating the files because the function was empty.

I've since commented out the line which defined the custom error handler and the problem is now resolved.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SheppardDigitalAuthor Commented:
I believe I resolved this problem myself.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.