public function init()
 {
     parent::init();
     $this->addElement('simpleText', 'path', array('label' => $this->lmsg('pathLabel'), 'value' => $this->_slave->getConfigPath()));
     $this->addElement('textarea', 'config', array('value' => $this->_slave->content(), 'decorators' => [['Callback', ['callback' => [$this, 'decorateConfig']]]]));
     $this->addControlButtons(array('hideLegend' => true, 'sendHidden' => true, 'cancelLink' => pm_Context::getBaseUrl()));
 }
 public function viewAction()
 {
     $this->view->pageTitle = $this->lmsg('viewPageTitle');
     $this->view->uplevelLink = pm_Context::getBaseUrl();
     $config = $this->_getParam('config');
     $slave = new Modules_SlaveDnsManager_Slave($config);
     $this->view->form = new Modules_SlaveDnsManager_Form_View($slave);
 }
 public function init()
 {
     parent::init();
     $this->addElement('text', 'ip', array('label' => $this->lmsg('ipLabel'), 'value' => '', 'class' => 'f-large-size', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Ip', true))));
     $this->addElement('text', 'port', array('label' => $this->lmsg('portLabel'), 'value' => '953', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Int', true))));
     $this->addElement('select', 'algorithm', array('label' => $this->lmsg('algorithmLabel'), 'multiOptions' => array('hmac-md5' => 'hmac-md5'), 'value' => 'hmac-md5', 'required' => true));
     $this->addElement('text', 'secret', array('label' => $this->lmsg('secretLabel'), 'value' => $this->_getRandomSecret(), 'class' => 'f-large-size', 'required' => true, 'validators' => array(array('NotEmpty', true), array('Callback', true, array(array($this, 'isValidSecret'))))));
     $this->addControlButtons(array('cancelLink' => pm_Context::getBaseUrl()));
 }
Example #4
0
 public function indexAction()
 {
     // TODO: allow access for admin only
     $this->view->pageTitle = 'Panel Statistics Settings';
     $form = new Modules_PanelStats_Form_Settings();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $form->process();
         $this->_status->addMessage('info', 'Settings were saved.');
         $this->_helper->json(array('redirect' => pm_Context::getModulesListUrl()));
     }
     $this->view->form = $form;
 }
Example #5
0
 private function _getListRandom()
 {
     $data = array();
     $iconPath = pm_Context::getBaseUrl() . 'images/icon_16.gif';
     for ($i = 0; $i < 150; $i++) {
         $data[] = array('column-1' => '<a href="#">' . (string) rand() . '</a>', 'column-2' => '<img src="' . $iconPath . '" /> ' . (string) rand());
     }
     $list = new pm_View_List_Simple($this->view, $this->_request);
     $list->setData($data);
     $list->setColumns(array('column-1' => array('title' => 'Random with link', 'noEscape' => true), 'column-2' => array('title' => 'Random with image', 'noEscape' => true)));
     // Take into account listDataAction corresponds to the URL /list-data/
     $list->setDataUrl(array('action' => 'list-data'));
     return $list;
 }
Example #6
0
 public function init()
 {
     $this->addElement('description', 'description', array('description' => 'You can protect statistics information or make it public available.'));
     $useAuth = (bool) pm_Settings::get('useAuth');
     $this->addElement('checkbox', 'useAuth', array('label' => 'Protect access using auth token', 'value' => $useAuth));
     $authToken = pm_Settings::get('authToken');
     $this->addElement('text', 'authToken', array('label' => 'Auth token', 'value' => $authToken));
     $authToken = $useAuth ? $authToken : '';
     $baseUrl = pm_Context::getBaseUrl() . "public/?authToken={$authToken}";
     $this->addElement('simpleText', 'link_xml', array('label' => 'Statistics in XML format', 'escape' => false, 'value' => "<a href='{$baseUrl}&format=xml' target='_blank'>Link</a>"));
     $this->addElement('simpleText', 'link_json', array('label' => 'Statistics in JSON format', 'escape' => false, 'value' => "<a href='{$baseUrl}&format=json' target='_blank'>Link</a>"));
     $this->addElement('simpleText', 'link_plain', array('label' => 'Statistics in plain text format', 'escape' => false, 'value' => "<a href='{$baseUrl}&format=plain' target='_blank'>Link</a>"));
     $this->addControlButtons(array('cancelHidden' => true));
 }
Example #7
0
 public function indexAction()
 {
     $this->view->pageTitle = $this->lmsg('formTitle');
     $form = new Modules_ApiUsage_Form_CreateClientAndWebspace();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         try {
             $form->process();
             $this->_helper->json(array('redirect' => pm_Context::getModulesListUrl()));
         } catch (pm_Exception $exception) {
             $this->_status->addMessage('error', $exception->getMessage());
         }
         $this->_helper->json(array('redirect' => pm_Context::getModulesListUrl()));
     }
     $this->view->form = $form;
 }
 public function getButtons()
 {
     $buttons = [['place' => self::PLACE_COMMON, 'order' => 2, 'title' => pm_Locale::lmsg('commonButtonTitle'), 'description' => pm_Locale::lmsg('commonButtonDescription'), 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index')], ['place' => self::PLACE_COMMON, 'order' => 3, 'title' => 'Common Button #2', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index')], ['place' => self::PLACE_COMMON, 'order' => 4, 'title' => 'Common Button #3', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index')], ['place' => self::PLACE_ADMIN_HOME, 'title' => 'Admin Home Button', 'description' => 'Description for admin home button', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => 'http://www.plesk.com/', 'newWindow' => true], ['place' => self::PLACE_CUSTOMER_HOME, 'title' => 'Customer Home Button', 'description' => 'Description for customer home button', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index')], ['place' => self::PLACE_DOMAIN, 'title' => 'Domain Button', 'description' => 'Description for domain button', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index')], ['place' => array_filter([self::PLACE_HOSTING_PANEL_NAVIGATION, version_compare(pm_ProductInfo::getVersion(), '17.0') >= 0 ? self::PLACE_HOSTING_PANEL_TABS : null, self::PLACE_ADMIN_TOOLS_AND_SETTINGS, self::PLACE_RESELLER_TOOLS_AND_SETTINGS]), 'title' => 'Multi Place Button', 'description' => 'Description for multi place button', 'link' => pm_Context::getActionUrl('index', 'another')], ['place' => self::PLACE_DOMAIN, 'targetId' => 'buttonBackup', 'hidden' => true], ['place' => self::PLACE_DOMAIN_PROPERTIES, 'targetId' => 'buttonLogs', 'hidden' => true, 'contextParams' => true], ['place' => self::PLACE_DOMAIN_PROPERTIES, 'targetId' => 'buttonSitebuilder', 'title' => 'Sitebuilder', 'description' => 'My Sitebuilder', 'link' => pm_Context::getActionUrl('index'), 'contextParams' => true], ['place' => self::PLACE_DOMAIN_PROPERTIES, 'title' => 'Domain Properties Button', 'description' => 'Description for domain properties button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true], ['place' => self::PLACE_RESELLER_HOME, 'title' => 'Reseller Home Button', 'description' => 'Description for Reseller home button', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => 'http://www.plesk.com/', 'newWindow' => true], ['place' => self::PLACE_ADMIN_TOOLS_AND_SETTINGS, 'title' => 'Tools and settings button', 'section' => 'securityPanel-tools-list', 'order' => 3, 'description' => 'Description for multi place button', 'link' => pm_Context::getActionUrl('index', 'another')]];
     if (version_compare(pm_ProductInfo::getVersion(), '12.1') >= 0) {
         $buttons[] = ['place' => self::PLACE_TOOLBAR, 'id' => 'toolbox-button-id', 'title' => 'Toolbar Button', 'description' => 'Description for toolbar button', 'icon' => pm_Context::getBaseUrl() . 'images/icon.png', 'link' => pm_Context::getActionUrl('index', 'another'), 'visibility' => function ($options) {
             if (isset($options['controller']) && 'email-address' == $options['controller']) {
                 return true;
             }
             return false;
         }];
     }
     if (version_compare(pm_ProductInfo::getVersion(), '17.0') >= 0) {
         $newButtons = [['place' => self::PLACE_ADMIN_TOOLS_AND_SETTINGS, 'section' => 'mailButtons', 'order' => 2, 'title' => 'Mail Settings Button', 'description' => 'Description for Mail Settings Button', 'link' => pm_Context::getActionUrl('index', 'another')], ['place' => self::PLACE_ADMIN_NAVIGATION, 'section' => 'hosting', 'order' => 4, 'title' => 'Admin Navigation Button', 'description' => 'Description for Admin Navigation Button', 'link' => pm_Context::getActionUrl('index', 'another')], ['place' => self::PLACE_RESELLER_NAVIGATION, 'section' => 'profile', 'order' => 3, 'title' => 'Reseller Navigation Button', 'description' => 'Description for Navigation Button', 'link' => pm_Context::getActionUrl('index', 'another')], ['place' => self::PLACE_DOMAIN_PROPERTIES, 'order' => 1, 'title' => 'Domain Properties Button', 'additionalComments' => 'Additional comment for Domain Properties Button', 'description' => 'Description for domain properties button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true], ['place' => self::PLACE_RESELLER_TOOLS_AND_SETTINGS, 'section' => 'toolsButtons', 'order' => 5, 'title' => 'Reseller Tools And Settings button', 'additionalComments' => 'Additional comment for Reseller Tools And Settings button', 'description' => 'Description for Reseller Tools And Settings button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true], ['place' => self::PLACE_RESELLER_TOOLS_AND_SETTINGS, 'section' => self::SECTION_RESELLER_TOOLS_SERVICES, 'title' => 'Reseller Tools and Utilities', 'additionalComments' => 'Additional comment for Reseller Tools and Utilities button', 'description' => 'Description for Reseller Tools and Utilities button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true], ['place' => self::PLACE_RESELLER_TOOLS_AND_SETTINGS, 'section' => self::SECTION_RESELLER_TOOLS_RESOURCES, 'title' => 'Reseller Tools and Utilities', 'additionalComments' => 'Additional comment for Reseller Tools and Utilities button', 'description' => 'Description for Reseller Tools and Utilities button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true], ['place' => self::PLACE_RESELLER_TOOLS_AND_SETTINGS, 'section' => self::SECTION_RESELLER_TOOLS_ADDITIONAL_SERVICES, 'title' => 'Reseller Tools and Utilities', 'additionalComments' => 'Additional comment for Reseller Tools and Utilities button', 'description' => 'Description for Reseller Tools and Utilities button', 'link' => pm_Context::getActionUrl('index', 'another'), 'contextParams' => true]];
         $buttons = array_merge($buttons, $newButtons);
     }
     return $buttons;
 }
    public function save(array $data)
    {
        $keyAlgorithm = array_key_exists('algorithm', $data) ? $data['algorithm'] : 'hmac-md5';
        $keySecret = $data['secret'];
        $slaveIp = $data['ip'];
        $slavePort = array_key_exists('port', $data) ? $data['port'] : 953;
        $view = new Zend_View();
        $view->setScriptPath(pm_Context::getPlibDir() . 'views/scripts');
        $rndc = new Modules_SlaveDnsManager_Rndc();
        $pleskIp = $view->escape($rndc->getServerIP());
        $slaveConfiguration = $view->partial('index/slave-config.phtml', array('pleskIp' => $pleskIp, 'secret' => $keySecret));
        $slaveConfiguration = trim(html_entity_decode(strip_tags($slaveConfiguration)));
        $slaveConfiguration = preg_replace('/^/m', '    ', $slaveConfiguration);
        $configuration = <<<CONF
/*
{$slaveConfiguration}
*/

key "rndc-key" {
    algorithm {$keyAlgorithm};
    secret "{$keySecret}";
};

options {
    default-key "rndc-key";
    default-server {$slaveIp};
    default-port {$slavePort};
};
CONF;
        if (null === $this->_config) {
            $this->_config = "slave_{$slaveIp}.conf";
        }
        $result = file_put_contents($this->getConfigPath(), $configuration);
        if (false === $result) {
            throw new pm_Exception("Failed to save configuration {$this->_config}");
        }
        $acl = new Modules_SlaveDnsManager_Acl();
        $acl->add($slaveIp);
    }
 public function __construct(Zend_View $view, Zend_Controller_Request_Abstract $request)
 {
     parent::__construct($view, $request);
     $data = array();
     foreach (Modules_SlaveDnsManager_Slave::getList() as $slave) {
         try {
             $rndc = new Modules_SlaveDnsManager_Rndc();
             $details = $rndc->checkStatus($slave);
             $icon = 'ok';
         } catch (Exception $e) {
             $details = $e->getMessage();
             $icon = 'warning';
         }
         $ip = $view->escape((string) $slave->getIp());
         $config = $view->escape((string) $slave->getConfig());
         $data[] = array('select' => '<input type="checkbox" class="checkbox" name="listCheckbox[]" value="' . $config . '"/>', 'status' => '<img class="slave-status" src="/theme/icons/16/plesk/' . $icon . '.png" title="' . $view->escape($details) . '"/>', 'config' => '<a href="' . $view->getHelper('baseUrl')->moduleUrl(array('action' => 'view')) . '?config=' . $config . '">' . $ip . '</a>');
     }
     $this->setData($data);
     $this->setColumns(array('select' => array('title' => '<input type="checkbox" class="checkbox" name="listGlobalCheckbox"/>', 'sortable' => false, 'noEscape' => true), 'status' => array('title' => $this->lmsg('statusColumnTitle'), 'noEscape' => true), 'config' => array('title' => $this->lmsg('configColumnTitle'), 'noEscape' => true)));
     $this->setTools(array(array('title' => $this->lmsg('addToolTitle'), 'description' => $this->lmsg('addToolDescription'), 'class' => 'sb-add-new', 'link' => $view->getHelper('baseUrl')->moduleUrl(array('action' => 'add'))), array('title' => $this->lmsg('refreshToolTitle'), 'description' => $this->lmsg('refreshToolDescription'), 'class' => 'sb-refresh', 'link' => pm_Context::getBaseUrl()), array('title' => $this->lmsg('removeToolTitle'), 'description' => $this->lmsg('removeToolDescription'), 'class' => 'sb-remove-selected', 'link' => 'javascript:removeSlaves()')));
     $this->setDataUrl(array('action' => 'list-data'));
 }
<?php

// Copyright 1999-2015. Parallels IP Holdings GmbH.
pm_Loader::registerAutoload();
pm_Context::init('slave-dns-manager');
try {
    $result = pm_ApiCli::call('server_dns', array('--disable-custom-backend'));
} catch (pm_Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
exit(0);
Example #12
0
pm_Context::init('example');
if (false !== ($upgrade = array_search('upgrade', $argv))) {
    $upgradeVersion = $argv[$upgrade + 1];
    echo "upgrading from version {$upgradeVersion}\n";
    if (version_compare($upgradeVersion, '1.2') < 0) {
        pm_Bootstrap::init();
        $id = pm_Bootstrap::getDbAdapter()->fetchOne("select val from misc where param = 'moduleExampleCustomButton'");
        pm_Bootstrap::getDbAdapter()->delete('misc', array("param = 'moduleExampleCustomButton'"));
        pm_Settings::set('customButtonId', $id);
    }
    echo "done\n";
    exit(0);
}
$iconPath = rtrim(pm_Context::getHtdocsDir(), '/') . '/images/icon_16.gif';
$baseUrl = pm_Context::getBaseUrl();
$request = <<<APICALL
<ui>
   <create-custombutton>
         <owner>
            <admin/>
         </owner>
      <properties>
         <file>{$iconPath}</file>
         <internal>true</internal>
         <noframe>true</noframe>
         <place>navigation</place>
         <url>{$baseUrl}</url>
         <text>Example Module</text>
      </properties>
   </create-custombutton>
Example #13
0
 public function getIconUrl()
 {
     pm_Context::init('panel-news');
     return pm_Context::getBaseUrl() . '/images/feed.png';
 }
Example #14
0
<?php

pm_Context::init('example');
$id = pm_Settings::get('customButtonId');
$request = <<<APICALL
<ui>
    <delete-custombutton>
        <filter>
            <custombutton-id>{$id}</custombutton-id>
        </filter>
    </delete-custombutton>
</ui>
APICALL;
try {
    $response = pm_ApiRpc::getService()->call($request);
    $result = $response->ui->{"delete-custombutton"}->result;
    if (true || 'ok' == $result->status) {
        echo "done\n";
        exit(0);
    } else {
        echo "error {$result->errcode}: {$result->errtext}\n";
        exit(1);
    }
} catch (PleskAPIParseException $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
Example #15
0
<?php

pm_Context::init('panel-news');
Modules_PanelNews_News::load();
Example #16
0
<?php

pm_Context::init('panel-stats');
<?php

// Copyright 1999-2015. Parallels IP Holdings GmbH.
pm_Loader::registerAutoload();
pm_Context::init('slave-dns-manager');
try {
    if (pm_ProductInfo::isWindows()) {
        $cmd = '"' . PRODUCT_ROOT . '\\bin\\extension.exe"';
    } else {
        $cmd = '"' . PRODUCT_ROOT . '/bin/extension"';
    }
    $script = $cmd . ' --exec ' . pm_Context::getModuleId() . ' slave-dns.php';
    $result = pm_ApiCli::call('server_dns', array('--enable-custom-backend', $script));
} catch (pm_Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
exit(0);