You are here: Re: [PHP] is this possible in PHP? « PHP « IT news, forums, messages
Re: [PHP] is this possible in PHP?

Posted by Rasmus Lerdorf on 05/03/05 11:08

Dasmeet Singh wrote:
> Hi!
>
> I want a script that can display a list of all the websites currently
> hosted on my server.. (i have root access to the server)
>
> Say I have a page sitesonmyserver.php..it shud show a list of all the
> websites hosted on my server..eg:
> abc.com
> xyz.om
>
> And any additional info if possible?
>
> Is such a thing possible in PHP.. or does any such script exists?

Generally, no. You would need some black magic that probed the guts of
your web server for this information. And by black magic I mean some
low-level C code.

A bit of grey magic I wrote almost exactly 9 years ago now! (May 1,
1996) in the form of Apache's mod_info module might help you out a
little bit. If you define all your vhosts in your httpd.conf file and
not in included files, then you can enable mod_info in your Apache
config, and restrict access to the information to localhost with
something like:

<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

Then your PHP code would hit your server's local /server-info link and
parse it with something along the lines of:

$info = file_get_contents('http://localhost/server-info?http_core.c');
preg_match_all('/.*servername <.*?>(\S+?)<.*/i',$info,$reg);
$vhosts = $reg[1];

You may need to doublecheck that regex. I didn't actually test it.

-Rasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация