Re: is this possible in PHP?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux