Mini Shell

Direktori : /usr/share/l.v.e-manager/ispmanager/liblve0.8/addon/
Upload File :
Current File : //usr/share/l.v.e-manager/ispmanager/liblve0.8/addon/lvemanager.php

#!/usr/bin/php -n
<?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
 */

set_time_limit(0);
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
ini_set('display_errors', 0);

// Include Library for system comands
include_once('lvemanager/system.class.php');

// Include display class
include_once('lvemanager/output.class.php');


// Tmp Logger
//$file = fopen('/usr/local/ispmgr/addon/test.log',"a+");

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $RequestString = fread(STDIN, $_SERVER['CONTENT_LENGTH']);
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
        $RequestString = $_SERVER['QUERY_STRING'];
}
// End Logger

// Create Instances of work Libraries
$commands = new SystemComands();    // Execute command Lib
$output_XML = new ISPOutput();      // Output library (only for ISPManager)

//$RequestString = 'lickstat=yes&func=lvemanager.statistic';

$RequestString = str_replace('%2E','.',$RequestString);
$RequestString = str_replace('%2D','-',$RequestString);
$RequestString = str_replace('%5F','_',$RequestString);

// Please forgive me God
if ('' == $_ENV['REMOTE_USER'])
    $_ENV['REMOTE_USER'] = $_SERVER['REMOTE_USER'];
    
    
// Hello from India
    // Output for index page
    if (strstr($RequestString, 'main')) {
        $data = $commands->GetLiveData();
        $XML = $output_XML->HomeResult($data);
        echo $XML;
    } 
    
    if (strstr($RequestString, 'autoupdate')) {
        $data = $commands->GetLiveData();
        $XML = $output_XML->HomeResultAuto($data);
        echo $XML;
    } 
    
    if (strstr($RequestString, 'accounts')) {
        $data = $commands->GetAccounts();
        $XML = $output_XML->AccountResult($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'default')) {
        if (strstr($RequestString, 'sok=ok')) {
            if ($commands->SetDefaultLVE($RequestString,'&func')) {
                $XML = $output_XML->FormOK();
                echo $XML;
            } else {
                // Some Error here
            }
        } else {
            $data = $commands->GetDefaultLVE();
            $XML = $output_XML->DefaultShow($data);
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'edit')) {
        if (strstr($RequestString, 'sok=ok')) {
            if ($commands->SetUserLVE($RequestString,'&func')) {
                $XML = $output_XML->FormOK(1);
                echo $XML;
            } else {
                // Some Error here
            }
        } else {
            $data = $commands->GetUserLVE($RequestString);
            $XML = $output_XML->UserShow($data);
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'confirmation')) {
        if (strstr($RequestString, 'sok=ok')) {
                $XML = $output_XML->FormOK();
                echo $XML;
        } else {
            $XML = $output_XML->FormOK(2);
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'userinfo')) {
        $data = $commands->GetUserLveInfo($_ENV['REMOTE_USER'],date("Y-m-d H:i", mktime(0, 0, date('s'), date('m'), date('d'), date('Y'))));
        $XML = $output_XML->GetChart($data, 1);
        echo $XML;
    }
    
    if (strstr($RequestString, 'chart.setupcpu')) {
        if (strstr($RequestString, 'sok=ok')) {
            $XML = $output_XML->ChartRedirect('cpu',$RequestString);
            echo $XML;
        } else {
            $XML = $output_XML->ChartSetup();
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'chart.setupmem')) {
        if (strstr($RequestString, 'sok=ok')) {
            $XML = $output_XML->ChartRedirect('mem',$RequestString);
            echo $XML;
        } else {
            $XML = $output_XML->ChartSetup();
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'chart.setupmep')) {
        if (strstr($RequestString, 'sok=ok')) {
            $XML = $output_XML->ChartRedirect('mep',$RequestString);
            echo $XML;
        } else {
            $XML = $output_XML->ChartSetup();
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'chart.setupfaults')) {
        if (strstr($RequestString, 'sok=ok')) {
            $XML = $output_XML->ChartRedirect('faults',$RequestString);
            echo $XML;
        } else {
            $XML = $output_XML->ChartSetup();
            echo $XML;
        }
    }
    
    if (strstr($RequestString, 'detail')) {
        include_once('lvemanager/detail_root');
        $data = $commands->GetUserDetailInfo($RequestString);
        $XML = $output_XML->GetDetailInfo($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'user.cpu')) {
        include_once('lvemanager/detail_root');
        $data = $commands->GetDetailLveInfo($_SESSION['user'],$_SESSION['period']);
        $XML = $output_XML->GetChart($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'user.mem')) {
        include_once('lvemanager/detail_root');
        $data = $commands->GetDetailLveInfo($_SESSION['user'],$_SESSION['period']);
        $XML = $output_XML->GetDetailInfo($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'user.mep')) {
        include_once('lvemanager/detail_root');
        $data = $commands->GetDetailLveInfo($_SESSION['user'],$_SESSION['period']);
        $XML = $output_XML->GetDetailInfo($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'user.faults')) {
        include_once('lvemanager/detail_root');
        $data = $commands->GetDetailLveInfo($_SESSION['user'],$_SESSION['period']);
        $XML = $output_XML->GetDetailInfo($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'chart.showmem')) {
        $data = $commands->GetUserLveInfo($_ENV['REMOTE_USER'],$RequestString);
        $XML = $output_XML->GetChart($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'chart.showcpu')) {
        $data = $commands->GetUserLveInfo($_ENV['REMOTE_USER'],$RequestString);
        $XML = $output_XML->GetChart($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'chart.showmep')) {
        $data = $commands->GetUserLveInfo($_ENV['REMOTE_USER'],$RequestString);
        $XML = $output_XML->GetChart($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'chart.showfaults')) {
        $data = $commands->GetUserLveInfo($_ENV['REMOTE_USER'],$RequestString);
        $XML = $output_XML->GetChart($data);
        echo $XML;
    }
    
    if (strstr($RequestString, 'statistic')) {
        $file2 = fopen(getcwd().'/addon/lvemanager/detail_root',"w");
        fclose($file2);
        if (strstr($RequestString, 'setup')) {
            if (strstr($RequestString, 'sok=ok')) {
                $redirect = $commands->GetStat($RequestString);
                $XML = $output_XML->StatFilterApply($redirect);
                echo $XML;
            } else {
                $XML = $output_XML->StatSetupShow();
                echo $XML;
            }
        } else {
            if (strstr($RequestString, 'display=yes')) {
                $data = $commands->GetStatData($RequestString);
                $XML = $output_XML->StatShow($data,$RequestString);
                echo $XML;
            } else {
                $data = $commands->GetStatData('period=today&order-by=cpu_max&limit=10&display=yes');
                $XML = $output_XML->StatShow($data,'period=today&order-by=cpu_max&limit=10&display=yes');
                echo $XML;
            }
        }
    }

// End India

// Some code for debug

//exit();
//echo $XML;
//$result = '';
//foreach ($_SERVER as $key => $value)
//    $result .= $key.' => '.$value.PHP_EOL;
//fwrite($file,PHP_EOL.$result);
//fwrite($file,PHP_EOL.PHP_EOL);

//$result = '';
//foreach ($_ENV as $key => $value)
//    $result .= $key.' => '.$value.PHP_EOL;
//fwrite($file,PHP_EOL.$result);
//fwrite($file,PHP_EOL.PHP_EOL);    
//    
//fwrite($file,date("Y-m-d H:i:s").' '.$RequestString.PHP_EOL);
//fwrite($file,PHP_EOL.$XML);
//fwrite($file,PHP_EOL.$redirect);
//fwrite($file,PHP_EOL.getcwd());
//fwrite($file,PHP_EOL.PHP_EOL);
//fwrite($file,PHP_EOL.'$_SESSION - period -> '.$_SESSION['period'].' user -> '.$_SESSION['user']);
//fwrite($file,PHP_EOL.$result);
//fwrite($file,PHP_EOL.getcwd());
//$RequestString = 'func=lvemanager.accounts&clickstat=yes';
//fwrite($file,PHP_EOL.$RequestString);
//fwrite($file,'test'.PHP_EOL);
//fclose($file);
exit;

Zerion Mini Shell 1.0