/** * gets xfer percentage bar * * @param $total * @param $used * @param $title * @return string */ function tmplGetXferBar($total, $used, $title, $type = 'xfer') { global $cfg; // create template-instance $tmpl = tmplGetInstance($cfg["theme"], "component.xferBar.tmpl"); $remaining = $total - $used / 1048576; $remaining = max(0, min($total, $remaining)); $percent = round($remaining / $total * 100, 0); $text = ' (' . formatFreeSpace($remaining) . ') ' . $cfg['_REMAINING']; if ($type == 'xfer') { $bgcolor = '#'; $bgcolor .= str_pad(dechex(255 - 255 * ($percent / 150)), 2, 0, STR_PAD_LEFT); $bgcolor .= str_pad(dechex(255 * ($percent / 150)), 2, 0, STR_PAD_LEFT); $bgcolor .= '00'; $tmpl->setvar('bgcolor', $bgcolor); } $tmpl->setvar('title', $title); $tmpl->setvar('percent', $percent); $tmpl->setvar('text', $text); $tmpl->setvar('type', $type); $percent_100 = 100 - $percent; $tmpl->setvar('percent_100', $percent_100); // grab the template $output = $tmpl->grab(); return $output; }
switch ($type) { // server case "server": // target if ($target == "") { $target = _DEFAULT_TARGET_SERVER; } // targets $target_list = array(); array_push($target_list, array('name' => "all", 'selected' => $target == "all" ? 1 : 0)); array_push($target_list, array('name' => "bandwidth", 'selected' => $target == "bandwidth" ? 1 : 0)); array_push($target_list, array('name' => "drivespace", 'selected' => $target == "drivespace" ? 1 : 0)); $tmpl->setloop('target_list', $target_list); // target-content // create template-instance $_tmpl = tmplGetInstance($cfg["theme"], "component.images.server.tmpl"); // set vars $image_list = array(); if ($target == "bandwidth" || $target == "all") { array_push($image_list, array('title' => "Bandwidth", 'src' => "image.php?i=pieServerBandwidth")); } if ($target == "drivespace" || $target == "all") { array_push($image_list, array('title' => "Drivespace", 'src' => "image.php?i=pieServerDrivespace")); } if (!empty($image_list)) { $_tmpl->setloop('image_list', $image_list); } $_tmpl->setvar('type', $type); $_tmpl->setvar('target', $target); // grab + set the content of template $tmpl->setvar('content', $_tmpl->grab());
/** * global error-function * * @param $msg * @param $link * @param $linklabel * @param $msgs */ function error($msg, $link = "", $linklabel = "", $msgs = array()) { global $cfg, $argv; // web/cli/tfbf if (empty($argv[0]) && !("tfbf" == @substr($cfg['user_agent'], 0, 4))) { // web // theme $theme = CheckandSetUserTheme(); // template require_once "themes/" . $theme . "/index.php"; require_once "inc/lib/vlib/vlibTemplate.php"; $_tmpl = tmplGetInstance($theme, "page.error.tmpl"); // message $_tmpl->setvar('message', htmlentities($msg, ENT_QUOTES)); // messages if (!empty($msgs)) { $msgAry = array_map("htmlentities", $msgs); $_tmpl->setvar('messages', implode("\n", $msgAry)); } // link + linklabel if (!empty($link)) { $_tmpl->setvar('link', $link); $_tmpl->setvar('linklabel', !empty($linklabel) ? htmlentities($linklabel, ENT_QUOTES) : "Ok"); } // parse template $_tmpl->pparse(); // get out here exit; } else { // cli/tfbf // message $exitMsg = "Error: " . $msg . "\n"; // messages if (!empty($msgs)) { $exitMsg .= implode("\n", $msgs) . "\n"; } // get out here exit($exitMsg); } }
/** * get superadmin-popup-link-html-snip. * * @param $param * @param $linkText * @return string */ function getSuperAdminLink($param = "", $linkText = "") { global $cfg; // create template-instance $_tmpl = tmplGetInstance($cfg["theme"], "component.superAdminLink.tmpl"); $_tmpl->setvar('param', $param); if (isset($linkText) && $linkText != "") { $_tmpl->setvar('linkText', $linkText); } // grab the template $output = $_tmpl->grab(); return $output; }