/dev/null | /usr/bin/tr -s ' ' '\n'",$relinfo); exec("/bin/echo; /bin/ls {$rootfolder}/releases | grep RELEASE 2>/dev/null | /usr/bin/tr -s ' ' '\n'",$relinfo); array_shift($relinfo); $rellist = []; foreach($relinfo as $rel): $arel = preg_split("/\s+/",ltrim($rel)); $relname = chop($arel[0]); if(substr($relname,-1) === '*'): $relname = substr($relname,0,strlen($relname) - 1); endif; $rellist[$relname] = []; endforeach; return $rellist; } // Get all interface list. function get_all_interface_list() { global $g; exec("/bin/echo; /sbin/ifconfig -l | /usr/bin/tr -s ' ' '\n'; /bin/echo 'Config'",$linkinfo); array_shift($linkinfo); $iflist = []; foreach($linkinfo as $link): $alink = preg_split("/\s+/",ltrim($link)); $ifname = chop($alink[0]); if(substr($ifname,-1) === '*'): $ifname = substr($ifname,0,strlen($ifname) - 1); endif; $iflist[$ifname] = []; endforeach; return $iflist; } // list base releases $a_release = get_all_release_list(); $l_release = []; foreach($a_release as $k_release => $release): $l_release[$k_release] = $k_release; endforeach; // list of configured interfaces $a_interface = get_all_interface_list(); $l_interfaces = []; foreach($a_interface as $k_interface => $ifinfo): $l_interfaces[$k_interface] = $k_interface; endforeach; // Get jail infos. function get_jail_infos() { global $img_path; global $image_dir; global $configfile; global $jail_dir; $result = []; if(is_dir($jail_dir)): $cmd = '/usr/local/bin/bastille list jail 2>&1'; else: $cmd = ":"; endif; mwexec2($cmd,$rawdata); foreach($rawdata as $line): $a = preg_split('/\t/',$line); $r = []; $name = $a[0]; if(preg_match('/(.*)/', $name, $m)): $r['name'] = $m[1]; else: $r['name'] = '-'; endif; $r['jailname'] = $r['name']; $item = $r['jailname']; # Get some jail infos from 'bastille list' then dump data to temporary file. # JID Name Boot Prio State Type IP_Address Published_Ports Release Tags $jail_info = "bastille list | grep -w $item | while read _jid _name _boot _prio _state _type _ip _ports _release _tag; do \ echo \$_jid \$_name \$_boot \$_prio \$_state \$_type \$_ip \$_ports \$_release \$_tag > /tmp/jail.$item.state; done"; exec("$jail_info"); $jid = exec("cat /tmp/jail.$item.state | awk '{print $1}'"); $boot = exec("cat /tmp/jail.$item.state | awk '{print $3}'"); $prio = exec("cat /tmp/jail.$item.state | awk '{print $4}'"); $state = exec("cat /tmp/jail.$item.state | awk '{print $5}'"); $type = exec("cat /tmp/jail.$item.state | awk '{print $6}'"); $ipvx = exec("cat /tmp/jail.$item.state | awk '{print $7}'"); $ports = exec("cat /tmp/jail.$item.state | awk '{print $8}'"); $release = exec("cat /tmp/jail.$item.state | awk '{print $9}'"); $tags = exec("cat /tmp/jail.$item.state | awk '{print $10}'"); // Set the jail JID. $r['id'] = $jid; if (!$r['id']): $r['id'] = "-"; endif; // Set the jail Boot. $r['boot'] = $boot; if (!$r['boot']): $r['boot'] = "-"; endif; // Set the jail Prio. $r['prio'] = $prio; if (!$r['prio']): $r['prio'] = "-"; endif; // Set the jail State. $r['state'] = $state; if (!$r['state']): $r['state'] = "-"; endif; // Set the jail Type. $r['type'] = $type; if (!$r['type']): $r['type'] = "-"; endif; // Set the jail IP Address. $r['ip'] = $ipvx; if (!$r['ip']): $r['ip'] = "-"; endif; // Set the jail Published Ports. $r['ports'] = $ports; if (!$r['ports']): $r['ports'] = "-"; endif; // Set the jail Release. $r['rel'] = $release; if (!$r['rel']): $r['rel'] = "-"; endif; // Set the jail Tags. $r['tags'] = $tags; if (!$r['tags']): $r['tags'] = "-"; endif; // Display running status icons. if ($state == "Up"): $r['stat'] = $img_path['ena']; else: $r['stat'] = $img_path['dis']; endif; # Cleanup temporary file. $info_tmpfile = "/tmp/jail.$item.state"; if(is_file("$info_tmpfile")): unlink("$info_tmpfile"); endif; // Display custom template icons if available. $template_icon = "{$jail_dir}/{$item}/plugin_icon.png"; if(file_exists($template_icon)): if(!file_exists("{$image_dir}/{$item}_icon.png")): copy("$template_icon", "{$image_dir}/{$item}_icon.png"); endif; $r['logo'] = "{$image_dir}/{$item}_icon.png"; else: $template_icon = exec("/usr/bin/grep linsysfs {$jail_dir}/{$item}/fstab"); if($template_icon): // Display standard Linux icon. $r['logo'] = "{$image_dir}/linux_icon.png"; else: // Display standard FreeBSD icon. $r['logo'] = "{$image_dir}/bsd_icon.png"; endif; endif; $result[] = $r; endforeach; return $result; } ?>