tbrehm
2007-10-17 af8f1ba169081990bfbe62fe295d8124f6aadc5c
server/plugins-enabled/apache2_plugin.inc.php
@@ -49,6 +49,10 @@
      $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
      $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete');
      
      $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip');
      $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip');
      $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip');
   }
   
   function insert($event_name,$data) {
@@ -68,7 +72,7 @@
      if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
         // This is not a vhost, so we need to update the parent record instead.
         $parent_domain_id = intval($data["new"]["parent_domain_id"]);
         $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id);
         $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'");
         $data["new"] = $tmp;
         $data["old"] = $tmp;
      }
@@ -91,12 +95,20 @@
      
      // Check if the directories are there and create them if nescessary.
      if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
      if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log");
      if(!is_dir($data["new"]["document_root"]."/web/error")) exec("mkdir -p ".$data["new"]["document_root"]."/web/error");
      //if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log");
      if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl");
      if(!is_dir($data["new"]["document_root"]."/cgi-bin")) exec("mkdir -p ".$data["new"]["document_root"]."/cgi-bin");
      
      // Create the symlink for the logfiles
      if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]);
      if(!is_link($data["new"]["document_root"]."/log")) exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
      // TODO: Create the symlinks
      
      // Copy the error pages
      $error_page_path = escapeshellcmd($data["new"]["web_document_root"])."/web/error/";
      exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
      
      // Create group and user, if not exist
      $app->uses("system");
@@ -150,7 +162,7 @@
      }
      
      // get alias domains (co-domains and subdomains)
      $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]);
      $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'");
      $server_alias = '';
      if(is_array($aliases)) {
         foreach($aliases as $alias) {
@@ -217,6 +229,16 @@
      
   }
   
   //* This function is called when a IP on the server is inserted, updated or deleted
   function server_ip($event_name,$data) {
      global $app, $conf;
      // Here we write the name virtualhost directives
      // NameVirtualHost IP:80
      // NameVirtualHost IP:443
   }
} // end class