function renderIPVSConvert($vs_id) { $old_vs_list = callHook('getVSIDsByGroup', $vs_id); $grouped = array(); $used_tags = array(); foreach ($old_vs_list as $old_vs_id) { $vsinfo = spotEntity('ipv4vs', $old_vs_id); foreach ($vsinfo['etags'] as $taginfo) { $used_tags[$taginfo['id']] = $taginfo; } $port_key = $vsinfo['proto'] . '-' . $vsinfo['vport']; $grouped[$port_key][] = $vsinfo; } startPortlet("Found " . count($old_vs_list) . " matching VS"); printOpFormIntro('convert'); if (count($used_tags)) { echo '<p>Assign these tags to VS group:</p>'; foreach ($used_tags as $taginfo) { echo '<p><label><input type=checkbox checked name="taglist[]" value="' . htmlspecialchars($taginfo['id'], ENT_QUOTES) . '""> ' . serializeTags(array($taginfo)) . '<label>'; } } echo '<p>Import settings of these VS:</p>'; echo '<table align=center><tr>'; foreach ($grouped as $port_key => $list) { echo '<th>' . $port_key . '</th>'; } echo '</tr><tr>'; foreach ($grouped as $port_key => $list) { echo '<td><table>'; foreach ($list as $vsinfo) { echo '<tr><td><input type=checkbox name="vs_list[]" checked value="' . htmlspecialchars($vsinfo['id'], ENT_QUOTES) . '"></td><td>'; renderSLBEntityCell($vsinfo); echo '</td></tr>'; } echo '</table></td>'; } echo '</tr></table>'; printImageHREF('next', "Import settings of the selected services", TRUE); echo '</form>'; finishPortlet(); }
function renderSLBTripletsEdit($cell) { list($realm1, $realm2) = array_values(array_diff(array('object', 'ipv4vs', 'ipv4rspool'), array($cell['realm']))); if (getConfigVar('ADDNEW_AT_TOP') == 'yes') { callHook('renderNewSLBItemForm', $realm1, $realm2); } $triplets = SLBTriplet::getTriplets($cell); if (count($triplets)) { $cells = array(); foreach ($triplets[0]->display_cells as $field) { $cells[] = $triplets[0]->{$field}; } startPortlet('Manage existing (' . count($triplets) . ')'); echo "<table cellspacing=0 cellpadding=5 align=center class=cooltable>\n"; global $nextorder; $order = 'odd'; foreach ($triplets as $slb) { $cells = array(); foreach ($slb->display_cells as $field) { $cells[] = $slb->{$field}; } $ids = array('object_id' => $slb->lb['id'], 'vs_id' => $slb->vs['id'], 'pool_id' => $slb->rs['id']); $del_params = $ids; $del_params['op'] = 'delLB'; printOpFormIntro('updLB', $ids); echo "<tr valign=top class=row_{$order}><td rowspan=2 class=tdright valign=middle>"; echo getOpLink($del_params, '', 'DELETE', 'Unconfigure'); echo "</td><td class=tdleft valign=bottom>"; renderSLBEntityCell($cells[0]); echo "</td><td>VS config ↓<br><textarea name=vsconfig rows=5 cols=70>" . stringForTextarea($slb->slb['vsconfig']) . "</textarea></td>"; echo '<td class=tdleft rowspan=2 valign=middle>'; printImageHREF('SAVE', 'Save changes', TRUE); echo "</td>"; echo "</tr><tr class=row_{$order}><td class=tdleft valign=top>"; renderSLBEntityCell($cells[1]); echo '</td><td>'; echo "<textarea name=rsconfig rows=5 cols=70>" . stringForTextarea($slb->slb['rsconfig']) . "</textarea><br>RS config ↑"; echo "<div style='float:left; margin-top:10px'><label><input name=prio type=text size=10 value=\"" . htmlspecialchars($slb->slb['prio']) . "\"> ← Priority</label></div>"; echo '</td></tr></form>'; $order = $nextorder[$order]; } echo "</table>\n"; finishPortlet(); } if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { callHook('renderNewSLBItemForm', $realm1, $realm2); } }
function renderCell($cell) { switch ($cell['realm']) { case 'user': echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; printImageHREF('USER'); echo '</td><td>' . mkA($cell['user_name'], 'user', $cell['user_id']) . '</td></tr>'; if (strlen($cell['user_realname'])) { echo "<tr><td><strong>" . niftyString($cell['user_realname']) . "</strong></td></tr>"; } else { echo "<tr><td class=sparenetwork>no name</td></tr>"; } echo '<td>'; if (!isset($cell['etags'])) { $cell['etags'] = getExplicitTagsOnly(loadEntityTags('user', $cell['user_id'])); } echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo "</td></tr></table>"; break; case 'file': echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; switch ($cell['type']) { case 'text/plain': printImageHREF('text file'); break; case 'image/jpeg': case 'image/png': case 'image/gif': printImageHREF('image file'); break; default: printImageHREF('empty file'); break; } echo "</td><td>"; echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'file', $cell['id']); echo "</td><td rowspan=3 valign=top>"; if (isset($cell['links']) and count($cell['links'])) { printf("<small>%s</small>", serializeFileLinks($cell['links'])); } echo "</td></tr><tr><td>"; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo '</td></tr><tr><td>'; if (isolatedPermission('file', 'download', $cell)) { // FIXME: reuse renderFileDownloader() echo "<a href='?module=download&file_id={$cell['id']}'>"; printImageHREF('download', 'Download file'); echo '</a> '; } echo formatFileSize($cell['size']); echo "</td></tr></table>"; break; case 'ipv4vs': case 'ipvs': case 'ipv4rspool': renderSLBEntityCell($cell); break; case 'ipv4net': case 'ipv6net': echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; printImageHREF('NET'); echo '</td><td>' . mkA("{$cell['ip']}/{$cell['mask']}", $cell['realm'], $cell['id']); echo getRenderedIPNetCapacity($cell); echo '</td></tr>'; echo "<tr><td>"; if (strlen($cell['name'])) { echo "<strong>" . niftyString($cell['name']) . "</strong>"; } else { echo "<span class=sparenetwork>no name</span>"; } // render VLAN renderNetVLAN($cell); echo "</td></tr>"; echo '<tr><td>'; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo "</td></tr></table>"; break; case 'rack': echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; $thumbwidth = getRackImageWidth(); $thumbheight = getRackImageHeight($cell['height']); echo "<img border=0 width={$thumbwidth} height={$thumbheight} title='{$cell['height']} units' "; echo "src='?module=image&img=minirack&rack_id={$cell['id']}'>"; echo "</td><td>"; echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'rack', $cell['id']); echo "</td></tr><tr><td>"; echo niftyString($cell['comment']); echo "</td></tr><tr><td>"; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo "</td></tr></table>"; break; case 'location': echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; printImageHREF('LOCATION'); echo "</td><td>"; echo mkA('<strong>' . niftyString($cell['name']) . '</strong>', 'location', $cell['id']); echo "</td></tr><tr><td>"; echo niftyString($cell['comment']); echo "</td></tr><tr><td>"; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo "</td></tr></table>"; break; case 'object': echo "<table class='slbcell vscell'><tr><td rowspan=2 width='5%'>"; printImageHREF('OBJECT'); echo '</td><td>'; echo mkA('<strong>' . niftyString($cell['dname']) . '</strong>', 'object', $cell['id']); echo '</td></tr><tr><td>'; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; echo "</td></tr></table>"; break; default: throw new InvalidArgException('realm', $cell['realm']); } }