Exemplo n.º 1
0
function select_locations($selected, $name = 'locations')
{
    $sel = new SelectItem($name);
    list($list, $values) = getEntitiesSelectableElements();
    $sel->setElements($list);
    $sel->setElementsVal($values);
    $sel->setSelected($selected);
    return $sel;
}
Exemplo n.º 2
0
function select_locations($selected, $name = 'locations') {
    $sel = new SelectItem($name);
    $list = array();
    $locations = getUserLocations();
    if (is_array($locations)) {
        foreach ($locations as $loc) {
            $list[$loc['uuid']] = $loc['altname'];
        }
    } else {
        $locations = array();
    }
    $sel->setElements(array_values($list));
    $sel->setElementsVal(array_keys($list));
    $sel->setSelected($selected);
    return $sel;
}
Exemplo n.º 3
0
    redirectTo(urlStrRedirect("shorewall/shorewall/restart_service", array("page" => $page)));
}
// Display policy form
$p = new PageGenerator(_T("Policy", "shorewall"));
$p->setSideMenu($sidemenu);
$p->display();
echo '<p>' . _T("The policy applies if no rule match the request.") . '</p>';
$f = new ValidatingForm(array('id' => 'policy'));
$f->push(new Table());
foreach (getPolicies() as $policy) {
    if (startsWith($policy[0], $src) && startsWith($policy[1], $dst)) {
        $label = sprintf("%s (%s) → %s (%s)", getZoneType($policy[0]), $policy[0], getZoneType($policy[1]), $policy[1]);
        $decisionTpl = new SelectItem($policy[0] . "_" . $policy[1] . "_policy");
        $decisionTpl->setElements(array(_T("Accept"), _T("Drop")));
        $decisionTpl->setElementsVal(array("ACCEPT", "DROP"));
        $decisionTpl->setSelected($policy[2]);
        $f->add(new TrFormElement($label, $decisionTpl));
    }
}
$f->pop();
$f->addButton("bpolicy", _T("Save"));
$f->display();
print '<br />';
// Rules list display
$ajax = new AjaxFilter(urlStrRedirect("shorewall/shorewall/ajax_" . $page));
$ajax->display();
$t = new TitleElement(_T("Port forwarding rules"), 2);
$t->display();
$ajax->displayDivToUpdate();
// Add rule form
print '<script type="text/javascript" src="modules/shorewall/includes/functions.js"></script><br />';
Exemplo n.º 4
0
$f = new ValidatingForm(array("action" => urlStrRedirect("imaging/manage/save_configuration")));
$f->add(new HiddenTpl("is_uuid"), array("value" => $imaging_server['imaging_uuid'], "hide" => True));
$lang = xmlrpc_getAllKnownLanguages();
$lang_choices = array();
$lang_values = array();
$lang_id2uuid = array();
foreach ($lang as $l) {
    $lang_choices[$l['imaging_uuid']] = $l['label'];
    $lang_values[$l['imaging_uuid']] = $l['imaging_uuid'];
    $lang_id2uuid[$l['id']] = $l['imaging_uuid'];
}
$language = new SelectItem("language");
$language->setElements($lang_choices);
$language->setElementsVal($lang_values);
if ($imaging_server['fk_language']) {
    $language->setSelected($lang_id2uuid[$imaging_server['fk_language']]);
}
$f->push(new Table());
$f->add(new TrFormElement(_T("Menu language", "imaging"), $language));
$pxe_password_label = _T('PXE Password', 'imaging');
$pxe_password_label_desc = _T('Leave this field empty to unset PXE Password', 'imaging');
$pxe_password_label = <<<EOS
<a href="#" class="tooltip">
    {$pxe_password_label}
    <span><p>
        {$pxe_password_label_desc}
    </p></span>

</a>
EOS;
$f->add(new TrFormElement($pxe_password_label, new PasswordTpl('pxe_password')), array("value" => xmlrpc_getPXEPasswordHash($location) == '' ? '' : '.......'));
Exemplo n.º 5
0
        // We check other languages
        // Searching with xx_XX pattern
        if (in_array($lang_2, $languages)) {
            $_SESSION['lang'] = $lang_2;
        } else {
            // Searching with xx pattern
            foreach ($languages as $lang) {
                if (substr($lang, 0, 2) == $lang_1) {
                    $_SESSION['lang'] = $lang;
                }
            }
        }
    }
}
if (isset($_SESSION['lang'])) {
    $langList->setSelected($_SESSION['lang']);
} else {
    $langList->setSelected($langDescList[0]);
}
if ($conf[$servList->selected]['forgotPassword']) {
    ?>
                <p><a href="forgotpassword.php?server=<?php 
    echo $servList->selected;
    ?>
&lang=<?php 
    echo $langList->selected;
    ?>
"><?php 
    echo _("Forgot password ?");
    ?>
</a></p>
Exemplo n.º 6
0
}
if ($src != array("fw")) {
    $f->add(new TrFormElement(_T("Limit source IP(s)"), new InputTpl("source_ip"), array("tooltip" => "Specify source IP(s), IP range(s), network for this rule separated by commas. (eg: 192.168.2.2,192.0.2.11-192.0.2.17)")), array("value" => fromPOST('source_ip')));
}
$dst_zones = getZonesInterfaces($dst);
if (count($dst_zones) > 1) {
    $destinations = array("All");
    $destinationsVals = array("all");
    foreach ($dst_zones as $zone) {
        $destinations[] = sprintf("%s (%s)", $zone[0], $zone[1]);
        $destinationsVals[] = $zone[0];
    }
    $destinationsTpl = new SelectItem("destination");
    $destinationsTpl->setElements($destinations);
    $destinationsTpl->setElementsVal($destinationsVals);
    $destinationsTpl->setSelected(fromPOST("destination"));
    $f->add(new TrFormElement(_T("Destination zone"), $destinationsTpl));
} else {
    $tr = new TrFormElement(_T("Destination zone"), new HiddenTpl("destination"));
    $tr->setStyle("display: none");
    $f->add($tr, array("value" => "all"));
}
if ($dst != array("fw")) {
    $tr = new TrFormElement(_T("Limit destination IP(s)"), new InputTpl("destination_ip"), array("tooltip" => "Specify destination IP(s), IP range(s), network for this rule separated by commas. (eg: 155.186.235.0/24,155.186.233.23)"));
    $f->add($tr, array("value" => fromPOST("destination_ip")));
}
$macros = getServices();
$services = array("", "Custom rule...") + $macros;
$servicesVals = array("", "custom") + $macros;
$serviceTpl = new SelectItem("service", "toggleCustom");
$serviceTpl->setElements($services);
Exemplo n.º 7
0
 function display_ordered($orders)
 {
     $f = new ValidatingForm();
     $f->push(new Table());
     foreach ($this->members as $pid => $plabel) {
         $select = new SelectItem($this->input_pre . base64_encode($pid));
         $select->setElements($this->c);
         $select->setElementsVal($this->c);
         $select->setSelected($orders[$pid]);
         $f->add(new TrFormElement($plabel, $select, array()));
     }
     foreach ($this->getHidden() as $w) {
         $f->add($w[0], $w[1]);
     }
     $this->display_options($f);
     $f->pop();
     foreach ($this->buttons as $b) {
         $f->addButton($b[0], $b[1], $b[2]);
     }
     $f->display();
 }
Exemplo n.º 8
0
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * MMC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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
 */
include_once "modules/msc/includes/commands_xmlrpc.inc.php";
if (!empty($_GET["commands"])) {
    setCommandsFilter($_GET["commands"]);
}
$paramname2 = $_GET['paramname2'];
$res = get_all_commandsonhost_currentstate();
$states = new SelectItem($paramname2, 'pushSearch', 'searchfieldreal noborder');
$list = array();
$labels = array();
foreach ($res as $name) {
    $labels[$name] = _T(preg_replace("[_]", ' ', ucfirst($name)), 'msc');
    $list[$name] = $name;
}
$states->setElements($labels);
$states->setElementsVal($list);
if (in_array($_GET['selected'], array_keys($labels))) {
    $states->setSelected($_GET['selected']);
}
$states->displayContent();
Exemplo n.º 9
0
$p->setSideMenu($sidemenu);
// Display the PageGenerator
$p->display();

// Create a form with a list of options and a checkbox
$form = new ValidatingForm();
$form->push(new Table());

// The list of options is put in an array, and the listbox is configured with this array
$periodList = array(_T("Last week") => 7, _T("Last month")=>30, _T("Last quarter")=>90, _T("Last semester")=>180, _T("Last year")=>356);
$listbox = new SelectItem("period", "validateForm");
$listbox->setElements(array_keys($periodList));
$listbox->setElementsVal(array_values($periodList));
// Check the value to put by default in the list
if(isset($_POST['period']))
    $listbox->setSelected($_POST['period']);
else
    $listbox->setSelected(7); // must match with the default value in ajaxIncoming.php (7 for a week here)

// Put the element in a Tr elemet to align it
$listboxTr = new TrFormElement(_T("Period"), $listbox);

// Create a checkbox element
$checkbox = new CheckboxTpl("only_new", null, "validateForm");

$checkboxTr = new TrFormElement(_T("Only new computers"), $checkbox,
                                array("tooltip"=>_T("Load only the computers which were new when the inventory was made")));

$form->add($listboxTr);
$form->add($checkboxTr,
           array("value" => $checked));
Exemplo n.º 10
0
}
$f->add(new TrFormElement(_T("Folder", "backuppc"), $sel, array()));
// =====================================================================
// MIN AND MAX FILESIZE
// =====================================================================
$f->add(new HiddenTpl("minsize"), array("value" => isset($_POST['minsize']) ? $_POST['minsize'] : '-1', "hide" => True));
$f->add(new HiddenTpl("maxsize"), array("value" => isset($_POST['maxsize']) ? $_POST['maxsize'] : '-1', "hide" => True));
// =============================================================================
// SHARENAME SELECT FIELD  =====================================================
// =============================================================================
$sel = new SelectItem("filesize");
$sizes = array('0' => _T('Any size', 'backuppc'), '1' => _T('Less than 1 Mb', 'backuppc'), '2' => _T('1 Mb to 10 Mb', 'backuppc'), '3' => _T('10 Mb to 100 Mb', 'backuppc'), '4' => _T('Greater than 100 Mb', 'backuppc'));
$sel->setElements(array_values($sizes));
$sel->setElementsVal(array_keys($sizes));
if (isset($_POST['filesize'])) {
    $sel->setSelected($_POST['filesize']);
} else {
    $sel->setSelected(0);
}
$f->add(new TrFormElement(_T("File size", "backuppc"), $sel, array()));
/*
 $f->add(
 new TrFormElement(_T('Minimum file size','backuppc'), new InputTpl('minsize')),
 array("value" => isset($_POST['minsize'])?$_POST['minsize']:'',"required" => True)
 );

 $f->add(
 new TrFormElement(_T('Maximum file size','backuppc'), new InputTpl('maxsize')),
 array("value" => isset($_POST['maxsize'])?$_POST['maxsize']:'',"required" => True)
 );
*/
Exemplo n.º 11
0
    new NotifyWidgetWarning(_T("Default profiles can't be modified. Your changes will be saved as a new profile.", 'backuppc'));
    $profile['profilename'] = '';
}
$p->setSideMenu($sidemenu);
$p->display();
// display an edit config form
$f = new ValidatingForm();
$f->push(new Table());
// Profile name
$f->add(new TrFormElement(_T('Name', 'backuppc'), new InputTpl('profilename')), array("value" => $profile['profilename'], "required" => True));
// Client host encoding
$sel = new SelectItem("encoding");
$list = array("utf8" => 'UTF8', "cp1252" => _T('Windows-1252 - Western Europe', 'backuppc'), "cp874" => _T('Windows-874 - Thai', 'backuppc'), "cp932" => _T('Windows-932 - Japanese', 'backuppc'), "cp936" => _T('Windows-936 - Chinese (simplified)', 'backuppc'), "cp949" => _T('Windows-949 - Korean', 'backuppc'), "cp950" => _T('Windows-950 - Chinese (traditional)', 'backuppc'), "cp1250" => _T('Windows-1250 - Latin (Central Europe)', 'backuppc'), "cp1251" => _T('Windows-1251 - Cyrillic', 'backuppc'), "cp1253" => _T('Windows-1253 - Greek', 'backuppc'), "cp1254" => _T('Windows-1254 - Turkish', 'backuppc'), "cp1255" => _T('Windows-1255 - Hebrew', 'backuppc'), "cp1256" => _T('Windows-1256 - Arabic', 'backuppc'), "cp1257" => _T('Windows-1257 - Latin (Baltic languages)', 'backuppc'), "cp1258" => _T('Windows-1258 - Vietnamese', 'backuppc'));
$sel->setElements(array_values($list));
$sel->setElementsVal(array_keys($list));
$sel->setSelected($profile['encoding']);
$f->add(new TrFormElement(_T("Client encoding", "backuppc"), $sel, array()));
// Exclude lists
$sharenames = explode("\n", $profile['sharenames']);
$i = 0;
$profile['excludes'] = explode('||', $profile['excludes']);
for ($i = 0; $i < count($sharenames); $i++) {
    // Fields
    $fields = array(new InputTpl('sharenames[]'), new textTpl(_T('Excluded files', 'backuppc')), new TextareaTpl('excludes[]'), new buttonTpl('removeShare', _T('Remove'), 'removeShare'));
    $values = array($sharenames[$i], '', $profile['excludes'][$i], '');
    $f->add(new TrFormElement(_T('Folder', 'backuppc'), new multifieldTpl($fields)), array("value" => $values, "required" => True));
}
// Add Share button
$addShareBtn = new buttonTpl('addShare', _T('Add folder', 'backuppc'));
$addShareBtn->setClass('btnPrimary');
$f->add(new TrFormElement('', $addShareBtn), array());
Exemplo n.º 12
0
}
// Add Share button
$addShareBtn = new buttonTpl('addShare', _T('Add folder', 'backuppc'));
$addShareBtn->setClass('btnPrimary');
$f->add(new TrFormElement('', $addShareBtn), array());
//=======================================
// PERIOD PROFILE SELECT FIELD
$sel = new SelectItem("period_profile");
$list = array();
$list[0] = _T('Custom', 'backuppc');
foreach ($period_profiles as $profile) {
    $list[intval($profile['id'])] = _T($profile['profilename'], 'backuppc');
}
$sel->setElements(array_values($list));
$sel->setElementsVal(array_keys($list));
$sel->setSelected($period_profile_id);
$f->add(new TrFormElement(_T("Schedule", 'backuppc'), $sel, array()));
// =====================================================================
// Period config
// FULL period
$f->add(new TrFormElement(_T('Interval between two full backups (days)', 'backuppc'), new InputTpl('full')), array("value" => $host_config['FullPeriod'] == '' ? '' : floatval($host_config['FullPeriod']) + 0.03, "required" => True));
// INCR period
$f->add(new TrFormElement(_T('Interval between two incr backups (days)', 'backuppc'), new InputTpl('incr')), array("value" => $host_config['IncrPeriod'] == '' ? '' : floatval($host_config['IncrPeriod']) + 0.03, "required" => True));
$daynames = array(_T('Monday', 'backuppc'), _T('Tuesday', 'backuppc'), _T('Wednesday', 'backuppc'), _T('Thursday', 'backuppc'), _T('Friday', 'backuppc'), _T('Saturday', 'backuppc'), _T('Sunday', 'backuppc'));
// Exclude periods
$exclude_periods = explode("\n", $profile['exclude_periods']);
$z = 0;
foreach ($host_config['BlackoutPeriods'] as $period) {
    list($from, $to, $days) = array($period['hourBegin'], $period['hourEnd'], $period['weekDays']);
    $days = explode(',', $days);
    // DAYS SELECT
Exemplo n.º 13
0
// Create the page with its title and sidemenu
$p = new PageGenerator(_T("Incoming Inventories"));
$p->setSideMenu($sidemenu);
// Display the PageGenerator
$p->display();
// Create a form with a list of options and a checkbox
$form = new ValidatingForm();
$form->push(new Table());
// The list of options is put in an array, and the listbox is configured with this array
$periodList = array(_T("Last week") => 7, _T("Last month") => 30, _T("Last quarter") => 90, _T("Last semester") => 180, _T("Last year") => 356);
$listbox = new SelectItem("period", "validateForm");
$listbox->setElements(array_keys($periodList));
$listbox->setElementsVal(array_values($periodList));
// Check the value to put by default in the list
if (isset($_POST['period'])) {
    $listbox->setSelected($_POST['period']);
} else {
    $listbox->setSelected(7);
}
// must match with the default value in ajaxIncoming.php (7 for a week here)
// Put the element in a Tr elemet to align it
$listboxTr = new TrFormElement(_T("Period"), $listbox);
// Create a checkbox element
$checkbox = new CheckboxTpl("only_new", null, "validateForm");
$checkboxTr = new TrFormElement(_T("Only new computers"), $checkbox, array("tooltip" => _T("Load only the computers which were new when the inventory was made")));
$form->add($listboxTr);
$form->add($checkboxTr, array("value" => $checked));
$form->pop();
// Display the form
$form->display();
// Create the Ajax filter