Hey all,
Anyone have anything "pre-built" I can use to open a file, read the contents where each line starts with a variable name, whitespace, then a value (which may or may not contains spaces)?
Okay, before you all scratch your head over what I'm trying to do, here goes:
I currently run a virtual web server (who doesn't these days?) and I'd like to give my clients (and especially my resellers) a little bit of control over their virtual server setup under Apache.
To do this, I split each of their virtual domain entries into separate files and chown'd them to the Apache user so I can read/write the files via PHP.
Each file consists of the following lines:
<VirtualHost 1.2.3.4>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin webmaster@mydomain.com
DocumentRoot /disk/path/mydomain.com/public_html
ErrorLog /disk/path/mydomain.com/logs/error_log
TransferLog /disk/path/mydomain.com/logs/access_log
ScriptAlias /cgi-bin/ /disk/path/mydomain.com/cgi-bin/
ServerSignature Email
Options IncludesNOEXEC Includes Indexes SymLinksIfOwnerMatch FollowSymLinks
</VirtualHost>
So what I'd LIKE to do is reach each line into PHP memory so I can call a function and have something like the following in an array:
$my_details = parse_domain_file ("mydomain.com") ;
$my_details[IP] = "1.2.3.4" ;
$my_details[ScriptAlias] = "/cgi-bin/ /disk/path/mydomain.com/cgi-bin/" ;
$my_details[ServerAdmin] = "info@mydomain.com" ;
write_domain_file ("mydomain.com",$my_details) ;
etc.
Anyone have anything like this, or should I just build it from scratch? ;o)
Ian