📄 httpd_conf.old
字号:
#!/usr/local/bin/php -f
<?php
require(dirname(dirname(__FILE__)) . "/conf/mysql.inc.php");
/*
* Justin Osterholt
* 11/26/05
* mysql connect/db select code moved from mysq.inc.php
*/
$link = mysql_connect($conf['hostname'], $conf['username'], $conf['password']) or die("Unable to connect to the MySQL Database: " . mysql_error());
mysql_select_db($conf['database']) or die("Unable to connect to the MySQL Database: " . mysql_error());
define("HTTPD_CONF", "/usr/local/apache/conf/httpd.conf");
// get users to write, and unwrite
// get code to write
$query = mysql_query("SELECT DISTINCT a.username FROM accounts AS a LEFT JOIN packages AS b ON (a.package = b.id) WHERE b.pkg_type = 1");
if(is_resource($query))
{
while($data = mysql_fetch_assoc($query))
{
$database_result[$data['username']] = 1;
}
}
$query = mysql_query("SELECT header_path, footer_path FROM settings");
if(is_resource($query))
{
list($header, $footer) = mysql_fetch_row($query);
// BEGIN CHECK FOR TAG MERGE ON / OFF
$query = mysql_query("SELECT layout_merge FROM settings");
$merge = mysql_result($query, 0);
// make sure path is clear.
$path = '';
if($merge == 1)
{
$path = "LayoutMerge On\n";
}
// END CHECK FOR TAG MERGE ON / OFF
$path .= "LayoutHeader $header/header.html\n";
$path .= "LayoutFooter $footer/footer.html\n";
}
$file = file(HTTPD_CONF);
$pipe = fopen(HTTPD_CONF, "w");
$user = '';
$written = 0;
$layoutMergeUsed = 0;
foreach($file as $line)
{
if(preg_match('@^\s*Layout(Header|Footer)\s+(.*)@i', $line))
{
continue;
}
if(!preg_match('/LayoutMerge On/', $line) || $layoutMergeUsed == 0) {
fwrite($pipe, $line);
}
if(preg_match('@^\s*Group\s+(.*)@i', $line, $m))
{
$written = 0;
$user = trim($m[1]);
}
if(strlen($user) < 1)
{
continue;
}
if(preg_match('/LayoutMerge On/', $line)) {
$layoutMergeUsed = 1;
}
if(preg_match('@</virtualhost>@i', $line))
{
$written = 0;
$layoutMergeUsed = 0;
$user = '';
continue;
}
if((strlen(trim($line) < 1)) && (strlen($user) > 0) && ($database_result[$user] == 1) && ($written == 0))
{
$written = 1;
fwrite($pipe, $path, strlen($path));
}
}
system("/usr/local/apache/bin/apachectl restart");
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -