function show_icon($id) { $app = $_SESSION['service']->application_info($_REQUEST['id']); if (!is_object($app)) { popup_error(sprintf(_("Failed to import application '%s'"), $_REQUEST['id'])); return false; } // die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__); if ($app->getAttribute('static')) { redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id')); } $is_rw = applicationdb_is_writable(); $servers = array(); if ($app->hasAttribute('servers')) { $servers = $app->getAttribute('servers'); } page_header(); echo '<div>'; echo '<h1><img class="icon32" src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; echo '<th>' . _('Package') . '</th>'; echo '<th>' . _('Type') . '</th>'; // echo '<th>'._('Status').'</th>'; echo '<th>' . _('Description') . '</th>'; echo '<th>' . _('Executable') . '</th>'; echo '</tr>'; echo '<tr class="content1">'; echo '<td>' . $app->getAttribute('package') . '</td>'; echo '<td style="text-align: center;"><img class="icon32" src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>'; // echo '<td>'.$status.'</td>'; echo '<td>' . $app->getAttribute('description') . '</td>'; echo '<td>' . $app->getAttribute('executable_path') . '</td>'; echo '</tr>'; echo '</table>'; echo '<br />'; echo '<h2>' . _('Select an icon from an Application Server') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="5">'; foreach ($servers as $server_id => $server_name) { $ret = $_SESSION['service']->application_icon_getFromServer($app->getAttribute('id'), $server_id); if (!$ret) { continue; } $imgfile = tempnam(NULL, 'ico'); @file_put_contents($imgfile, base64_decode($ret)); if (!file_exists($imgfile)) { continue; } echo '<tr>'; echo '<td style="width: 32px;"><img class="icon32" src="media/image/temp_icon.php?tempnam=' . basename($imgfile) . '" /></td>'; echo '<td><a href="servers.php?action=manage&id=' . $server_id . '">' . $server_name . '</a></td>'; echo '<td><form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application" />'; echo '<input type="hidden" name="action" value="icon" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="hidden" name="server" value="' . $server_id . '" />'; echo '<input type="submit" value="' . _('Select this icon') . '" />'; echo '</form></td>'; echo '</tr>'; } echo '</table>'; echo '<br />'; echo '<h2>' . _('Upload an icon') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="5">'; echo '<tr>'; echo '<td>'; echo '<form action="actions.php" method="post" enctype="multipart/form-data" >'; // form A echo '<input type="hidden" name="name" value="Application" />'; echo '<input type="hidden" name="action" value="icon" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="file" name="file_icon" /> '; echo '<input type="submit" value="' . _('Upload this icon') . '" />'; echo '</form>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</div>'; page_footer(); die; }
function show_manage($id) { $app = $_SESSION['service']->application_info($id); $application_type = $app->getAttribute('type'); if (!is_object($app)) { return false; } $is_rw = applicationdb_is_writable(); $can_manage_applications = isAuthorized('manageApplications'); // App groups $appgroups = $_SESSION['service']->applications_groups_list(); $groups_id = array(); if ($app->hasAttribute('groups')) { $groups_id = $app->getAttribute('groups'); } $groups = array(); $groups_available = array(); foreach ($appgroups as $group) { if (array_key_exists($group->id, $groups_id)) { $groups[] = $group; } else { $groups_available[] = $group; } } $servers_all = $_SESSION['service']->servers_list('online'); $servers = array(); foreach ($servers_all as $server) { if (array_key_exists('webapps', $server->roles) && $server->roles['webapps']) { $servers[] = $server; } } $can_manage_server = isAuthorized('manageServers'); page_header(); echo '<div>'; echo '<h1><img class="icon32" src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; echo '<th>' . _('Type') . '</th>'; echo '<th>' . _('Description') . '</th>'; if ($is_rw and $can_manage_applications) { echo '<th></th>'; } echo '</tr>'; echo '<tr class="content1">'; // echo '<td>'.$app->getAttribute('package').'</td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>'; echo '<td>' . $app->getAttribute('description') . '</td>'; if ($is_rw and $can_manage_applications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">'; echo '<input type="hidden" name="name" value="Application_webapp" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Delete') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; echo '</table>'; if ($is_rw and $can_manage_applications) { $app_info = $_SESSION['service']->application_webapp_info($id); echo '<br />'; echo '<form action="actions.php" method="post"">'; echo '<input type="hidden" name="name" value="Application_webapp" />'; echo '<input type="hidden" name="action" value="clone" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Clone to new application') . '"/>'; echo '</form>'; echo '<br />'; echo '<h2>' . _('Description') . '</h2>'; echo '<div id="application_modify">'; echo '<form id="delete_icon" action="actions.php" method="post" style="display: none;">'; echo '<input type="hidden" name="name" value="Application_webapp" />'; echo '<input type="hidden" name="action" value="del_icon" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '</form>'; echo '<form action="actions.php" method="post" enctype="multipart/form-data" >'; // form A echo '<input type="hidden" name="name" value="Application_webapp" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="published" value="1" />'; echo '<input type="hidden" name="static" value="1" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<table border="1"><tr><td>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; $count = 1; $app->setAttribute('application_name', $app->getAttribute('name')); // ugly hack $app->setAttribute('url_prefix', $app_info['url_prefix']); $attr_list = array('application_name' => _('Name'), 'description' => 'Description', 'url_prefix' => _('URL prefix')); foreach ($attr_list as $attr_name => $display_name) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td style="text-transform: capitalize;">'; echo $display_name; $attr_value = $app->getAttribute($attr_name); echo '</td>'; echo '<td>'; echo '<input type="text" name="' . $attr_name . '" value="' . htmlspecialchars($attr_value) . '" style="with:100%;"/>'; echo '<input type="hidden" name="attributes_send[]" value="' . $attr_name . '" />'; echo '</td>'; echo '</tr>'; } $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td>' . _('Icon') . '</td>'; echo '<td>'; echo '<img class="icon32" src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> '; echo '<input type="button" value="' . _('Delete this icon') . '" onclick="return confirm(\'' . _('Are you sure you want to delete this icon?') . '\') && $(\'delete_icon\').submit();"/>'; echo '<br />'; echo '<input type="file" name="file_icon" /> '; echo '</td>'; echo '</tr>'; $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td>' . _('Configuration') . '</td>'; echo '<td>'; echo '<textarea name="app_conf_raw" style="width:100%;height:12em">' . $app_info['raw_configuration'] . '</textarea>'; echo '<br />'; echo '<a href="actions.php?name=Application_webapp&action=download&id=' . $app->getAttribute('id') . '">' . _('Download') . '</a>'; echo '</td>'; echo '</tr>'; $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td colspan="2">'; echo '<input type="submit" value="' . _('Modify') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; // form A echo "</td>"; echo "<td>"; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_webapp" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="published" value="1" />'; echo '<input type="hidden" name="static" value="1" />'; echo '<input type="hidden" name="task" value="webapp_configuration" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; display_webapp_configuration($id); echo '</form>'; echo '</table>'; echo "</td></tr>"; echo "</table>"; echo '</div>'; // application_modify } if (count($servers) > 0) { echo '<div>'; echo '<h2>' . _('Servers') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($servers as $server) { echo '<tr><td>'; echo '<a href="servers.php?action=manage&id=' . $server->id . '">' . $server->getDisplayName() . '</a>'; echo '</td></tr>'; } echo '</table>'; echo "<div>\n"; } if (count($appgroups) > 0) { echo '<div>'; echo '<h2>' . _('Groups with this application') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($groups as $group) { echo '<tr>'; echo '<td>'; echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>'; echo '</td>'; echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="element" value="' . $id . '" />'; echo '<input type="hidden" name="group" value="' . $group->id . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form></td>'; echo '</tr>'; } if (count($groups_available) > 0) { echo '<tr>'; echo '<form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="element" value="' . $id . '" />'; echo '<select name="group">'; foreach ($groups_available as $group) { echo '<option value="' . $group->id . '">' . $group->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form>'; echo '</tr>'; } echo '</table>'; echo "<div>\n"; } echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; page_footer(); die; }
function show_manage($id) { global $types, $regular_types; $app = $_SESSION['service']->application_info($id); if (!is_object($app)) { return false; } $is_rw = applicationdb_is_writable(); $can_manage_applications = isAuthorized('manageApplications'); // App groups $appgroups = $_SESSION['service']->applications_groups_list(); $groups_id = array(); if ($app->hasAttribute('groups')) { $groups_id = $app->getAttribute('groups'); } $groups = array(); $groups_available = array(); foreach ($appgroups as $group) { if (array_key_exists($group->id, $groups_id)) { $groups[] = $group; } else { $groups_available[] = $group; } } $servers_all = $_SESSION['service']->servers_list('role_aps'); // load by type application type ... $servers_id = array(); if ($app->hasAttribute('servers')) { $servers_id = $app->getAttribute('servers'); } $servers = array(); $servers_available = array(); foreach ($servers_all as $server) { if (array_key_exists($server->id, $servers_id)) { $servers[] = $server; } elseif (!$server->isOnline()) { continue; } elseif ($server->type != $app->getAttribute('type')) { continue; } else { $servers_available[] = $server; } } $mimes = $_SESSION['service']->mime_types_list(); $mimeliste1 = $app->getMimeTypes(); $mimeliste2 = array(); foreach ($mimes as $mime) { if (!in_array($mime, $mimeliste1)) { $mimeliste2[] = $mime; } } $can_manage_server = isAuthorized('manageServers'); page_header(); echo '<div>'; echo '<h1><img class="icon32" src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">'; echo '<tr class="title">'; // echo '<th>'._('Package').'</th>'; echo '<th>' . _('Type') . '</th>'; echo '<th>' . _('Description') . '</th>'; if (in_array($app->getAttribute('type'), $regular_types)) { echo '<th>' . _('Command') . '</th>'; } else { echo '<th>' . _('URL') . '</th>'; } if ($is_rw and $can_manage_applications) { echo '<th></th>'; } echo '</tr>'; echo '<tr class="content1">'; // echo '<td>'.$app->getAttribute('package').'</td>'; echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>'; echo '<td>' . $app->getAttribute('description') . '</td>'; echo '<td>'; if (in_array($app->getAttribute('type'), $regular_types)) { echo $app->getAttribute('executable_path'); } else { echo '<a href="' . $app->getAttribute('executable_path') . '">' . $app->getAttribute('executable_path') . '</a>'; } echo '</td>'; if ($is_rw and $can_manage_applications) { echo '<td>'; echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application?') . '\');">'; echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Delete') . '" />'; echo '</form>'; echo '</td>'; } echo '</tr>'; echo '</table>'; if ($is_rw and $can_manage_applications) { echo '<br />'; echo '<form action="actions.php" method="post"">'; echo '<input type="hidden" name="name" value="Application" />'; echo '<input type="hidden" name="action" value="clone" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="submit" value="' . _('Clone to new application') . '"/>'; echo '</form>'; echo '<br />'; echo '<h2>' . _('Modify') . '</h2>'; echo '<div id="application_modify">'; echo '<form id="delete_icon" action="actions.php" method="post" style="display: none;">'; echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="del_icon" />'; echo '<input type="hidden" name="checked_applications[]" value="' . $app->getAttribute('id') . '" />'; echo '</form>'; echo '<form action="actions.php" method="post" enctype="multipart/form-data" >'; // form A echo '<input type="hidden" name="name" value="Application_static" />'; echo '<input type="hidden" name="action" value="modify" />'; echo '<input type="hidden" name="published" value="1" />'; echo '<input type="hidden" name="static" value="1" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="5">'; $count = 1; $app->setAttribute('application_name', $app->getAttribute('name')); // ugly hack $attr_list = array('application_name', 'description', 'executable_path'); asort($attr_list); foreach ($attr_list as $attr_name) { $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td style="text-transform: capitalize;">'; if ($attr_name == 'executable_path') { if (in_array($app->getAttribute('type'), $regular_types)) { echo _('Command'); } else { echo _('URL'); } } else { if ($attr_name == 'application_name') { echo _('Name'); } else { echo _($attr_name); } } echo '</td>'; echo '<td>'; echo '<input type="text" name="' . $attr_name . '" value="' . htmlspecialchars($app->getAttribute($attr_name)) . '" style="with:100%;"/>'; echo '<input type="hidden" name="attributes_send[]" value="' . $attr_name . '" />'; echo '</td>'; echo '</tr>'; } $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td>' . _('Icon') . '</td>'; echo '<td>'; echo '<img class="icon32" src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> '; echo '<input type="button" value="' . _('Delete this icon') . '" onclick="return confirm(\'' . _('Are you sure you want to delete this icon?') . '\') && $(\'delete_icon\').submit();"/>'; echo '<br />'; echo '<input type="file" name="file_icon" /> '; echo '</td>'; echo '</tr>'; $content = 'content' . ($count++ % 2 == 0 ? 1 : 2); echo '<tr class="' . $content . '">'; echo '<td colspan="2">'; echo '<input type="submit" value="' . _('Modify') . '" />'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</form>'; // form A echo '</div>'; // application_modify } if (count($servers) + count($servers_available) > 0) { echo '<div>'; echo '<h2>' . _('Servers with this application') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($servers as $server) { echo '<tr><td>'; echo '<a href="servers.php?action=manage&id=' . $server->id . '">' . $server->getDisplayName() . '</a>'; echo '</td>'; echo '<td>'; if ($server->isOnline() and $can_manage_server) { echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application from this server?') . '\');">'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="name" value="Application_Server" />'; echo '<input type="hidden" name="application" value="' . $id . '" />'; echo '<input type="hidden" name="server" value="' . $server->id . '" />'; echo '<input type="submit" value="' . _('Remove from this server') . '"/>'; echo '</form>'; } echo '</td>'; echo '</tr>'; } if (count($servers_available) > 0 and $can_manage_server) { echo '<tr>'; echo '<form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="Application_Server" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="application" value="' . $id . '" />'; echo '<select name="server">'; foreach ($servers_available as $server) { echo '<option value="' . $server->id . '">' . $server->getDisplayName() . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this server') . '" /></td>'; echo '</form>'; echo '</tr>'; } echo '</table>'; echo "<div>\n"; } if (count($appgroups) > 0) { echo '<div>'; echo '<h2>' . _('Groups with this application') . '</h2>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($groups as $group) { echo '<tr>'; echo '<td>'; echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>'; echo '</td>'; echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="element" value="' . $id . '" />'; echo '<input type="hidden" name="group" value="' . $group->id . '" />'; echo '<input type="submit" value="' . _('Delete from this group') . '" />'; echo '</form></td>'; echo '</tr>'; } if (count($groups_available) > 0) { echo '<tr>'; echo '<form action="actions.php" method="post"><td>'; echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="element" value="' . $id . '" />'; echo '<select name="group">'; foreach ($groups_available as $group) { echo '<option value="' . $group->id . '">' . $group->name . '</option>'; } echo '</select>'; echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>'; echo '</form>'; echo '</tr>'; } echo '</table>'; echo "<div>\n"; } // Mime-Type part echo '<div>'; echo '<h2>' . _('Mime-Types') . '</h2>'; echo '<div>'; echo '<table border="0" cellspacing="1" cellpadding="3">'; foreach ($mimeliste1 as $mime) { echo '<tr><td>'; echo '<a href="mimetypes.php?action=manage&id=' . urlencode($mime) . '">' . $mime . '</a>'; echo '</td>'; echo '<td>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="del" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<input type="hidden" name="mime" value="' . $mime . '" />'; echo '<input type="submit" value="' . _('Del') . '"/>'; echo '</form>'; echo '</td>'; echo '</tr>'; } if (is_array($mimeliste2) && count($mimeliste2) > 0) { echo '<tr>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<td>'; echo '<select name="mime">'; foreach ($mimeliste2 as $mime) { echo '<option>' . $mime . '</option>'; } echo '</select>'; echo '</td>'; echo '<td>'; echo '<input type="submit" value="' . _('Add') . '"/>'; echo '</td>'; echo '</form>'; echo '</tr>'; } echo '<tr>'; echo '<form action="actions.php" method="post">'; echo '<input type="hidden" name="name" value="Application_MimeType" />'; echo '<input type="hidden" name="action" value="add" />'; echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />'; echo '<td>' . _('Custom Mime-Type: ') . '<input type="text" name="mime" /></td>'; echo '<td>'; echo '<input type="submit" value="' . _('Add') . '"/>'; echo '</td>'; echo '</form>'; echo '</tr>'; echo '</table>'; echo '</div>'; echo '</div>'; // mime div echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; page_footer(); die; }