%PDF- %PDF-
| Direktori : /usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Nodeworx/ |
| Current File : //usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Nodeworx/LveEdit.php |
<?php
/**
* Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
*
* Licensed under CLOUD LINUX LICENSE AGREEMENT
* http://cloudlinux.com/docs/LICENSE.TXT
*/
include('nav.php');
class Ctrl_Nodeworx_LveEdit extends Ctrl_Nodeworx_Plugin
{
protected function _init()
{
if( IW::NW()->isReseller() )
{
throw new IWorx_Exception_ActionBlocked( '##LG_ACTION_BLOCKED##' );
}
}
public function check_speed($speed)
{
if (preg_match('/\d+(?:\.\d+)?%$/',$speed) || (preg_match('/\d+(?:\.\d+)?(mhz|ghz)+$/i',$speed))){
return True;
}
}
public function indexAction()
{
include_once('LVE.class.php');
$error_msg = false;
$changed = false;
if (isset($_POST['submit'])) {
if ($_POST['uid'] == 'DEFAULT') {
$_POST['uid'] = 0;
}
$params = '';
if (isset($_POST['speed'])) {
if ((strlen($_POST['speed']) != 0) && ($this->check_speed($_POST['speed']))){
$params .= ' --speed='.$_POST['speed'];
} else {
$error_msg = 'Bad CPU limit given - '.$_POST['speed'];
}
}
if (isset($_POST['ncpu'])) {
if ((strlen($_POST['ncpu']) != 0) && ((int)$_POST['ncpu'] != 0) && ($_POST['ncpu'] > 0)) {
$params .= ' --ncpu='.(int)$_POST['ncpu'];
} else {
$error_msg = 'Bad nCPU limit given';
}
}
if (isset($_POST['vmem'])) {
if ((strlen($_POST['vmem']) != 0) && ($_POST['vmem'] >= 0)) {
$params .= ' --vmem='.$_POST['vmem'];
} else {
$error_msg = 'Bad vMEM limit given';
}
}
if (isset($_POST['pmem'])) {
if ((strlen($_POST['pmem']) != 0) && ($_POST['pmem'] >= 0)) {
$params .= ' --pmem='.$_POST['pmem'];
} else {
$error_msg = 'Bad pMEM limit given';
}
}
if (isset($_POST['ep'])) {
if ((strlen($_POST['ep']) != 0) && ((int)$_POST['ep'] != 0) && ($_POST['ep'] > 0)) {
$params .= ' --maxEntryProcs='.(int)$_POST['ep'];
} else {
$error_msg = 'Bad EntryProcs limit given';
}
}
if (isset($_POST['nproc'])) {
if ((strlen($_POST['nproc']) != 0) && ($_POST['nproc'] >= 0)) {
$params .= ' --nproc='.(int)$_POST['nproc'];
} else {
$error_msg = 'Bad nPROC limit given';
}
}
if (isset($_POST['io'])) {
if ((strlen($_POST['io']) != 0) && ($_POST['io'] >= 0)) {
$params .= ' --io='.(int)$_POST['io'];
} else {
$error_msg = 'Bad I/O limit limit given';
}
}
if (!$error_msg) {
if (strlen($params) != 0) {
$LVE->SetupLVE($_POST['uid'],$params);
$changed = true;
}
}
}
$this->getView()->assign( 'title', 'CloudLinux Manager' );
$this->getView()->assign( 'template', 'admin/edit' );
$this->getView()->assign( 'nav', nav('settings') );
$this->getView()->assign( 'acc', $_REQUEST['acc'] );
$this->getView()->assign( 'uid', $_REQUEST['uid'] );
$this->getView()->assign( 'error_msg', $error_msg );
$this->getView()->assign( 'changed', $changed );
$this->getView()->assign( 'ProcLVEVersion', $LVE->ReturnProcLVEVerion() );
$this->getView()->assign( 'data', $LVE->GetEditData($_REQUEST['uid']) );
}
}
?>