Пример #1
0
function renderConfigEditor()
{
    global $pageno;
    $per_user = $pageno == 'myaccount';
    global $configCache;
    startPortlet('Current configuration');
    echo "<table cellspacing=0 cellpadding=5 align=center class=widetable width='50%'>\n";
    echo "<tr><th class=tdleft>Option</th>";
    echo "<th class=tdleft>Value</th></tr>";
    printOpFormIntro('upd');
    $i = 0;
    foreach ($per_user ? $configCache : loadConfigCache() as $v) {
        if ($v['is_hidden'] != 'no') {
            continue;
        }
        if ($per_user && $v['is_userdefined'] != 'yes') {
            continue;
        }
        echo "<input type=hidden name={$i}_varname value='{$v['varname']}'>";
        echo '<tr><td class="tdright">';
        echo renderConfigVarName($v);
        echo '</td>';
        echo "<td class=\"tdleft\"><input type=text name={$i}_varvalue value='" . htmlspecialchars($v['varvalue'], ENT_QUOTES) . "' size=24></td>";
        echo '<td class="tdleft">';
        if ($per_user && $v['is_altered'] == 'yes') {
            echo getOpLink(array('op' => 'reset', 'varname' => $v['varname']), 'reset');
        }
        echo '</td>';
        echo "</tr>\n";
        $i++;
    }
    echo "<input type=hidden name=num_vars value={$i}>\n";
    echo "<tr><td colspan=3>";
    printImageHREF('SAVE', 'Save changes', TRUE);
    echo "</td></tr>";
    echo "</form>";
    finishPortlet();
}
Пример #2
0
function loadConfigDefaults()
{
    global $configCache;
    $configCache = loadConfigCache();
    if (!count($configCache)) {
        throw new RackTablesError('Failed to load configuration from the database.', RackTablesError::INTERNAL);
    }
    foreach ($configCache as $varname => &$row) {
        $row['is_altered'] = 'no';
        if ($row['vartype'] == 'uint') {
            $row['varvalue'] = 0 + $row['varvalue'];
        }
        $row['defaultvalue'] = $row['varvalue'];
    }
}