I've just bough VPS account for testing and development.
我只是用VPS帐户进行测试和开发。
Is there a function of PHP to parse Apache config file, PHP config, FTP Server config, zone files, etc? Also a way to insert data into config file.
是否有PHP的功能来解析Apache配置文件,PHP配置,FTP服务器配置,区域文件等?也是一种将数据插入配置文件的方法。
I want to create a simple Control Panel to add ftp accounts and web account (with domain). If you have done it before - how did you do it?
我想创建一个简单的控制面板来添加ftp帐户和网络帐户(带域名)。如果你以前做过 - 你是怎么做到的?
It would be quite challenging to learn
学习起来非常具有挑战性
Thanks.
3 个解决方案
#1
2
No, PHP has no functions to parse the config files of those programs - you'll have to write a custom parser for most of those formats. However, for php.ini you might be able to use PHP's ini functions.
不,PHP没有解析这些程序的配置文件的功能 - 您必须为大多数格式编写自定义解析器。但是,对于php.ini,您可以使用PHP的ini函数。
Most webhosting control panels either create the whole config file based on their database - i.e. they never read it but only (over)write it or they require you to include (apache and bind support that for example, for PHP you can use php_admin_value in the apache virtualhosts) their generated file - which is also never read by the tool.
大多数虚拟主机控制面板要么基于他们的数据库创建整个配置文件 - 即他们从不读取它而只是(过)写它或者它们要求你包括(apache和绑定支持,例如,对于PHP,你可以使用php_admin_value apache virtualhosts)他们生成的文件 - 工具也从未读过。
If you really want to create a tool that actually modifies existing files, don't forget that you cannot simply skip comments as nobody would want an application to rewrite his config file stripping all comments.
如果你真的想创建一个实际修改现有文件的工具,不要忘记你不能简单地跳过评论,因为没有人希望应用程序重写他的配置文件剥离所有注释。
#2
2
You may be able to use the follow pear library to parse apache config files:
您可以使用follow pear库来解析apache配置文件:
http://pear.php.net/manual/en/package.configuration.config.avail-container.apache.php
Parsing a php.ini file, depending on what you want to do, is probably best done with ini_get
解析一个php.ini文件,取决于你想要做什么,最好用ini_get来完成
#3
0
I'm not aware of such functions and I highly doubt they exist for the simple reason that there are just too many HTTP / FTP / SMTP / ... server implementations. Control panels like cPanel, WebMin and others usually do the heavy lifting for you and some even provide an API to automatize things from PHP.
我不知道这些功能,我非常怀疑它们存在的原因很简单,因为有太多的HTTP / FTP / SMTP / ...服务器实现。像cPanel,WebMin等控制面板通常会为您提供繁重的工作,有些甚至提供了一个API来自动化PHP的东西。
For the PHP configuration the following functions will probably do the trick:
对于PHP配置,以下函数可能会起到作用:
Bare in mind however that not all PHP configuration directives can be changed with ini_set()
.
但是请记住,并非所有PHP配置指令都可以使用ini_set()进行更改。
#1
2
No, PHP has no functions to parse the config files of those programs - you'll have to write a custom parser for most of those formats. However, for php.ini you might be able to use PHP's ini functions.
不,PHP没有解析这些程序的配置文件的功能 - 您必须为大多数格式编写自定义解析器。但是,对于php.ini,您可以使用PHP的ini函数。
Most webhosting control panels either create the whole config file based on their database - i.e. they never read it but only (over)write it or they require you to include (apache and bind support that for example, for PHP you can use php_admin_value in the apache virtualhosts) their generated file - which is also never read by the tool.
大多数虚拟主机控制面板要么基于他们的数据库创建整个配置文件 - 即他们从不读取它而只是(过)写它或者它们要求你包括(apache和绑定支持,例如,对于PHP,你可以使用php_admin_value apache virtualhosts)他们生成的文件 - 工具也从未读过。
If you really want to create a tool that actually modifies existing files, don't forget that you cannot simply skip comments as nobody would want an application to rewrite his config file stripping all comments.
如果你真的想创建一个实际修改现有文件的工具,不要忘记你不能简单地跳过评论,因为没有人希望应用程序重写他的配置文件剥离所有注释。
#2
2
You may be able to use the follow pear library to parse apache config files:
您可以使用follow pear库来解析apache配置文件:
http://pear.php.net/manual/en/package.configuration.config.avail-container.apache.php
Parsing a php.ini file, depending on what you want to do, is probably best done with ini_get
解析一个php.ini文件,取决于你想要做什么,最好用ini_get来完成
#3
0
I'm not aware of such functions and I highly doubt they exist for the simple reason that there are just too many HTTP / FTP / SMTP / ... server implementations. Control panels like cPanel, WebMin and others usually do the heavy lifting for you and some even provide an API to automatize things from PHP.
我不知道这些功能,我非常怀疑它们存在的原因很简单,因为有太多的HTTP / FTP / SMTP / ...服务器实现。像cPanel,WebMin等控制面板通常会为您提供繁重的工作,有些甚至提供了一个API来自动化PHP的东西。
For the PHP configuration the following functions will probably do the trick:
对于PHP配置,以下函数可能会起到作用:
Bare in mind however that not all PHP configuration directives can be changed with ini_set()
.
但是请记住,并非所有PHP配置指令都可以使用ini_set()进行更改。