We are a hosting company wanting to implement a custom webhosting system. We require an Apache 1.3 Module which will be named mod_bwkeeper. Currently, we would like the module to do the following scenario:
* Upon request to a VirtualHost, the module will query a MySQL database (MySQL database format will follow). Two things can then happen:
a. If the bandwidth used is less than the bandwidth allowed, files are served as usual. The bandwidth used in the MySQL database is then incremented by the number of bytes in the current request. This means that for each request, there will be two MySQL queries.
b. If the bandwidth used is more or equal to the bandwidth allowed, the server will display a predetermined file instead of the requested file.
The module must have the following directives:
* BWKeeperDBName: Specifies the MySQL database name to use. (Example: "BWKeeperDBName MyDatabase")
* BWKeeperDBLogin: Specifies the MySQL database username and password to use. (Example: "BWKeeperDBLogin MyUsername MyPassword")
* BWKeeperDBHost: Specifies the MySQL database hostname and port to connect to. (Example: "BWKeeperDBHost localhost 3306")
* BWKeeperGetQuery: Specifies the MySQL query to execute when Apache checks for bandwidth usage. (See attached file for example)
* BWKeeperSetQuery: Specifies the MySQL query to execute when Apache handles a request. (See attached file for example)
* BWKeeperOverquotaFile: Specifies the location of the file to show when the VirtualHost has used up their bandwidth.
Note 1: The first three directives (BWKeeperDBName, BWKeeperDBLogin, BWKeeperDBHost) must be placed in the main configuration.
Note 2: The last three directives (BWKeeperGetQuery, BWKeeperSetQuery, BWKeeperOverquotaFile) can appear in the main configuration or in a VirtualHost block. If placed in the main configuration, the value will apply as a default value. If placed in the VirtualHost block, the configuration will override the default value (if there exists a default value).
Note 3: NONE of the above directives may appear in an .htaccess file.
See attached file for full example, including what the directives will be like in [url removed, login to view], an example MySQL table, etc.
Please note that this module must work with Apache 1.3 only. I do NOT need it to work with Apache 2 or Apache 2.1 (dev). Note that it will need to work along with MySQL 4.
To reduce the number of MySQL connect / disconnects, the module should reuse the connection between requests. The module should NOT open a new MySQL connection for every request. A similar Apache module that reuses database connections is [url removed, login to view] (mod_accounting). The mod_accounting module already tracks bandwidth usage, however, it does NOT compare bandwidth usage with a bandwidth allocated / bandwidth allowed variable.
If you can modify mod_accounting to fit our needs, feel free to do so, as this module will be used for our internal purposes only and will not be redistributed.
For a programmer who is familiar with Apache internals, this should be a relatively easy project. Please let us know should you have any questions prior to bidding, or comments / input on this project, and feel free to include any previous work you would liike us to know about.
This project will be a part of more projects in the near future.