{ global $sess, $HTTP_POST_VARS, $mytrail, $auth; if ($HTTP_POST_VARS['field_subject'] == "") { form(true); page_close(); exit; } if (!defined("TALK_INC")) { include "messages/talk.inc"; } talk($auth->auth['uname'], $mytrail['userid'], $HTTP_POST_VARS['field_subject'], $HTTP_POST_VARS['field_message'], $mytrail['id']); header("Location: " . $sess->url($mytrail['path'])); } if (!defined("LAY_TRAIL_INC")) { include "layout/lay_trail.inc"; } /* First I read the permissions of our user. */ page_open(array("sess" => "Linktrail_Session", "auth" => "Linktrail_Auth", "perm" => "Linktrail_Perm", "user" => "Linktrail_User")); $mytrail = get_node_info($PATH_INFO); if ($mytrail == -1) { $mytrail = get_node_info($PATH_INFO . "?"); } include "template.inc"; if ($REQUEST_METHOD == "POST") { doit(); } else { form(); } page_close();
if (!defined("DIRECTORY_INC")) { include "dbapi/directory.inc"; } if (!defined("LAY_LOGIN_INC")) { include "layout/lay_login.inc"; } if (!defined("LAY_TRAIL_INC")) { include "layout/lay_trail.inc"; } global $username, $ltrstr, $sess, $HTTP_POST_VARS, $HTTP_GET_VARS, $mytrail, $PHP_SELF, $PATH_INFO; $failed = isset($username); if (is_trail($PHP_SELF)) { $mytrail = get_node_info($PHP_SELF); } if (!is_array($mytrail)) { $mytrail = get_node_info($PATH_INFO); } if ($in_trail == 1) { //die(class_exists("Template")); if (!class_exists("Template")) { include "template.inc"; } $tpl = new Template(APPLICATION_HOME . "/templates/trail", "keep"); $tpl->set_file(array("simpleframe" => "simpleframe.html")); $tpl->set_var("CONTENT", print_loginform_trail($PHP_SELF, $this->auth["uname"], $ltrstr['Trail_Login'], $failed)); $tpl->parse("simpleframe", "simpleframe"); /* global $action, $kat; $action = $HTTP_GET_VARS['action']; $kat = $HTTP_GET_VARS['kat'];*/ //die($action); // $sess->register("kat"); $sess->register("action");
} if (!defined("LAY_DIRECTORY_INC")) { include "layout/lay_directory.inc"; } if (!defined("LAY_DIREDIT_INC")) { include "layout/lay_diredit.inc"; } if (!defined("LAY_SLOTS_INC")) { include "layout/lay_slots.inc"; } if (!defined("DISPLAY_DIRECTORY_INC")) { include "application/display_directory.inc"; } $capabilities = get_caps($perm, $kat); $kat = $PATH_INFO; $nodeinfo = get_node_info($kat); //push back evil guys... if (!has_caps($capabilities, CAP_EDIT_EXPERTS) or $REQUEST_METHOD != "POST" or $nodeinfo == -1) { go_back(); } if (isset($cancel)) { go_back(); } else { doit(); } function go_back() { global $sess, $PATH_INFO; page_close(); Header("Location: " . $sess->url($PATH_INFO)); exit;
function show_bhyvevm($nodelist = "local") { global $workdir; $pieces = explode(" ", $nodelist); ?> <table class="images"> <thead> <tr> <th>node</th> <th>vm</th> <th>vm_ram</th> <th>vm_cpus</th> <th>vm_os_type</th> <th>status</th> <th>action</th> <th>remove</th> </tr> </thead> <tbody> <?php foreach ($pieces as $nodename) { if (!$nodename) { $nodename = $nodelist; } $db = new SQLite3("{$workdir}/var/db/{$nodename}.sqlite"); $db->busyTimeout(5000); $sql = "SELECT jname,vm_ram,vm_cpus,vm_os_type FROM bhyve;"; $result = $db->query($sql); //->fetchArray(SQLITE3_ASSOC); $row = array(); $i = 0; if ($nodename != "local") { $nodeip = get_node_info($nodename, "ip"); $idle = check_locktime($nodeip); } else { $idle = 1; } if ($idle == 0) { $hdr = '<tr style="background-color:#D6D2D0">'; } else { $hdr = '<tr>'; } while ($res = $result->fetchArray(SQLITE3_ASSOC)) { if (!isset($res['jname'])) { continue; } $jname = $res['jname']; $vm_ram = $res['vm_ram'] / 1024 / 1024; $vm_cpus = $res['vm_cpus']; $vm_os_type = $res['vm_os_type']; $status = check_vmonline($jname); $i++; if ($idle != 0) { switch ($status) { case 0: //off $statuscolor = "#EDECEA"; $action = "<form action=\"bstart.php\" method=\"post\"><input type=\"hidden\" name=\"jname\" value=\"{$jname}\"/> <input type=\"submit\" name=\"start\" value=\"Start\"></form>"; break; case 1: //running $statuscolor = "#51FF5F"; $action = "<form action=\"bstop.php\" method=\"post\"><input type=\"hidden\" name=\"jname\" value=\"{$jname}\"/> <input type=\"submit\" name=\"stop\" value=\"Stop\"></form>"; break; default: $action = "maintenance"; break; } } else { $statuscolor = "#D6D2D0"; $action = "offline"; } if ($idle != 0) { $status_td = "<td><a href=\"bstatus.php?jname={$jname}\">{$jname}</a></td>"; $remove_td = "<td><a href=\"bremove.php?jname={$jname}\">Remove</a></td>"; } else { $status_td = "<td>{$jname}</td>"; $remove_td = "<td>Remove</td>"; } $str = <<<EOF \t\t\t{$hdr} \t\t\t<td><strong>{$nodename}</strong></td> \t\t\t{$status_td} \t\t\t<td>{$vm_ram}</td><td>{$vm_cpus}</td> \t\t\t<td>{$vm_os_type}</td> \t\t\t<td style="background-color:{$statuscolor}">{$status}</td> \t\t\t<td>{$action}</td> \t\t\t{$remove_td} \t\t\t</tr> EOF; echo $str; } } echo "</tbody></table>"; }
} if (!defined("ACTIONS_INC")) { include "layout/actions.inc"; } if (!defined("TRAILFUNCS_INC")) { include "commonapi/trailfuncs.inc"; } if (!defined("COMMON_PERMISSIONS_INC")) { include "commonapi/common_permissions.inc"; } $trail = $PATH_INFO; //$sqltrail = addslashes($trail); //echo($trail); $nodeinfo = get_node_info($trail); if ($nodeinfo == -1) { $nodeinfo = get_node_info($trail . '?'); $trail = $trail . '?'; } $links = get_links($trail); $mytrail = $nodeinfo; $hilight_words = explode("|", base64_decode($hilight)); /* First I read the permissions of our user. */ $caps = get_caps($perm); //used to read the superuser-capability of users with perm->have-perm("admin"); $trailperms = relevant_perms($nodeinfo, $auth->auth["uid"], $caps); //die("Perms: $trailperms"); //$sess->register("mytrail"); $auth->login_if($dologin == "1" and empty($password)); print_trail_direct($links, $nodeinfo, $trailperms);
function create($kat, $title, $description, $pass_language_check = false) { global $sess, $auth, $glob_language_name, $glob_language; if (!defined("SPELLING_INC")) { include "commonapi/spelling.inc"; } if (!strstr($kat, '/')) { $kat = base64_decode($kat); } $predef['kat'] = $kat; $predef['title'] = $title; $predef['description'] = $description; $title = str_replace(' ', '_', $title); $exists = get_node_info($kat . $title); $exists = $exists != -1; if (strstr($title, '/')) { $errfile = "err_invalidslash.html"; addform($predef, $errfile); exit; } elseif ($title == "") { $errfile = "err_notitle.html"; addform($predef, $errfile); exit; } elseif ($description == "") { $errfile = "err_nodesc.html"; addform($predef, $errfile); exit; } elseif ($exists) { $errfile = "err_object_exists.html"; addform($predef, $errfile); exit; } elseif (!check_language($description, $glob_language_name) and !$pass_language_check) { lang_query($kat, $title, $description); } else { $title = str_replace(' ', '_', $title); $obj['name'] = $kat . $title; $obj['parent'] = path2id($kat); $obj['level'] = level_count($kat); $obj['objecttype'] = "trail"; $obj['description'] = $description; $obj['useraccess'] = 4; $obj['friendaccess'] = 12; $obj['owner'] = $auth->auth["uid"]; $obj['language'] = $glob_language; add_object($obj, true); Header("Location: " . $sess->url(build_good_url($obj['name']) . "?reloadparent=1")); exit; // echo("Debug: dieses Fenster schliessen"); } }
function show_jails($nodelist = "local") { global $workdir; $pieces = explode(" ", $nodelist); ?> <table class="images"> <thead> <tr> <th>node</th> <th>jname</th> <th>ip4_addr</th> <th>status</th> <th>action</th> <th>remove</th> <th>console</th> </tr> </thead> <tbody> <?php foreach ($pieces as $nodename) { if (!$nodename) { $nodename = $nodelist; } $db = new SQLite3("{$workdir}/var/db/{$nodename}.sqlite"); $db->busyTimeout(5000); if (!$db) { return; } $sql = "SELECT jname,ip4_addr,status FROM jails WHERE emulator != \"bhyve\";"; $result = $db->query($sql); //->fetchArray(SQLITE3_ASSOC); $row = array(); $i = 0; if ($nodename != "local") { $nodeip = get_node_info($nodename, "ip"); $idle = check_locktime($nodeip); } else { $idle = 1; } if ($idle == 0) { $hdr = '<tr style="background-color:#D6D2D0">'; } else { $hdr = '<tr>'; } while ($res = $result->fetchArray(SQLITE3_ASSOC)) { if (!isset($res['jname'])) { continue; } $jname = $res['jname']; $ip4_addr = $res['ip4_addr']; $status = $res['status']; $i++; if ($idle != 0) { switch ($status) { case 0: //off $statuscolor = "#EDECEA"; $action = "<form action=\"jstart.php\" method=\"post\"><input type=\"hidden\" name=\"jname\" value=\"{$jname}\"/> <input type=\"submit\" name=\"start\" value=\"Start\"></form>"; break; case 1: //running $statuscolor = "#51FF5F"; $action = "<form action=\"jstop.php\" method=\"post\"><input type=\"hidden\" name=\"jname\" value=\"{$jname}\"/> <input type=\"submit\" name=\"stop\" value=\"Stop\"></form>"; break; default: $statuscolor = "#D6D2D0"; $action = "maintenance"; break; } } else { $statuscolor = "#D6D2D0"; $action = "offline"; } if ($idle != 0) { $status_td = "<td><a href=\"jstatus.php?jname={$jname}\">{$jname}</a></td>"; $remove_td = "<td><a href=\"jremove.php?jname={$jname}\">Remove</a></td>"; } else { $status_td = "<td>{$jname}</td>"; $remove_td = "<td>Remove</td>"; } $str = <<<EOF \t\t\t\t{$hdr} \t\t\t\t<td><strong>{$nodename}</strong></td> \t\t\t\t{$status_td} \t\t\t\t<td>{$ip4_addr}</td> \t\t\t\t<td style="background-color:{$statuscolor}">{$status}</td> \t\t\t\t<td>{$action}</td> \t\t\t\t{$remove_td} EOF; if ($status == 1) { $tmp = str_replace("/", ",", $ip4_addr); $ipw = explode(",", $tmp); $console = '<a href="http://'; $console .= $ipw[0] . ":8000"; $console .= '">Console</a>'; } else { $console = "Not running"; } $str .= <<<EOF \t\t\t\t<td>{$console}</td> \t\t\t\t</tr> EOF; echo $str; } } echo "</tbody></table>"; }
function edit_slot() { global $nodeinfo, $HTTP_POST_VARS, $field_image_file, $field_image_file_name, $sess; if (!defined("RED_NOTIFICATION_INC")) { } include "messages/red_notification.inc"; $slot = validate_and_set($HTTP_POST_VARS); $oldslot = get_slot_info($slot['id']); edit_slot_ex($slot['id'], $slot); if (isset($HTTP_POST_VARS['row']) and $HTTP_POST_VARS['row'] != "") { reposition_slot($slot, $HTTP_POST_VARS['row']); } copy_file($slot['id']); //Notify users only if god (admin) wants them to be notified (the default) if (isset($HTTP_POST_VARS['field_notify_users']) and $slot['islive'] == "y") { $trail1_new = get_node_info($slot['trail_1_id']); $trail2_new = $slot['trail_2_id'] ? get_node_info($slot['trail_2_id']) : -1; $trail1_old = get_node_info($oldslot['trail_1_id']); $trail2_old = $oldslot['trail_2_id'] ? get_node_info($oldslot['trail_2_id']) : -1; send_red_notification(LTMSG_SLOTTERM, $trail1_old['userid'], $trail1_old['id'], $slot['node']); if ($trail2 != -1) { send_red_notification(LTMSG_SLOTTERM, $trail2_old['userid'], $trail2_old['id'], $slot['node']); } send_red_notification(LTMSG_SLOTTERM, $trail1_new['userid'], $trail1_new['id'], $slot['node']); if ($trail2 != -1) { send_red_notification(LTMSG_SLOTTERM, $trail2_new['userid'], $trail2_new['id'], $slot['node']); } } Header("Location: " . $sess->url($nodeinfo['path'])); exit; }