plugins->registerEvent('web_domain_insert', $this->plugin_name, 'insert'); $app->plugins->registerEvent('web_domain_update', $this->plugin_name, 'update'); } function insert($event_name, $data) { global $app, $conf; $this->action = 'insert'; // just run the update function $this->update($event_name, $data); } function update($event_name, $data) { global $app, $conf; if($this->action != 'insert') $this->action = 'update'; if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { $old_parent_domain_id = intval($data["old"]["parent_domain_id"]); $new_parent_domain_id = intval($data["new"]["parent_domain_id"]); // If the parent_domain_id has been chenged, we will have to update the old site as well. if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; $this->update($event_name, $data); } // This is not a vhost, so we need to update the parent record instead. $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; } if($data["new"]["document_root"] == '') { $app->log("document_root not set", LOGLEVEL_WARN); return 0; } $symlink = true; if($data["new"]["php"] == "suphp") $symlink = false; elseif($data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y") $symlink = false; elseif($data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y") $symlink = false; if(!is_dir($data["new"]["document_root"]."/web")) mkdir($data["new"]["document_root"].'/web', 0755, true); if($symlink == false) { if(is_link($data["new"]["document_root"].'/web/phpmyadmin')) unlink($data["new"]["document_root"].'/web/phpmyadmin'); } else { if(!is_link($data["new"]["document_root"].'/web/phpmyadmin')) symlink('/var/www/phpmyadmin', $data["new"]["document_root"].'/web/phpmyadmin'); else symlink('/var/www/phpmyadmin', $data["new"]["document_root"].'/web/phpmyadmin'); } } } // end class ?>