관리-도구
편집 파일: SoftaculousEventsHandler.php
<?php include_once ('EventPublisher.php'); function getSoftaculousInstallationDir($docroot, $path) { // doctoot - "/home/moaddib" // path - "/home/moaddib/test1" $docrootSize = strlen($docroot); if ($path && substr($path, 0, $docrootSize) == $docroot) { // Remove path prefix by len $path = substr($path, $docrootSize + 1); // 1 - remove ending `/` } // return string return $path ? $path : ""; } function softaculousWebsiteDeleted($instalation) { global $softpanel; $data = $instalation[0]; $domain = $data['softdomain']; $payload = [ 'metadata' => [ 'entityId' => $data['insid'], 'entityName' => 'website', 'eventName' => 'softaculousWebsiteDeleted' ], 'payload' => [ 'path' => getSoftaculousInstallationDir($softpanel->domainroots[$domain], $data['softpath']), 'url' => $data['softurl'], 'domain' => $domain, 'db' => isset($data['softdb']) ? $data['softdb'] : "", 'dbUser' => isset($data['softdbuser']) ? $data['softdbuser'] : "", 'user' => $softpanel->user['name'] ] ]; $publisher = new HcEventPublisher\EventPublisher(); return $publisher->send($payload); } function softaculousWebsiteCreated($instalation) { global $softpanel; global $__settings; $data = $instalation[0]; $domain = $data['softdomain']; $payload = [ 'metadata' => [ 'entityId' => $data['insid'], 'entityName' => 'website', 'eventName' => 'softaculousWebsiteCreated', ], 'payload' => [ 'path' => getSoftaculousInstallationDir($softpanel->domainroots[$domain], $data['softpath']), 'url' => $data['softurl'], 'domain' => $data['softdomain'], 'db' => isset($data['softdb']) ? $data['softdb'] : "", 'dbUser' => isset($data['softdbuser']) ? $data['softdbuser'] : "", 'user' => $softpanel->user['name'], 'admin_email' => $data["admin_email"], 'version' => $data['ver'], 'cms' => (int) $data['sid'], 'site_name' => $data['site_name'], 'auto_upgrade_plugins' => (bool) $data['auto_upgrade_plugins'], 'auto_upgrade_themes' => (bool) $data['auto_upgrade_themes'], 'disable_notify_update' => (int) $data['disable_notify_update'], 'core_auto_upgrade' => (int) $data['eu_auto_upgrade'] ] ]; $publisher = new HcEventPublisher\EventPublisher(); return $publisher->send($payload); } function softaculousWebsiteDiscovered($installation) { global $softpanel; global $__settings; $domain = $installation['softdomain']; $payload = [ 'metadata' => [ 'entityId' => '_', //there is no id here yet, but the protocol provides this field as required 'entityName' => 'website', 'eventName' => 'softaculousWebsiteDiscovered', ], 'payload' => [ 'path' => getSoftaculousInstallationDir($softpanel->domainroots[$domain], $installation['softpath']), 'url' => $installation['softurl'], 'domain' => $domain, 'db' => isset($installation['softdb']) ? $installation['softdb'] : "", 'dbUser' => isset($installation['softdbuser']) ? $installation['softdbuser'] : "", 'user' => $softpanel->user['name'], 'version' => $installation['ver'], 'cms' => (int) $installation['sid'], 'siteName' => isset($installation['site_name']) ? $installation['site_name'] : "" ] ]; $publisher = new HcEventPublisher\EventPublisher(); return $publisher->send($payload); } ?>