From aa3ea245dd208d5b80afdb6f8ef35c9d6409d7cd Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 26 Sep 2010 09:25:29 -0400
Subject: [PATCH] Implemented: FS#1325 - Option to create remoting user automatically during package installation from repository Implemented: VAT-ID and customer No. fields for client and reseller.
---
server/plugins-available/apache2_plugin.inc.php | 77 +++++++++++++++++++++++++-------------
1 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 8832d98..135f549 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -1052,13 +1052,14 @@
*/
public function webdav($event_name,$data) {
global $app, $conf;
+
+ /*
+ * load the server configuration options
+ */
+ $app->uses("getconf");
+ $web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
if (($event_name == 'webdav_user_insert') || ($event_name == 'webdav_user_update')) {
- /*
- * load the server configuration options
- */
- $app->uses("getconf");
- $web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
/*
* Get additional informations
@@ -1134,12 +1135,29 @@
*/
$sitedata = $app->db->queryOneRecord("SELECT document_root, domain FROM web_domain WHERE domain_id = " . $data['old']['parent_domain_id']);
$documentRoot = $sitedata['document_root'];
+ $domain = $sitedata['domain'];
/*
* We dont't want to destroy any (transfer)-Data. So we do NOT delete any dir.
* So the only thing, we have to do, is to delete the user from the password-file
*/
$this->_writeHtDigestFile( $documentRoot . '/webdav/' . $data['old']['dir'] . '.htdigest', $data['old']['username'], $data['old']['dir'], '');
+
+ /*
+ * Next step, patch the vhost - file
+ */
+ $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"] . '/' . $domain . '.vhost');
+ $this->_patchVhostWebdav($vhost_file, $documentRoot . '/webdav');
+
+ /*
+ * Last, restart apache
+ */
+ if($apache_chrooted) {
+ $app->services->restartServiceDelayed('httpd','restart');
+ } else {
+ // request a httpd reload when all records have been processed
+ $app->services->restartServiceDelayed('httpd','reload');
+ }
}
}
@@ -1155,26 +1173,29 @@
*/
private function _writeHtDigestFile($filename, $username, $authname, $pwdhash ) {
$changed = false;
- $in = fopen($filename, 'r');
- $output = '';
- /*
- * read line by line and search for the username and authname
- */
- while (preg_match("/:/", $line = fgets($in))) {
- $line = rtrim($line);
- $tmp = explode(':', $line);
- if ($tmp[0] == $username && $tmp[1] == $authname) {
- /*
- * found the user. delete or change it?
- */
- if ($pwdhash != '') {
- $output .= $tmp[0] . ':' . $tmp[1] . ':' . $pwdhash . "\n";
- }
- $changed = true;
+ if(is_file($filename)) {
+ $in = fopen($filename, 'r');
+ $output = '';
+ /*
+ * read line by line and search for the username and authname
+ */
+ while (preg_match("/:/", $line = fgets($in))) {
+ $line = rtrim($line);
+ $tmp = explode(':', $line);
+ if ($tmp[0] == $username && $tmp[1] == $authname) {
+ /*
+ * found the user. delete or change it?
+ */
+ if ($pwdhash != '') {
+ $output .= $tmp[0] . ':' . $tmp[1] . ':' . $pwdhash . "\n";
+ }
+ $changed = true;
+ }
+ else {
+ $output .= $line . "\n";
+ }
}
- else {
- $output .= $line . "\n";
- }
+ fclose($in);
}
/*
* if we didn't change anything, we have to add the new user at the end of the file
@@ -1182,12 +1203,16 @@
if (!$changed) {
$output .= $username . ':' . $authname . ':' . $pwdhash . "\n";
}
- fclose($in);
+
/*
* Now lets write the new file
*/
- file_put_contents($filename, $output);
+ if(trim($output) == '') {
+ unlink($filename);
+ } else {
+ file_put_contents($filename, $output);
+ }
}
/**
--
Gitblit v1.9.1