예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $z = $input->getArgument('params');
     $attributes = parseAttributes($z);
     $params = ['User-Name', 'Acct-Session-Id', 'Acct-Unique-Session-Id', 'Acct-Input-Octets', 'Acct-Output-Octets', 'Acct-Input-Gigawords', 'Acct-Output-Gigawords', 'Acct-Session-Time', 'Acct-Status-Type'];
     foreach ($params as $param) {
         if (!array_key_exists($param, $attributes)) {
             $output->writeln("Insufficient/Invalid parameters provided.");
             exit;
         }
     }
     if ($attributes['Acct-Status-Type'] == 'Start') {
         exit(0);
     }
     $username = $params['User-Name'];
     $acctsessionid = $params['Acct-Session-Id'];
     $acctuniqueid = $params['Acct-Unique-Session-Id'];
     $sessiontime = $params['Acct-Session-Time'];
     $inputoctets = $params['Acct-Input-Octets'];
     $outputoctets = $params['Acct-Output-Octets'];
     $inputgigs = $params['Acct-Input-Gigawords'];
     $outputgigs = $params['Acct-Output-Gigawords'];
     $account = new Account((new User($username))->fetchAccount($acctsessionid, $acctuniqueid));
     $account->takeTime($sessiontime);
     $account->takeData($inputoctets, $inputgigs, $outputoctets, $outputgigs);
     $account->setupAccounting();
     $account->countTime();
     $account->countData();
     $account->updateDatabase();
 }
예제 #2
0
function getObjectAttributes($resourceName, &$extends, $enableExtend = true)
{
    global $resources, $objects;
    $matches = null;
    if (!preg_match('/\\n    ' . $resourceName . ' = (\\{|(\\w+)\\.merge \\\\)(.+)\\n    [^ ]/sU', $resources, $matches) && !preg_match('/\\n    ' . $resourceName . ' = ((\\w+))((\\.merge\\([^\\(]+\\))+)/', $resources, $matches)) {
        echo "Cant find resource for object [{$resourceName}]\n";
        return array();
    }
    $attributes = array();
    if ($matches[2]) {
        if ($enableExtend) {
            $objects[strtolower($matches[2])] = true;
            $extends = gitHubClassName($matches[2]);
        } else {
            $attributes = getObjectAttributes($matches[2], $extends, $enableExtend);
        }
    }
    $mergeMatches = null;
    if (preg_match_all('/\\.merge\\((\'[^\']+\' => )?([^\\)]+)\\)/', $matches[3], $mergeMatches)) {
        foreach ($mergeMatches[2] as $mergeResource) {
            $mergeAttributesMatches = null;
            if (preg_match('/^\\{(\\n( +).+)\\}$/s', $mergeResource, $mergeAttributesMatches)) {
                $mergeAttributes = parseAttributes($resourceName, $mergeAttributesMatches[1], $mergeAttributesMatches[2]);
                $attributes = array_merge($attributes, $mergeAttributes);
            } else {
                echo "Merging {$mergeResource} into {$resourceName}\n";
                $attributes = array_merge($attributes, getObjectAttributes($mergeResource, $extends, false));
            }
        }
    } else {
        $attributes = array_merge($attributes, parseAttributes($resourceName, $matches[3]));
    }
    return $attributes;
}