コード例 #1
0
ファイル: vps__xenlib.php プロジェクト: digideskio/hypervm
 /**
  * Get the disk usage for a given disk on a windows based Xen virtual machine.
  *
  * Get the data from ntfscluster output processing the bytes per volume,
  * and bytes of user data.
  *
  * Calculate the total disk space and total disk space used.
  *
  * @author Anonymous <*****@*****.**>
  * @author Ángel Guzmán Maeso <*****@*****.**>
  *
  * @param string $disk The disk on a xen virtual machine. Default NULL.
  * @param string $root_path The location for root path needed for windows based Xen virtual machine.
  * @return array[string] The total and used integer space indexed as string
  */
 private static function getDiskUsageWindows($disk = NULL, $root_path = NULL)
 {
     $root_path = fix_vgname($root_path);
     $partition = get_partition($disk, $root_path);
     // @todo Check if the ntfscluster it's available to use and exists (never trusts on users)
     $output = lxshell_output('ntfscluster', '-f', $partition);
     // Disconnect the partition from the file on device mapper.
     // @todo Check if the kpartx it's available to use and exists (never trusts on users)
     $base = basename($disk);
     $image_file = '/dev/mapper/' . $root_path . '-' . $base;
     lxshell_return('kpartx', '-d', $image_file);
     if (!empty($output)) {
         // If no output returned we return 0 MBytes (fallback mode)
         $ouput_lines = explode(PHP_EOL, $output);
         // Process the ntfscluster output
         if (!empty($ouput_lines)) {
             foreach ($ouput_lines as $line) {
                 $line = trim($line);
                 // Only process lines with :
                 if (char_search_a($line, ':')) {
                     list($variable_header, $value) = explode(':', $line);
                     $variable_header = trim($variable_header);
                     $value = trim($val);
                     // Get the bytes per volume line
                     if ($variable_header === 'bytes per volume') {
                         $total_disk = $value;
                     }
                     // Get the bytes of user data line
                     if ($variable_header === 'bytes of user data') {
                         $total_disk_used = $value;
                     }
                 }
             }
         }
         // Round total and used to MBytes with 2 decimals
         $result['total'] = round($total_disk / (1024 * 1024), 1);
         $result['used'] = round($total_disk_used / (1024 * 1024), 1);
     } else {
         // Fallback mode
         $result['total'] = 0;
         $result['used'] = 0;
     }
     return $result;
 }
コード例 #2
0
ファイル: lxlib.php プロジェクト: zseand/kloxo
function csa($haystack, $needle, $insensitive = 0)
{
    return char_search_a($haystack, $needle, $insensitive);
}
コード例 #3
0
ファイル: htmllib.php プロジェクト: hypervm-ng/hypervm-ng
    function print_sortby($parent, $class, $unique_name, $sortby, $descr)
    {
        global $gbl, $sgbl, $login, $ghtml;
        $filtername = $parent->getFilterVariableForThis($class);
        $desc = $descr[2];
        $help = $descr['help'];
        $alt = lx_strip_tags($help);
        $url = $_SERVER['PHP_SELF'];
        if (!$desc) {
            $desc = ucfirst($sortby);
        }
        if (char_search_a($descr[0], "b") || char_search_a($descr[0], "S")) {
            // hack...
            if (!$alt) {
                $d = $alt;
            } else {
                $d = $desc;
            }
            print "<font class=tableheadtext onmouseover=\"changeContent('help','<b> Message </b>: <br> <br> {$help}')\" onmouseout=\"changeContent('help','helparea')\"> {$d} </font>";
            return;
        }
        $fil = $login->getHPFilter();
        $sortdir = null;
        $nsortby = null;
        if (isset($fil[$filtername]['sortby'])) {
            $nsortby = $fil[$filtername]['sortby'];
        }
        if (isset($fil[$filtername]['sortdir'])) {
            $sortdir = $fil[$filtername]['sortdir'];
        }
        if ($nsortby === $sortby) {
            $sortdir = $sortdir === "desc" ? "asc" : "desc";
        }
        $formname = 'lpform_' . $unique_name . $sortby;
        ?>
 

	<form name=<?php 
        echo $formname;
        ?>
 method=<?php 
        echo $sgbl->method;
        ?>
 action=<?php 
        echo $url;
        ?>
 >
		<?php 
        $this->print_current_input_vars(array('frm_hpfilter'));
        ?>
 
	<input name=frm_hpfilter[<?php 
        echo $filtername;
        ?>
][sortby] type=hidden value="<?php 
        echo $sortby;
        ?>
" >
	<input name=frm_hpfilter[<?php 
        echo $filtername;
        ?>
][sortdir] type=hidden value="<?php 
        echo $sortdir;
        ?>
" >

	</form> 
	<span title='<?php 
        echo $alt;
        ?>
'><a class=tableheadtext href="javascript:document.<?php 
        echo $formname;
        ?>
.submit()"><?php 
        echo $desc;
        ?>
 </a>  </span>
	<?php 
    }
コード例 #4
0
ファイル: lxclass.php プロジェクト: hypervm-ng/hypervm-ng
 static function getdbFilter($filter = null, $class)
 {
     static $oplist = array('gt' => '>', 'lt' => '<', 'eq' => '===', 'ne' => '!=', 'cont' => 'LIKE');
     $total = null;
     foreach ((array) $filter as $key => $val) {
         if ($key === 'sortby' || $key === 'searchstring' || $key === 'sortdir' || $key === 'pagenum' || $key === 'pagesize') {
             continue;
         }
         if (char_search_a($key, "_o_")) {
             $var = substr($key, 0, strpos($key, "_o_"));
             $op = substr($key, strpos($key, "_o_") + 3);
             //$op = $oplist[$op];
             $var = str_replace(array("\"", "'", ";"), "", $var);
             $val = str_replace(array("\"", "'", ";"), "", $val);
             if ($val) {
                 if ($val === '__any__') {
                     continue;
                 }
                 if (cse($var, "_q")) {
                     $var = strtil($var, "_q");
                     if ($val === 'overquota') {
                         $total[] = "(priv_q_{$var} != 'Unlimited' AND (used_q_{$var} + 0) > (priv_q_{$var} + 0))";
                     } else {
                         $total[] = "(priv_q_{$var} = 'Unlimited' OR (used_q_{$var} + 0) <= (priv_q_{$var} + 0))";
                     }
                     continue;
                 }
                 if ($op == 'cont') {
                     if ($val[0] === '^') {
                         $val = substr($val, 1);
                         $val = "{$val}%";
                     } else {
                         $val = "%{$val}%";
                     }
                 }
                 $total[] = "{$var} {$oplist[$op]} '{$val}'";
             }
         } else {
             $f = "__hpfilter_{$key}_{$val}";
             $res = get_real_class_variable($class, $f);
             if (is_array($res)) {
                 $total[] = implode(" ", $res);
             }
         }
     }
     if (isset($filter['searchstring']) && $filter['searchstring']) {
         $var = exec_class_method($class, 'searchVar');
         $total[] = "{$var} LIKE '%{$filter['searchstring']}%'";
     }
     $andstr = null;
     if ($total) {
         $andstr = implode(" AND  ", $total);
     }
     return $andstr;
 }
コード例 #5
0
ファイル: ipaddress__redhatlib.php プロジェクト: zseand/kloxo
 static function getCurrentIps()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $path = $sgbl->__path_real_etc_root . "sysconfig/network-scripts/";
     $flist = lscandir($path);
     foreach ($flist as $file) {
         if (char_search_a($file, "ifcfg-")) {
             $result1[] = self::getcontentsof($path . $file);
         }
     }
     $result = "";
     foreach ($result1 as $res) {
         $temp = explode(":", $res['devname']);
         if (count($temp) === 2) {
             $res['devname'] = implode("-", $temp);
         }
         $result[] = $res;
     }
     //dprintr($result);
     return $result;
 }
コード例 #6
0
ファイル: domainlib.php プロジェクト: zseand/kloxo
 static function verify($var, $val)
 {
     switch ($var) {
         case "nname":
             if (is_numeric($val) || char_search_a($val, " ")) {
                 throw new lxexception("");
             }
         case "username":
             if (is_numeric($val) || char_search_a($val, " ")) {
                 throw new lxexception("");
             }
     }
     return $val;
 }
コード例 #7
0
ファイル: lxclass.php プロジェクト: zseand/kloxo
 function isDisplay($filter = null)
 {
     global $gbl, $sgbl, $login;
     return true;
     if (!$filter) {
         return 1;
     }
     $class = lget_class($this);
     $res = 1;
     foreach ($filter as $key => $val) {
         if (char_search_a($key, "_o_")) {
             $var = substr($key, 0, strpos($key, "_o_"));
             $op = substr($key, strpos($key, "_o_") + 3);
             //$op = $oplist[$op];
             if (!isset($this->{$var})) {
                 $oval = $a->display($var);
             } else {
                 $oval = $this->{$var};
             }
             $res &= self::filterFunc($op, $oval, $val);
         } else {
             $f = "__filter_{$key}_{$val}";
             $string = get_real_class_variable($class, $f);
             $res &= eval("return {$string};");
         }
     }
     return $res;
 }
コード例 #8
0
function resolve_single_child($object, $class, $nname)
{
    if (char_search_a($class, "_s_") || char_search_a($class, "-")) {
        if (csa($class, "_s_")) {
            $olist = explode("_s_", $class);
        } else {
            if (csa($class, "-")) {
                $olist = explode('-', $class);
            }
        }
        $object = $object->getFromList($olist[0], $nname);
        $olist[0] = null;
        unset($olist[0]);
        foreach ($olist as $o) {
            $object = $object->getObject($o);
        }
    } else {
        $object = $object->getFromList($class, $nname);
    }
    return $object;
}