Beispiel #1
0
                        $result .= sprintf(_("Failed to enable user in %s plugin"), $plugin) . "<br />";
                    }
                }
                $result = sprintf(_("User %s enabled"), $uid);
            }
        }
        if (!$error) {
            $redirect = true;
            $FH->isError(false);
        }
    } else {
        $FH->isError(true);
    }
}
// prepare the result popup
$resultPopup = new NotifyWidget();
// add error messages
if ($error) {
    $resultPopup->add('<div class="alert alert-error">' . $error . '</div>');
    $resultPopup->setLevel(5);
}
// add info messages
if ($result) {
    $resultPopup->add('<div class="alert alert-success">' . $result . '</div>');
}
// in case of modification/creation success, redirect to the edit page
if ($redirect) {
    header('Location: ' . urlStrRedirect("base/users/edit", array("user" => $uid)));
    exit;
}
// in case of failure, set errorStatus to 0 in order to display the edit form
Beispiel #2
0
<form method="post" action="">

<table cellspacing="0">
 <tr>
  <td><?php 
echo _T("Name");
?>
</td>
  <td><input name="blacklistName" type="text" size="23" value="<?php 
if (isset($error)) {
    echo $blacklistName;
}
?>
" /></td>
 </tr>
</table>

<input name="bcreate" type="submit" class="btnPrimary" value="<?php 
echo _("Create");
?>
" />
</form>

<?php 
if (isset($error)) {
    $n = new NotifyWidget();
    $n->add($error);
}
?>

Beispiel #3
0
 /**
  * Prepare error message to display
  */
 function registerNotify($xmlResponse)
 {
     if ($this->_level != 0) {
         $str = '<div class="alert alert-error">';
     } else {
         $str = '<div class="alert alert-info">';
     }
     $str .= "<h1>" . $this->getMsg() . "</h1>";
     if ($this->getAdvice()) {
         $str .= "<p>" . $this->getAdvice() . "</p>";
     }
     if ($this->_showTraceBack) {
         $str .= '<a class="btn btn-danger" href="#" onclick="jQuery(this).next().toggle();">' . _("Show complete trackback") . '</a>';
         $str .= '<div class="errorTraceback" style="display:none;"><h1>' . _("Complete Traceback") . '</h1><pre>';
         $str .= gmdate("d M Y H:i:s") . "\n\n";
         $str .= "PHP XMLRPC call: " . $xmlResponse["faultString"] . "\n\n";
         $str .= "Python Server traceback:\n";
         $str .= htmlentities($xmlResponse["faultTraceback"]) . "\n";
         $str .= '</pre></div>';
     }
     $str .= '</div>';
     $n = new NotifyWidget();
     $n->size = $this->_size;
     $n->level = $this->_level;
     $n->add($str);
 }
Beispiel #4
0
 function NotifyWidgetWarning($message)
 {
     parent::NotifyWidget();
     $this->add("<div class=\"alert\">{$message}</div>");
     $this->level = 3;
     $this->save();
 }
Beispiel #5
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
print "<h1>" . _T('Available updates', 'update') . "</h1>";
require_once "includes/xmlrpc.inc.php";
require_once "modules/update/includes/xmlrpc.inc.php";
$updates = getProductUpdates();
$update_titles = array();
foreach ($updates as $update) {
    $update_titles[] = $update['title'];
}
$n = new OptimizedListInfos($update_titles, _T("Update", "update"));
$n->setItemCount(count($updates));
$n->setNavBar(new AjaxNavBar($count, $filter1));
$n->start = 0;
$n->end = 50;
ob_start();
$n->display();
$list = ob_get_clean();
//print "<pre>";
//print ;
$text = "<h1>" . _T('Available updates', 'backuppc') . "</h1>";
$text .= '<div style="height:400px;width:100%;overflow-y:scroll;">';
$text .= $list;
$text .= "</div>";
$f = new NotifyWidget();
$f->add($text);
     if ($FH->isUpdated("secondary")) {
         updateSecondaryServer($FH->getValue("secondary"));
         if (!isXMLRPCError()) {
             $result .= _T(sprintf("%s set as the secondary DHCP server.", $FH->getValue("secondary"))) . "<br />";
             updateFailoverConfig($FH);
         } else {
             $error .= _T(sprintf("Failed to set %s as the secondary DHCP server.", $FH->getValue("secondary"))) . "<br />";
         }
     } else {
         if ($FH->isUpdated("secondaryIp") or $FH->isUpdated("primaryIp") or $FH->isUpdated("primaryPort") or $FH->isUpdated("secondaryPort") or $FH->isUpdated("delay") or $FH->isUpdated("update") or $FH->isUpdated("balance") or $FH->isUpdated("mclt") or $FH->isUpdated("split")) {
             updateFailoverConfig($FH);
         }
     }
 }
 // prepare the result popup
 $resultPopup = new NotifyWidget();
 // add error messages
 if ($error) {
     $resultPopup->add('<div class="alert alert-error">' . $error . '</div>');
     $resultPopup->setLevel(5);
 }
 // add info messages
 if ($result) {
     $services = getServicesNames();
     $resultPopup->add('<div class="alert alert-success">' . $result . '</div>');
     handleServicesModule($resultPopup, array($services[1] => "DHCP"));
 }
 if (!$error) {
     header("Location: " . urlStrRedirect("network/network/services"));
     exit;
 }
Beispiel #7
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
// Check if some notification(s) needs to be shown
// If yes display the popup
if (isset($_SESSION['notify']) && count($_SESSION['notify']) > 0) {
    $_SESSION['notify_render'] = $_SESSION['notify'];
    unset($_SESSION['notify']);
    $content = NotifyWidget::begin();
    foreach ($_SESSION['notify_render'] as $notify) {
        $n = unserialize($notify);
        $content .= $n->content();
        $n->flush();
    }
    $content .= NotifyWidget::end();
    $content = json_encode($content);
    echo '
    <script type="text/javascript">
        var message = ' . $content . ';
        try {
            $("__popup_container").update(message);
        }
        catch(ex) {
            $("__popup_container").innerHTML = messages;
        }
        displayPopupCenter();
    </script>';
}
 function display()
 {
     // display parameters
     if (!$this->db_cmd) {
         # use does not have the good permissions
         $widget = new RenderedMSCCommandDontExists();
         $widget->display();
         return;
     }
     if ($this->db_cmd['start_date']) {
         if ($this->db_cmd['end_date']) {
             $validity = sprintf(_T('<i>from</i> %s <i>to</i> %s', 'msc'), _toDate($this->db_cmd['start_date']), _toDate($this->db_cmd['end_date']));
         } else {
             $validity = sprintf(_T('<i>from</i> %s', 'msc'), _toDate($this->db_cmd['start_date']));
         }
     } else {
         if ($this->db_cmd['end_date']) {
             $validity = sprintf(_T('<i>to</i> %s', 'msc'), _toDate($this->db_cmd['end_date']));
         } else {
             $validity = _T('<i>forever</i>', 'msc');
         }
     }
     if ($this->db_cmd['deployment_intervals']) {
         $deploy_interv = str_replace(array('-', ','), array(' - ', ', '), $this->db_cmd['deployment_intervals']);
     } else {
         $deploy_interv = _T('<i>whole day</i>', 'msc');
     }
     if ($this->db_cmd['deployment_intervals']) {
         $deploy_interv = str_replace(array('-', ','), array(' - ', ', '), $this->db_cmd['deployment_intervals']);
     } else {
         $deploy_interv = _T('<i>whole day</i>', 'msc');
     }
     if ($this->db_coh['next_launch_date']) {
         $next_launch_date = _toDate($this->db_coh['next_launch_date']);
     } else {
         if ($this->db_cmd['start_date']) {
             $next_launch_date = _toDate($this->db_cmd['start_date']);
         } else {
             $next_launch_date = _T('<i>as soon as possible</i>', 'msc');
         }
     }
     if ($this->db_coh['start_date']) {
         $start_date = _toDate($this->db_coh['start_date']);
     } else {
         $start_date = _T('<i>not yet available</i>', 'msc');
     }
     if ($this->db_coh['end_date']) {
         $end_date = _toDate($this->db_coh['end_date']);
     } else {
         $end_date = _T('<i>not yet available</i>', 'msc');
     }
     if ($this->db_coh['last_wol_attempt']) {
         $last_wol_attempt = _toDate($this->db_coh['last_wol_attempt']);
     } else {
         $last_wol_attempt = _T('<i>not available</i>', 'msc');
     }
     if ($this->db_cmd['start_file']) {
         if ($this->db_cmd['parameters']) {
             $command_line = sprintf(_T('%s %s', 'msc'), $this->db_cmd['start_file'], $this->db_cmd['parameters']);
         } else {
             $command_line = sprintf(_T('%s <i>(no additional parameter given)</i>', 'msc'), $this->db_cmd['start_file']);
         }
     } else {
         $command_line = _T('<i>not set</i>', 'msc');
     }
     if ($this->db_coh['order_in_proxy'] == '') {
         $proxy_priority = _T('None (Local Proxy Client)', 'msc');
     } else {
         $proxy_priority = sprintf(_T('%s (Local Proxy Server)', 'msc'), $this->db_coh['order_in_proxy']);
     }
     if ($this->db_cmd['proxy_mode'] == 'split') {
         $proxy_mode = _T('Multiple', 'msc');
     } elseif ($this->db_cmd['proxy_mode'] == 'queue') {
         $proxy_mode = _T('Single with fallback', 'msc');
     } elseif ($this->db_cmd['proxy_mode'] == 'none') {
         $proxy_mode = _T('No proxy', 'msc');
         $proxy_priority = _T('None', 'msc');
     } else {
         $proxy_mode = _T('<i>not available</i>', 'msc');
         $proxy_priority = _T('<i>not available</i>', 'msc');
     }
     if ($this->db_lproxy) {
         $current_proxy = $this->db_lproxy['host'];
     } else {
         $current_proxy = _T('<i>not available</i>', 'msc');
     }
     // gettext obfucation
     _T('enable', 'msc');
     _T('disable', 'msc');
     _T('done', 'msc');
     _T('failed', 'msc');
     _T('over_time', 'msc');
     _T('out_of_interval', 'msc');
     // =====================================================================
     function formatLog($hist)
     {
         $i = 1;
         if ($hist['state'] == 'upload_in_progress' && $hist['error_code'] == '0' && array_key_exists('stderr', $hist) && $i != count($this->db_ch) && strpos($hist['stderr'], 'is available on mirror') !== False) {
             /*
              We are displaying which package server was used in push pull
              mode. We want to keep the led green instead of orange to
              tell the user that there was no problem.
             */
             $staticon = history_stat2icon("upload_done");
         } elseif ($hist['state'] == 'wol_failed' && $hist['error_code'] == '2001') {
             $staticon = history_stat2icon("stop");
         } else {
             $staticon = history_stat2icon($hist['state']);
         }
         $history = date("Y-m-d H:i:s", $hist['date']);
         /* Split lines in stdout and stderr */
         if (gettype($hist["stdout"]) != 'array') {
             $hist["stdout"] = split("\n", $hist["stdout"]);
         }
         if (gettype($hist["stderr"]) != 'array') {
             $hist["stderr"] = split("\n", $hist["stderr"]);
         }
         if (count($hist["stdout"]) > 0 && !(count($hist["stdout"]) == 1 && $hist["stdout"][0] == '')) {
             $hist["stderr"] = array_merge($hist["stderr"], $hist["stdout"]);
         }
         if (strpos($hist['state'], '_failed') !== False || $hist['error_code'] > 4501 && $hist['error_code'] < 5000) {
             $msgs = array(255 => _T("Error while connecting to secure agent on this host. Please check network connectivity, and that the secure agent is installed on this host.", 'msc'), 200 + 9 => _T("The script was killed by Pulse 2 (timeout ?).", 'msc'), 200 + 15 => _T("The script was terminated by Pulse 2.", 'msc'), 240 + 0 => _T("Something goes wrong while checking client identity.", 'msc'), 240 + 1 => _T("The current host name doesn't match the host name from the inventory database.", 'msc'), 240 + 2 => _T("The current host IP address doesn't match the IP address from the inventory database.", 'msc'), 240 + 3 => _T("The current host MAC address doesn't match the MAC address from the inventory database.", 'msc'), 4000 + 1 => sprintf(_T("The package '%s' is not available on any mirror.", "msc"), $hist['stderr'][0]), 4000 + 2 => sprintf(_T("Can't get files URI for package '%s' on mirror %s.\nPlease check that the package and its files have not been modified since the planning of the command.", "msc"), $hist['stderr'][0], $hist['stderr'][1]), 4000 + 3 => sprintf(_T("Can't get files URI for package '%s' on fallback mirror %s.\nPlease check that the package and its files have not been modified since the planning of the command.", "msc"), $hist['stderr'][0], $hist['stderr'][1]), 4000 + 4 => sprintf(_T("An error occurred when trying to contact the mirror '%s' : the connection was refused.", "msc"), $hist['stderr'][0]), 4000 + 5 => sprintf(_T("An error occurred when trying to contact the fallback mirror '%s' : the connection was refused.", "msc"), $hist['stderr'][0]), 4000 + 6 => sprintf(_T("An error occurred when trying to contact the mirror '%s' : the mountpoint doesn't exists.", "msc"), $hist['stderr'][0]), 4000 + 7 => sprintf(_T("An error occurred when trying to contact the fallback mirror '%s' : the mountpoint doesn't exists.", "msc"), $hist['stderr'][0]), 4500 + 8 => sprintf(_T("Package '%s' is NOT available on primary mirror %s\nPackage '%s' is available on fallback mirror %s", "msc"), $hist['stdout'][0], $hist['stdout'][1], $hist['stdout'][2], $hist['stdout'][3]), 4500 + 9 => sprintf(_T("Package '%s' is available on primary mirror %s", "msc"), $hist['stdout'][0], $hist['stdout'][1]));
             if ($hist['error_code'] >= 4001 && $hist['error_code'] < 5000) {
                 $hist["stderr"] = array('');
             }
             if (array_key_exists($hist['error_code'], $msgs)) {
                 $hist['stderr'][] = $msgs[$hist['error_code']];
             }
         }
         $raw_errors = array_map('_colorise', array_filter($hist["stderr"]));
         $purge_errors = array();
         foreach ($raw_errors as $error) {
             if (isset($error)) {
                 array_push($purge_errors, $error);
             }
         }
         return array($history, $purge_errors);
     }
     // =====================================================================
     ### Display command phases ###
     $phases = $this->db_coh['phases'];
     $phase_labels = getPhaseLabels();
     $hidden_phases = array('done');
     $phase_names = array();
     $phase_dates = array();
     $phase_states = array();
     $phase_logs = array();
     $btn_showfull_log = array();
     // Organize logs by phase
     $logs_by_phase = array();
     foreach ($this->db_ch as $entry) {
         // Decode base64 stdout and stderr before processing
         $entry['stdout'] = base64_decode($entry['stdout']);
         $entry['stderr'] = base64_decode($entry['stderr']);
         // if $logs_by_phase doesnt contain phase key we create it
         if (!isset($logs_by_phase[$entry['phase']])) {
             $logs_by_phase[$entry['phase']] = array();
         }
         $logs_by_phase[$entry['phase']][] = $entry;
     }
     $ts_next_launch_time = _toTimestamp($this->db_coh['next_launch_date']);
     foreach ($phases as $phase) {
         // Passing hidden phases
         if (in_array($phase['name'], $hidden_phases)) {
             continue;
         }
         $phase_names[] = $phase_labels[$phase['name']];
         $phase_states[] = _plusIcon($phase['state']);
         if (isset($logs_by_phase[$phase['name']]) && count($logs_by_phase[$phase['name']])) {
             $formatted_logs = array_map('formatLog', $logs_by_phase[$phase['name']]);
         } else {
             if ($ts_next_launch_time > mktime() && ($phase['state'] == 'failed' || $phase['state'] == 'ready')) {
                 $last_try_time = _toDate($this->db_coh['next_launch_date']) . sprintf(' (%s)', _T('next attempt', 'msc'));
                 $ts_next_launch_time = 0;
             } else {
                 $last_try_time = '';
             }
             $phase_dates[] = $last_try_time;
             $phase_logs[] = '';
             continue;
         }
         $log = '';
         foreach ($formatted_logs as $onetry_log) {
             // info: $onetry_log == array($history, $log_lines)
             $log .= implode('<br/>', $onetry_log[1]) . '<br/>';
         }
         $text = "<h1>" . _T('Step log', 'msc') . "</h1>";
         $text .= '<div style="height:400px;width:100%;overflow-y:scroll;">';
         $text .= nl2br($log);
         $text .= "</div>";
         $f = new NotifyWidget(FALSE);
         $f->add($text, FALSE);
         $divid = $phase['name'] . '_log';
         printf('<div id="%s" style="display:none">%s</div>', $divid, $f->begin() . $f->content() . $f->end());
         $btn_showfull_log[] = sprintf('<ul class="action"><li class="status"><a title="%s" href="#" onclick="PopupWindow(null, \'\', 300, _centerPlacement,jQuery(\'#%s\').html());return false;"></a></li></ul>', _T('Show log', 'msc'), $divid);
         $last_try = $formatted_logs[count($formatted_logs) - 1][1];
         // If next_launch_date is a later time and this step is failed
         if ($ts_next_launch_time > mktime() && ($phase['state'] == 'failed' || $phase['state'] == 'ready')) {
             $last_try_time = _toDate($this->db_coh['next_launch_date']) . sprintf(' (%s)', _T('next attempt', 'msc'));
             $ts_next_launch_time = 0;
         } else {
             $last_try_time = $formatted_logs[count($formatted_logs) - 1][0];
         }
         $phase_dates[] = $last_try_time;
         $log_last_lines = '...<br/>';
         $last_lines_number = 3;
         for ($i = $last_lines_number; $i > 0; $i--) {
             if (isset($last_try[count($last_try) - ($i + 1)])) {
                 $log_last_lines .= $last_try[count($last_try) - ($i + 1)];
             }
         }
         // if log_last_lines didnt change (no previous line),
         // we return exit code
         // else ''
         if ($log_last_lines == '...<br/>') {
             if (isset($last_try[count($last_try) - 1])) {
                 $log_last_lines = $last_try[count($last_try) - 1];
             } else {
                 $log_last_lines = '';
             }
         }
         $phase_logs[] = $log_last_lines;
     }
     //$n = new ListInfos(array_map("_names", $values), _T('<b>Command Overview</b>', 'msc'));
     $n = new ListInfos($phase_names, '<b>' . _T('Step', 'msc') . '</b>', '', '80px');
     //$n->addExtraInfo(array_map("_values", $values), '', '400px');
     $n->addExtraInfo($phase_states, 'State', '20px');
     $n->addExtraInfo($phase_dates, 'Execution time', '120px');
     $n->addExtraInfo($phase_logs, 'Details');
     $n->addExtraInfo($btn_showfull_log, '', '20px');
     $n->setTableHeaderPadding(0);
     $n->setRowsPerPage(20);
     $n->drawTable(0);
     print "<br/>";
     ### Display command environment ###
     $values = array(array(_T('Reserved bandwidth', 'msc'), $this->db_cmd['maxbw'] == '0' ? _T('<i>none</i>', 'msc') : prettyOctetDisplay($this->db_cmd['maxbw'], 1024, _T('bit/s', 'msc'))), array(_T('Proxy mode', 'msc'), $proxy_mode), array(_T('Proxy priority', 'msc'), $proxy_priority), array(_T('Scheduler', 'msc'), $this->db_coh['scheduler']), array(_T('Current launcher', 'msc'), !empty($this->db_coh['current_launcher']) ? $this->db_coh['current_launcher'] : _T('<i>not available</i>', 'msc')), array(_T('Current proxy', 'msc'), $current_proxy));
     $n = new ListInfos(array_map("_names", $values), _T('<b>Command Environment</b>', 'msc'));
     $n->addExtraInfo(array_map("_values", $values), '', '400px');
     $n->setTableHeaderPadding(0);
     $n->setRowsPerPage(count($values));
     $n->drawTable(0);
     print "<br/>";
     # display command history
     # display log files
     $statusTable = getStatusTable();
     $i = 1;
 }
Beispiel #9
0
</p>

<input name="blacklist" type="hidden" value="<?php 
    echo $blacklist;
    ?>
" />
<input name="bdelblacklist" type="submit" class="btnPrimary" value="<?php 
    echo _("Delete");
    ?>
 <?php 
    echo $blacklist;
    ?>
" />
<input name="bback" type="submit" class="btnSecondary" value="<?php 
    echo _("Cancel");
    ?>
" onclick="new Effect.Fade('popup'); return false;" />
</form>

<?php 
} else {
    if (isset($_POST["bdelblacklist"])) {
        $n = new NotifyWidget();
        $blacklist = $_POST["blacklist"];
        if (!isXMLRPCError()) {
            $str = sprintf(_T("Domain %s has been removed"), $blacklist);
        }
        $n->add($str);
        redirectTo(urlStrRedirect('proxy/blacklist/index'));
    }
}