Beispiel #1
0
function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    if ($act == "add") {
        if (form_file_uploaded("file")) {
            $fname = $_FILES["file"]['name'];
            db_query("INSERT INTO images (link) VALUES ('')");
            $id = db_last_id();
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images");
        }
        form_start("", "post", " enctype='multipart/form-data' ");
        form_file("Файл", "file");
        form_submit("Загрузить", "submit");
        form_end();
        $o = form();
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("../{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    return $o;
}
function wormhole_show_wormhole($wormhole_id)
{
    assert(!empty($wormhole_id));
    global $_GALAXY;
    if (!anomaly_is_wormhole($wormhole_id)) {
        return;
    }
    $wormhole = anomaly_get_anomaly($wormhole_id);
    $sector = sector_get_sector($wormhole['sector_id']);
    $race = user_get_race($wormhole['user_id']);
    $result = sql_query("SELECT * FROM w_wormhole WHERE id=" . $wormhole['id']);
    $dst_wormhole = sql_fetchrow($result);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>\n";
    echo "  <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $wormhole['name'] . "</i></b></td></tr>\n";
    echo "  <tr><td>\n";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "      <tr><td width=200>\n";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "            <tr><th>Anomaly View</th></tr>\n";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/wormholes/" . $wormhole['image'] . ".jpg\" width=150 height=150></center></td></tr>\n";
    echo "            <tr><th>&nbsp;</th></tr>\n";
    echo "          </table>\n";
    echo "        </td>\n";
    echo "        <td>&nbsp;</td>\n";
    echo "        <td nowrap valign=top>\n";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
    echo "            <tr><td nowrap width=40%><strong>Wormhole Name        </strong></td><td nowrap width=1%><b>:</b></td>\n";
    if ($wormhole['unknown'] == 1) {
        form_start();
        echo "<td nowrap>\n";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($wormhole_id) . ">\n";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">\n";
        echo "  <input type=text size=15 maxlength=30 name=ne_name>\n";
        echo "  <input name=submit type=submit value=\"Claim\">\n";
        echo "</td>\n";
        form_end();
    } else {
        echo "<td nowrap>" . $wormhole['name'] . "</td>\n";
    }
    echo "             </tr>\n";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Caretaker          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Radius             </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $wormhole['radius'] . " km</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Distance to sun    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $wormhole['distance'] . " km (10<sup>6</sup>)</td></tr>\n";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Destination        </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $dst_wormhole['distance'] . " / " . $dst_wormhole['angle'] . "</td></tr>\n";
    echo "            <tr><td nowrap width=40%><strong>Stability          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . wormhole_get_wormhole_stability($dst_wormhole['next_jump']) . " </td></tr>\n";
    echo "          </table>\n";
    echo "        </td>\n";
    echo "      </tr>\n";
    echo "    </table>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
    echo "<br><br>\n";
}
function starbase_show_starbase($starbase_id)
{
    assert(!empty($starbase_id));
    global $_GALAXY;
    if (!anomaly_is_starbase($starbase_id)) {
        return;
    }
    $starbase = anomaly_get_anomaly($starbase_id);
    $sector = sector_get_sector($starbase['sector_id']);
    $race = user_get_race($starbase['user_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Starbase: " . $starbase['name'] . "</i></b></td></tr>";
    echo "  <tr><td>";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "      <tr><td width=200>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><th>Starbase View</th></tr>";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/starbase/" . $starbase['image'] . ".jpg\" width=150 height=150></center></td></tr>";
    echo "            <tr><th>&nbsp;</th></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "        <td>&nbsp;</td>";
    echo "        <td nowrap valign=top>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><td nowrap width=40%><strong>Starbase Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($starbase['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($starbase_id) . ">";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">";
        echo "  <input type=text size=15 maxlength=30 name=ne_name> ";
        echo "  <input name=submit type=submit value=\"Claim\">";
        echo "</td>";
        form_end();
    } else {
        echo "<td nowrap>" . $starbase['name'] . "</td>";
    }
    echo "             </tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Caretaker   </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Attack      </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_attack'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Defense     </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_defense'] . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Strength    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $starbase['cur_strength'] . "</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
function blackhole_show_blackhole($blackhole_id)
{
    assert(is_numeric($blackhole_id));
    global $_GALAXY;
    if (!anomaly_is_blackhole($blackhole_id)) {
        return;
    }
    $blackhole = anomaly_get_anomaly($blackhole_id);
    $race = user_get_race($blackhole['user_id']);
    $sector = sector_get_sector($blackhole['sector_id']);
    if ($race == "") {
        $race = "-";
    }
    echo "<table border=1 width=500 align=center>";
    echo "  <tr><td align=center><b><i>Sector: " . $sector['name'] . " / Anomaly: " . $blackhole['name'] . "</i></b></td></tr>";
    echo "  <tr><td>";
    echo "    <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "      <tr><td width=200>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><th>Anomaly View</th></tr>";
    echo "            <tr><td width=100%><center><img src=\"" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/blackholes/" . $blackhole['image'] . ".jpg\" width=150 height=150></center></td></tr>";
    echo "            <tr><th>&nbsp;</th></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "        <td>&nbsp;</td>";
    echo "        <td nowrap valign=top>";
    echo "          <table border=0 cellpadding=0 cellspacing=0 width=100%>";
    echo "            <tr><td nowrap width=40%><strong>Blackhole Name        </strong></td><td nowrap width=1%><b>:</b></td>";
    if ($blackhole['unknown'] == 1) {
        form_start();
        echo "<td nowrap>";
        echo "  <input type=hidden name=aid value=" . encrypt_get_vars($blackhole_id) . ">";
        echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("claim") . ">";
        echo "  <input type=text size=15 maxlength=30 name=ne_name> ";
        echo "  <input name=submit type=submit value=\"Claim\">";
        echo "</td>";
        form_end();
    } else {
        echo "<td nowrap>" . $blackhole['name'] . "</td>";
    }
    echo "             </tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Caretaker          </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $race . "</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Radius             </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $blackhole['radius'] . " km</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Distance to sun    </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . $blackhole['distance'] . " km (10<sup>6</sup>)</td></tr>";
    echo "            <tr><td colspan=3>&nbsp;</td></tr>";
    echo "            <tr><td nowrap width=40%><strong>Fatalities         </strong></td><td nowrap width=1%><b>:</b>&nbsp;</td><td nowrap>" . blackhole_get_fatalities($blackhole_id) . " ship(s)</td></tr>";
    echo "          </table>";
    echo "        </td>";
    echo "      </tr>";
    echo "    </table>";
    echo "    </td>";
    echo "  </tr>";
    echo "</table>";
    echo "<br><br>";
}
Beispiel #5
0
function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    form_start("", "post", " enctype='multipart/form-data' ");
    form_file("Файл", "file");
    $caption = "Загрузить картинку";
    if ($act == "edit") {
        $caption = "Изменить картинку";
    }
    form_submit($caption, "submit");
    form_end();
    $upload = form();
    if (form_file_uploaded("file")) {
        $fname = $_FILES["file"]['name'];
        $ext = strtolower(fileext($fname));
        if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
            $o = "Данный тип файла не является картинкой";
            return $o;
        } else {
            if ($act == "add") {
                db_query("INSERT INTO images (link) VALUES ('')");
                $id = db_last_id();
            } else {
                @unlink(db_result(db_query("SELECT link FROM images WHERE id=%d", $id)));
            }
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images/edit/{$id}");
        }
    }
    if ($act == "add") {
        $o = $upload;
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    if ($act == 'edit') {
        $im = db_object_get("images", $id);
        $o .= "<img width=100px src={$im->link}><br>{$upload}";
    }
    return $o;
}
Beispiel #6
0
function edit_description($anomaly_id)
{
    assert(is_numeric($anomaly_id));
    $anomaly = anomaly_get_anomaly($anomaly_id);
    print_subtitle("Edit description for " . $anomaly['name']);
    echo "  <center>\n";
    form_start();
    echo "  <input type=hidden name=aid value=" . encrypt_get_vars($anomaly_id) . ">\n";
    echo "  <input type=hidden name=cmd value=" . encrypt_get_vars("description2") . ">\n";
    echo "  <textarea name=ne_description maxlength=255 rows=10 cols=80>";
    echo px2html4edit($anomaly['description']);
    echo "</textarea>\n";
    echo "  <input name=submit type=submit value=\"Change Description\">\n";
    form_end();
    echo "  </center>\n";
    create_submenu(array("Back to planet view" => "anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($anomaly_id)));
}
Beispiel #7
0
function page_start($auto = 0)
{
    $o = "";
    $memo = db_result(db_query("SELECT memo FROM log  WHERE active_check ORDER BY id desc LIMIT 1"));
    form_start();
    form_input("memo", "memo", $memo);
    form_submit("submit", "submit");
    $o .= form();
    if (form_post("submit") || $auto) {
        if ($auto) {
            $_REQUEST['memo'] = $memo;
        }
        db_query("INSERT INTO log (time_time,active_check,memo) \r\n\t  VALUES(%d,true,'%s')", time(), form_post("memo"));
        $o .= "<br>submitted";
        redir("report");
    }
    return $o;
}
Beispiel #8
0
<?php

require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
section_subhead('New hint');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/new_hint');
form_textarea('Body');
$opts = db_query_fetch_all('
    SELECT
       ch.id,
       ch.title,
       ca.title AS category
    FROM challenges AS ch
    LEFT JOIN categories AS ca ON ca.id = ch.category
    ORDER BY ca.title, ch.title');
form_select($opts, 'Challenge', 'id', array_get($_GET, 'id', 0), 'title', 'category');
form_input_checkbox('Visible');
form_hidden('action', 'new');
form_button_submit('Create hint');
form_end();
foot();
Beispiel #9
0
    <th>Hint</th>
    <th>Manage</th>
  </tr>
</thead>
<tbody>
';
$hints = db_select_all('hints', array('id', 'added', 'body'), array('challenge' => $_GET['id']));
foreach ($hints as $hint) {
    echo '
  <tr>
      <td>', date_time($hint['added']), '</td>
      <td>', htmlspecialchars($hint['body']), '</td>
      <td><a href="edit_hint.php?id=', htmlspecialchars(short_description($hint['id'], 100)), '" class="btn btn-xs btn-primary">Edit</a></td>
  </tr>
  ';
}
echo '
</tbody>
</table>

<a href="new_hint.php?id=', htmlspecialchars($_GET['id']), '" class="btn btn-sm btn-warning">Add a new hint</a>
';
section_subhead('Delete challenge: ' . $challenge['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_challenge');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! This will also delete all submissions, all hints and all files associated with challenge!');
form_button_submit('Delete challenge', 'danger');
form_end();
foot();
Beispiel #10
0
<?php

require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
$category = db_select_one('categories', array('*'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_text('Title', $category['title']);
form_textarea('Description', $category['description']);
form_input_checkbox('Exposed', $category['exposed']);
form_input_text('Available from', date_time($category['available_from']));
form_input_text('Available until', date_time($category['available_until']));
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! This will delete all challenges under this category, as well as all submissions, files, and hints related those challenges!');
form_button_submit('Delete category', 'danger');
form_end();
foot();
function mactrack_site_edit()
{
    global $fields_mactrack_site_edit;
    /* ================= input validation ================= */
    get_filter_request_var('site_id');
    /* ==================================================== */
    display_output_messages();
    if (!isempty_request_var('site_id')) {
        $site = db_fetch_row('SELECT * FROM mac_track_sites WHERE site_id=' . get_request_var('site_id'));
        $header_label = __('MacTrack Site [edit: %s]', $site['site_name']);
    } else {
        $header_label = __('MacTrack Site [new]');
    }
    form_start('mactrack_sites.php');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_mactrack_site_edit, isset($site) ? $site : array())));
    html_end_box();
    form_save_button('mactrack_sites.php', 'return', 'site_id');
}
Beispiel #12
0
function template()
{
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate");
    $filter_array = array();
    /* search field: filter (searches template name) */
    if (isset_get_var("search_filter")) {
        $filter_array["template_name"] = get_get_var("search_filter");
    }
    /* get a list of all data templates on this page */
    $data_templates = api_data_template_list($filter_array);
    /* get a list of data input types for display in the data sources list */
    $data_input_types = api_data_source_input_type_list();
    form_start("data_templates.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Data Templates") . "</strong>", "data_templates.php?action=edit");
    html_header_checkbox(array(_("Template Name"), _("Data Input Type"), _("Status")), $box_id);
    $i = 0;
    if (sizeof($data_templates) > 0) {
        foreach ($data_templates as $data_template) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" href="data_templates.php?action=edit&id=<?php 
            echo $data_template["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $data_template["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $data_template["template_name"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $data_input_types[$data_template["data_input_type"]];
            ?>
				</td>
				<td>
					<?php 
            if ($data_template["active"] == "1") {
                echo _("Active");
            } else {
                echo _("Disabled");
            }
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' title="<?php 
            echo $data_template["template_name"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No data templates found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NO_ICON);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "data_template_list");
    form_end();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
<?php

require '../include/mellivora.inc.php';
prefer_ssl();
head('Two-factor authentication required');
section_head('Two-factor authentication required');
form_start('actions/two_factor_auth');
form_input_text('Code', false, array('autocomplete' => 'off', 'autofocus' => true));
form_hidden('action', 'authenticate');
form_button_submit('Authenticate');
form_end();
foot();
                form_stop("dodaj");
                if (!empty($_POST['hala']) && !empty($_POST['nazwa_pk'])) {
                    dodaj_polke();
                }
                break;
            case 'dodaj_hale':
                form_start("index.php?action=dodaj_hale", "post");
                $form = form_admin_doadaj_hale();
                form_wyswietl($form);
                form_spawdz($form);
                form_stop("dodaj");
                if (!empty($_POST['nazwa_hala'])) {
                    dodaj_hale();
                }
                break;
            default:
                break;
        }
    }
} else {
    echo '<nav>&nbsp; </nav> <div id="tresc">';
    form_start("index.php", "post");
    $form = logowanie();
    form_wyswietl($form);
    form_stop("zaloguj");
}
// form_start("index.php?action=szukaj","post");
// $form=form_admin_doadaj_uzytkownika();
// form_wyswietl($form);
// form_stop("dodaj");
szablon_bottom();
Beispiel #15
0
function mactrack_snmp_edit()
{
    global $config, $fields_mactrack_snmp_edit;
    include_once $config['base_path'] . '/plugins/mactrack/lib/mactrack_functions.php';
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('page');
    /* ==================================================== */
    /* clean up rule name */
    if (isset_request_var('name')) {
        set_request_var('name', sanitize_search_string(get_request_var('name')));
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value('page', 'sess_mactrack_edit_current_page', '1');
    load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
    /* display the mactrack snmp option set */
    $snmp_group = array();
    if (!isempty_request_var('id')) {
        $snmp_group = db_fetch_row_prepared('SELECT * FROM mac_track_snmp where id = ?', array(get_request_var('id')));
        $header_label = __('SNMP Option Set [edit: %s]', $snmp_group['name']);
    } else {
        $header_label = __('SNMP Option Set [new]');
    }
    form_start('mactrack_snmp.php', 'mactrack_snmp_group');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_mactrack_snmp_edit, $snmp_group)));
    html_end_box();
    form_hidden_box('id', isset_request_var('id') ? get_request_var('id') : '0', '');
    form_hidden_box('save_component_mactrack_snmp', '1', '');
    if (!isempty_request_var('id')) {
        $items = db_fetch_assoc_prepared('SELECT * FROM mac_track_snmp_items WHERE snmp_id= ? ORDER BY sequence', array(get_request_var('id')));
        html_start_box(__('Mactrack SNMP Options'), '100%', '', '3', 'center', 'mactrack_snmp.php?action=item_edit&id=' . get_request_var('id'));
        print "<tr class='tableHeader'>";
        DrawMatrixHeaderItem(__('Item'), '', 1);
        DrawMatrixHeaderItem(__('Version'), '', 1);
        DrawMatrixHeaderItem(__('Community'), '', 1);
        DrawMatrixHeaderItem(__('Port'), '', 1);
        DrawMatrixHeaderItem(__('Timeout'), '', 1);
        DrawMatrixHeaderItem(__('Retries'), '', 1);
        DrawMatrixHeaderItem(__('Max OIDs'), '', 1);
        DrawMatrixHeaderItem(__('Username'), '', 1);
        DrawMatrixHeaderItem(__('Auth Proto'), '', 1);
        DrawMatrixHeaderItem(__('Priv Proto'), '', 1);
        DrawMatrixHeaderItem(__('Actions'), '', 1);
        print '</tr>';
        $i = 1;
        if (sizeof($items)) {
            foreach ($items as $item) {
                form_alternate_row();
                $form_data = '<td><a class="linkEditMain" href="' . htmlspecialchars('mactrack_snmp.php?action=item_edit&item_id=' . $item['id'] . '&id=' . $item['snmp_id']) . '">Item#' . $i . '</a></td>';
                $form_data .= '<td>' . $item['snmp_version'] . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? __('N/A') : $item['snmp_readstring']) . '</td>';
                $form_data .= '<td>' . $item['snmp_port'] . '</td>';
                $form_data .= '<td>' . $item['snmp_timeout'] . '</td>';
                $form_data .= '<td>' . $item['snmp_retries'] . '</td>';
                $form_data .= '<td>' . $item['max_oids'] . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_username'] : __('N/A')) . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_auth_protocol'] : __('N/A')) . '</td>';
                $form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_priv_protocol'] : __('N/A')) . '</td>';
                $form_data .= '<td class="right">' . ($i < sizeof($items) ? '<a class="remover fa fa-caret-down moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_movedown&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>') . ($i > 1 ? '<a class="remover fa fa-caret-up moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_moveup&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>');
                $form_data .= '<a class="delete deleteMarker fa fa-remove" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_remove&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' . '</td></tr>';
                print $form_data;
                $i++;
            }
        } else {
            print '<tr><td colspan="5"><em>' . __('No SNMP Items') . '</em></td></tr>';
        }
        html_end_box();
    }
    form_save_button('mactrack_snmp.php');
}
Beispiel #16
0
function webseer_urls($header_label)
{
    global $assoc_actions, $item_rows;
    /* ================= input validation and session storage ================= */
    $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'associated' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string')));
    validate_store_request_vars($filters, 'sess_maint_ws');
    /* ================= input validation ================= */
    /* if the number of rows is -1, set it to the default */
    if (get_request_var('rows') == '-1') {
        $rows = read_config_option('num_rows_table');
    } else {
        $rows = get_request_var('rows');
    }
    ?>
	<script type='text/javascript'>
	function applyFilter() {
		strURL  = 'maint.php?tab=webseer&action=edit&id=<?php 
    print get_request_var('id');
    ?>
';
		strURL += '&rows=' + $('#rows').val();
		strURL += '&associated=' + $('#associated').is(':checked');
		strURL += '&filter=' + $('#filter').val();
		strURL += '&header=false';
		loadPageNoHeader(strURL);
	}

	function clearFilter() {
		strURL = 'maint.php?tab=webseer&action=edit&id=<?php 
    print get_request_var('id');
    ?>
&clear=true&header=false';
		loadPageNoHeader(strURL);
	}
	</script>
	<?php 
    html_start_box(__('Associated Web URL\'s ') . htmlspecialchars($header_label), '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
		<form name='form_devices' method='post' action='maint.php?action=edit&tab=webseer'>
			<table class='filterTable'>
				<tr>
					<td>
						<?php 
    print __('Search');
    ?>
					</td>
					<td>
						<input type='text' id='filter' size='25' value='<?php 
    print htmlspecialchars(get_request_var('filter'));
    ?>
' onChange='applyFilter()'>
					</td>
					<td>
						<?php 
    print __('Rules');
    ?>
					</td>
					<td>
						<select id='rows' onChange='applyFilter()'>
							<option value='-1'<?php 
    if (get_request_var('rows') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Default');
    ?>
</option>
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var('rows') == $key) {
                print ' selected';
            }
            print '>' . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<input type='checkbox' id='associated' onChange='applyFilter()' <?php 
    print get_request_var('associated') == 'true' || get_request_var('associated') == 'on' ? 'checked' : '';
    ?>
>
					</td>
					<td>
						<label for='associated'><?php 
    print __('Associated');
    ?>
</label>
					</td>
					<td>
						<input type='button' value='<?php 
    print __('Go');
    ?>
' onClick='applyFilter()' title='<?php 
    print __('Set/Refresh Filters');
    ?>
'>
					</td>
					<td>
						<input type='button' name='clear' value='<?php 
    print __('Clear');
    ?>
' onClick='clearFilter()' title='<?php 
    print __('Clear Filters');
    ?>
'>
					</td>
				</tr>
			</table>
			<input type='hidden' name='page' value='<?php 
    print get_request_var('page');
    ?>
'>
			<input type='hidden' name='id' value='<?php 
    print get_request_var('id');
    ?>
'>
		</form>
		</td>
	</tr>
	<?php 
    html_end_box();
    /* form the 'where' clause for our main sql query */
    if (strlen(get_request_var('filter'))) {
        $sql_where = "WHERE ((u.url LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.display_name LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.ip LIKE '%" . get_request_var('filter') . "%'))";
    } else {
        $sql_where = '';
    }
    if (get_request_var('associated') == 'false') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (pmh.type=2 OR pmh.type IS NULL)';
    } else {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' pmh.type=2 AND pmh.schedule=' . get_request_var('id');
    }
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where}");
    $sql_query = "SELECT u.*, pmh.host AS associated, pmh.type AS maint_type\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where} \n\t\tLIMIT " . $rows * (get_request_var('page') - 1) . ',' . $rows;
    $urls = db_fetch_assoc($sql_query);
    $nav = html_nav_bar('notify_lists.php?action=edit&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 13, __('Lists'), 'page', 'main');
    form_start('maint.php', 'chk');
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array(__('Description'), __('ID'), __('Associated Schedules'), __('Enabled'), __('Hostname'), __('URL'));
    html_header_checkbox($display_text);
    if (sizeof($urls)) {
        foreach ($urls as $url) {
            form_alternate_row('line' . $url['id']);
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['display_name'])) : htmlspecialchars($url['display_name']), $url['id'], 250);
            form_selectable_cell(round($url['id'], 2), $url['id']);
            if ($url['associated'] != '' && $url['maint_type'] == '2') {
                form_selectable_cell('<span class="deviceUp">' . __('Current Schedule') . '</span>', $url['id']);
            } else {
                if (sizeof($lists = db_fetch_assoc('SELECT name FROM plugin_maint_schedules INNER JOIN plugin_maint_hosts ON plugin_maint_schedules.id=plugin_maint_hosts.schedule WHERE type=2 AND host=' . $url['id']))) {
                    $names = '';
                    foreach ($lists['name'] as $name) {
                        $names .= (strlen($names) ? ', ' : '') . "<span class='deviceRecovering'>{$name}</span>";
                    }
                    form_selectable_cell($names, $url['id']);
                } else {
                    form_selectable_cell('<span class="deviceUnknown">' . __('No Schedules') . '</span>', $url['id']);
                }
            }
            form_selectable_cell($url['enabled'] == 'on' ? __('Enabled') : __('Disabled'), $url['id']);
            if (empty($url['ip'])) {
                $url['ip'] = __('USING DNS');
            }
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", '<i>' . htmlspecialchars($url['ip'])) . '</i>' : '<i>' . htmlspecialchars($url['ip']) . '</i>', $url['id']);
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['url'])) : htmlspecialchars($url['url']), $url['id']);
            form_checkbox_cell($url['display_name'], $url['id']);
            form_end_row();
        }
    } else {
        print "<tr><td><em>" . __('No Associated WebSeer URL\'s Found') . "</em></td></tr>";
    }
    html_end_box(false);
    if (sizeof($urls)) {
        print $nav;
    }
    form_hidden_box('id', get_request_var('id'), '');
    form_hidden_box('save_webseer', '1', '');
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($assoc_actions);
    form_end();
}
function item_edit()
{
    global $colors;
    if (!empty($_GET["id"])) {
        $graph_template_item = db_fetch_row("select * from graph_template_item where id=" . $_GET["id"]);
    }
    /* by default, select the LAST DS chosen to make everyone's lives easier */
    $default = db_fetch_row("select data_template_item_id from graph_template_item where graph_template_id=" . $_GET["graph_template_id"] . " order by sequence DESC");
    if (sizeof($default) > 0) {
        $graph_template_item["data_template_item_id"] = $default["data_template_item_id"];
    } else {
        $graph_template_item["data_template_item_id"] = 0;
    }
    form_start("graph_templates_items.php", "form_graph_template");
    /* ==================== Box: Graph Item ==================== */
    html_start_box("<strong>" . _("Graph Item") . "</strong> [" . _("Graph Template: ") . db_fetch_cell("select template_name from graph_template where id=" . $_GET["graph_template_id"]) . "]", "98%", $colors["header_background"], "3", "center", "");
    _graph_item_field__data_template_item_id("data_template_item_id", isset($graph_template_item["data_template_item_id"]) ? $graph_template_item["data_template_item_id"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__color("color", isset($graph_template_item["color"]) ? $graph_template_item["color"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__graph_item_type("graph_item_type", isset($graph_template_item["graph_item_type"]) ? $graph_template_item["graph_item_type"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__consolidation_function("consolidation_function", isset($graph_template_item["consolidation_function"]) ? $graph_template_item["consolidation_function"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__cdef("cdef", isset($graph_template_item["cdef"]) ? $graph_template_item["cdef"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__gprint_format("gprint_format", isset($graph_template_item["gprint_format"]) ? $graph_template_item["gprint_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__legend_value("legend_value", isset($graph_template_item["legend_value"]) ? $graph_template_item["legend_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__legend_format("legend_format", isset($graph_template_item["legend_format"]) ? $graph_template_item["legend_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _graph_item_field__hard_return("hard_return", isset($graph_template_item["hard_return"]) ? $graph_template_item["hard_return"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    html_end_box();
    form_hidden_box("graph_template_item_id", !empty($graph_template_item["id"]) ? $graph_template_item["id"] : "0", "");
    form_hidden_box("graph_template_id", $_GET["graph_template_id"], "0");
    form_hidden_box("save_component_item", "1", "");
    form_save_button("graph_templates.php?action=edit&id=" . $_GET["graph_template_id"]);
}
Beispiel #18
0
function tree_item_edit()
{
    $_graph_tree_item_id = get_get_var_number("id");
    $_graph_tree_id = get_get_var_number("tree_id");
    if (isset_get_var("parent_id")) {
        $_graph_tree_item_parent_id = get_get_var_number("parent_id");
    }
    if (empty($_graph_tree_item_id)) {
        $header_label = "[new]";
    } else {
        $graph_tree_item = api_graph_tree_item_get($_graph_tree_item_id);
        $header_label = "[edit]";
    }
    $tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='" . $_GET["tree_id"] . "'");
    form_start("graph_trees_items.php", "form_graph_tree_item");
    html_start_box("<strong>Tree Items</strong> {$header_label}");
    _graph_tree_item_field__parent_item_id($_graph_tree_id, "parent_item_id", isset($_graph_tree_item_parent_id) ? $_graph_tree_item_parent_id : api_graph_tree_item_parent_get($_graph_tree_item_id), empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__item_type("item_type", isset($graph_tree_item) ? $graph_tree_item["item_type"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__title("item_value_title", isset($graph_tree_item) ? $graph_tree_item["item_value"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__sort_children_type("sort_children_type", isset($graph_tree_item) ? $graph_tree_item["sort_children_type"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__propagate_changes("propagate_changes", "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__graph("item_value_graph", isset($graph_tree_item) ? $graph_tree_item["item_value"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__device("item_value_device", isset($graph_tree_item) ? $graph_tree_item["item_value"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__device_grouping_type("device_grouping_type", isset($graph_tree_item) ? $graph_tree_item["device_grouping_type"] : "", empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    _graph_tree_item_field__item_type_js_update(isset($graph_tree_item) ? $graph_tree_item["item_type"] : TREE_ITEM_TYPE_HEADER, empty($_graph_tree_item_id) ? 0 : $_graph_tree_item_id);
    form_hidden_box("id", $_graph_tree_item_id, "");
    form_hidden_box("graph_tree_id", $_graph_tree_id, "");
    form_hidden_box("action_post", "graph_tree_item_edit");
    html_end_box();
    form_save_button("graph_trees.php?action=edit&id=" . $_graph_tree_id);
}
Beispiel #19
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
section_subhead('New user type');
message_inline_blue('User types are not required. You can add them if you wish to group contestants and give them separate scoreboards. If not, everyone will be in the same group.');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/new_user_type');
form_input_text('Title');
form_textarea('Description');
form_hidden('action', 'new');
form_button_submit('Create new user type');
form_end();
foot();
Beispiel #20
0
function graph()
{
    $current_page = get_get_var_number("page", "1");
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "change_graph_template" => "Change Graph Template", "change_host" => "Change Host", "convert_graph_template" => "Convert to Graph Template", "place_tree" => "Place on Tree");
    $filter_array = array();
    /* search field: device template */
    if (isset_get_var("search_device")) {
        $filter_array["host_id"] = get_get_var("search_device");
    }
    /* search field: filter (searches data source name) */
    if (isset_get_var("search_filter")) {
        $filter_array["filter"] = array("title_cache|title" => get_get_var("search_filter"));
    }
    /* get a list of all graphs on this page */
    $graphs = api_graph_list($filter_array, $current_page, read_config_option("num_rows_data_source"));
    /* get the total number of graphs on all pages */
    $total_rows = api_graph_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_device", "search_filter"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_graph"), $total_rows, "graphs.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    form_start("graphs.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Graphs") . "</strong>", "graphs.php?action=edit", $url_page_select);
    html_header_checkbox(array(_("Graph Title"), _("Template Name"), _("Size")), $box_id);
    $i = 0;
    if (sizeof($graphs) > 0) {
        foreach ($graphs as $graph) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" href="graphs.php?action=edit&id=<?php 
            echo $graph["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $graph["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $graph["title_cache"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo empty($graph["template_name"]) ? "<em>" . _("None") . "</em>" : $graph["template_name"];
            ?>
				</td>
				<td>
					<?php 
            echo $graph["height"];
            ?>
x<?php 
            echo $graph["width"];
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' title="<?php 
            echo $graph["title_cache"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No graphs found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "graph_list");
    form_end();
    /* pre-cache the device list since we need it in more than one place below */
    $device_list = array_rekey(api_device_list(), "id", "description");
    /* fill in the list of available devices for the search dropdown */
    $search_devices = array();
    $search_devices["-1"] = "Any";
    $search_devices["0"] = "None";
    $search_devices += $device_list;
    /* fill in the list of available devices for the change host dropdown */
    $change_host_list = array();
    $change_host_list["0"] = "None";
    $change_host_list += $device_list;
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Graph');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Graph');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {
			_elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $search_devices, isset_get_var("search_device") ? get_get_var("search_device") : "-1");
    ?>

			_elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
			_elm_ht_input.size = '30';

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

			action_area_update_header_caption(box_id, 'Search');
			action_area_update_submit_caption(box_id, 'Search');
		}else if (type == 'change_host') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to change the host for these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			_elm_dt_input = action_area_generate_select('box-' + box_id + '-change_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $change_host_list, "0");
    ?>

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'New Device', true, true));

			action_area_update_header_caption(box_id, 'Change Host');
			action_area_update_submit_caption(box_id, 'Change');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
    ' . ($search_for ? 'WHERE u.team_name LIKE :search_for_team_name OR u.email LIKE :search_for_email' : '') . (verifySA() ? '' : 'WHERE u.instanceID =' . $_SESSION["IID"]) . '
    GROUP BY u.id
    ORDER BY u.team_name ASC
    LIMIT ' . $from . ', ' . $results_per_page, $values);
pager(CONFIG_SITE_ADMIN_URL . 'list_users/', count($users), $results_per_page, $from);
foreach ($users as $user) {
    echo '
    <tr>
        <td>
            <a href="', CONFIG_SITE_URL, 'user?id=', htmlspecialchars($user['id']), '">', htmlspecialchars($user['team_name']), '</a>
        </td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'new_email.php?to=', htmlspecialchars($user['email']), '">', htmlspecialchars($user['email']), '</a></td>
        <td>', date_time($user['added']), '</td>
        <td>', user_class_name($user['class']), '</td>
        <td>', $user['enabled'] ? 'Yes' : 'No', '</td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?id=', htmlspecialchars($user['id']), '">', number_format($user['num_ips']), '</a></td>
        <td>
            <a href="', CONFIG_SITE_ADMIN_URL, 'edit_user.php?id=', htmlspecialchars($user['id']), '" class="btn btn-xs btn-primary">Edit</a>
        </td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
     ';
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/export_csv');
form_hidden('action', 'export');
form_button_submit('Export to CSV', 'danger');
form_end();
foot();
Beispiel #22
0
validate_id($_GET['id']);
$user = db_select_one('users', array('team_name', 'email', 'enabled', 'competing', 'country_id'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit user: '******'team_name']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_text('Email', $user['email']);
form_input_text('Team name', $user['team_name']);
$opts = db_query_fetch_all('SELECT * FROM countries ORDER BY country_name ASC');
form_select($opts, 'Country', 'id', $user['country_id'], 'country_name');
form_input_checkbox('Enabled', $user['enabled']);
form_input_checkbox('Competing', $user['competing']);
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Reset password');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_checkbox('Reset confirmation');
form_hidden('action', 'reset_password');
form_hidden('id', $_GET['id']);
form_button_submit('Reset password', 'warning');
form_end();
section_subhead('Delete user');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_user');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! This will delete all submissions made by this user!');
form_button_submit('Delete user', 'danger');
foot();
Beispiel #23
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
section_subhead('Search');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/search');
form_input_text('Search for');
$opts[] = array('id' => 'users', 'name' => 'Users');
$opts[] = array('id' => 'ip_log', 'name' => 'IP log');
form_select($opts, 'Search in', 'id', 'users', 'name');
form_button_submit('Search');
form_xsrf_token();
form_end();
foot();
Beispiel #24
0
function gprint_edit() {
	$_gprint_preset_id = get_get_var_number("id");

	if (empty($_gprint_preset_id)) {
		$header_label = "[new]";
	}else{
		$gprint = api_data_preset_gprint_get($_gprint_preset_id);

		$header_label = "[edit: " . $gprint["name"] . "]";
	}

	form_start("presets_gprint.php", "form_gprint");

	/* ==================== Box: Colors ==================== */

	html_start_box("<strong>" . _("GPRINT Presets") . "</strong> $header_label");
	_data_preset_gprint__name("name", (isset($gprint["name"]) ? $gprint["name"] : ""), (isset($gprint["id"]) ? $gprint["id"] : "0"));
	_data_preset_gprint__gprint_text("gprint_text", (isset($gprint["gprint_text"]) ? $gprint["gprint_text"] : ""), (isset($gprint["id"]) ? $gprint["id"] : "0"));
	html_end_box();

	form_hidden_box("preset_gprint_id", $_gprint_preset_id);
	form_hidden_box("action_post", "gprint_preset_edit");

	form_save_button("presets.php?action=view_gprint", "save_gprint");
}
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
validate_id($_GET['id']);
$rule = db_select_one('restrict_email', array('rule', 'enabled', 'white', 'priority'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit signup rule');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_restrict_email');
form_input_text('Rule', $rule['rule']);
form_input_text('Priority', $rule['priority']);
form_input_checkbox('Whitelist', $rule['white']);
form_input_checkbox('Enabled', $rule['enabled']);
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete rule');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_restrict_email');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
form_button_submit('Delete rule', 'danger');
form_end();
foot();
Beispiel #26
0
function thold_add_select_host()
{
    global $config;
    $host_id = get_filter_request_var('host_id');
    $local_graph_id = get_filter_request_var('local_graph_id');
    $data_template_rrd_id = get_filter_request_var('data_template_rrd_id');
    $hosts = get_allowed_devices();
    top_header();
    form_start('thold.php?action=save', 'tholdform');
    html_start_box(__('Threshold Creation Wizard'), '50%', '', '3', 'center', '');
    if ($host_id == '') {
        print '<tr><td class="center">' . __('Please select a Device') . '</td></tr>';
    } else {
        if ($local_graph_id == '') {
            print '<tr><td class="center">' . __('Please select a Graph') . '</td></tr>';
        } else {
            if ($data_template_rrd_id == '') {
                print '<tr><td class="center">' . __('Please select a Data Source') . '</td></tr>';
            } else {
                print '<tr><td class="center">' . __('Please press \'Create\' to activate your Threshold') . '</td></tr>';
            }
        }
    }
    html_end_box();
    html_start_box('', '50%', '', '3', 'center', '');
    /* display the host dropdown */
    ?>
	<tr><td><table class='filterTable' align='center'>
		<tr>
			<?php 
    print html_host_filter(get_request_var('host_id'));
    ?>
		</tr><?php 
    if ($host_id != '') {
        $graphs = get_allowed_graphs('gl.host_id=' . $host_id);
        ?>
		<tr>
			<td>
				<?php 
        print __('Graph');
        ?>
			</td>
			<td>
				<select id='local_graph_id' name='local_graph_id' onChange='applyFilter("graph")'>
					<option value=''></option><?php 
        foreach ($graphs as $row) {
            echo "<option value='" . $row['local_graph_id'] . "'" . ($row['local_graph_id'] == $local_graph_id ? ' selected' : '') . '>' . htmlspecialchars($row['title_cache'], ENT_QUOTES) . '</option>';
        }
        ?>
				</select>
			</td>
		</tr><?php 
    } else {
        ?>
		<tr>
			<td>
				<input type='hidden' id='local_graph_id' name='local_graph_id' value=''>
			</td>
		</tr><?php 
    }
    if ($local_graph_id != '') {
        $dt_sql = 'SELECT DISTINCT dtr.local_data_id
			FROM data_template_rrd AS dtr
			LEFT JOIN graph_templates_item AS gti
			ON gti.task_item_id=dtr.id
			LEFT JOIN graph_local AS gl
			ON gl.id=gti.local_graph_id
			WHERE gl.id = ' . $local_graph_id;
        $local_data_id = db_fetch_cell($dt_sql);
        $dss = db_fetch_assoc('SELECT DISTINCT id, data_source_name
			FROM data_template_rrd
			WHERE local_data_id IN (' . $dt_sql . ') ORDER BY data_source_name');
        /* show the data source options */
        ?>
		<tr>
			<td>
				<?php 
        print __('Data Source');
        ?>
			</td>
			<td>
				<input type='hidden' id='local_data_id' name='local_data_id' value='<?php 
        print $local_data_id;
        ?>
'>
				<select id='data_template_rrd_id' name='data_template_rrd_id' onChange='applyFilter("ds")'>
					<option value=''></option><?php 
        foreach ($dss as $row) {
            echo "<option value='" . $row['id'] . "'" . ($row['id'] == $data_template_rrd_id ? ' selected' : '') . '>' . htmlspecialchars($row['data_source_name'], ENT_QUOTES) . '</option>';
        }
        ?>
				</select>
			</td>
		</tr></table></td></tr><?php 
    } else {
        ?>
		<tr>
			<td>
				<input type='hidden' id='data_template_rrd_id' name='data_template_rrd_id' value=''>
			</td>
		</tr></table></td></tr><?php 
    }
    if ($data_template_rrd_id != '') {
        echo "<tr><td class='center' colspan='2'><input type='hidden' name='save' id='save' value='save'><input id='go' type='button' value='" . __('Create') . "' title='" . __('Create Threshold') . "'></td></tr>";
    } else {
        echo "<tr><td class='center' colspan='2'></td></tr>";
    }
    html_end_box();
    form_end();
    html_start_box('', '50%', '', '3', 'center', '');
    if ($local_graph_id != '') {
        print "<tr><td style='text-align:center'><img id='graphi' src='../../graph_image.php?local_graph_id={$local_graph_id}&rra_id=0'></td></tr>";
    }
    html_end_box();
    ?>
	<script type='text/javascript'>

	function applyFilter(target) {
		strURL = 'thold.php?action=add&header=false&host_id=' + $('#host_id').val();
		if (target != 'host_id') {
			strURL += '&local_graph_id=' + $('#local_graph_id').val();
		}
		if (target == 'ds') {
			strURL += '&data_template_rrd_id=' + $('#data_template_rrd_id').val();
		}
		loadPageNoHeader(strURL);
	}

	$(function() {
		$('#go').button().click(function() {
            strURL = $('#tholdform').attr('action');
            json   = $('input, select').serializeObject();
            $.post(strURL, json).done(function(data) {
                $('#main').html(data);
                applySkin();
                window.scrollTo(0, 0);
            });
		});
	});

	</script>
	<?php 
}
Beispiel #27
0
function package() {
	$menu_items = array(
		"remove" => "Remove",
		"duplicate" => "Duplicate"
		);

	$filter_array = array();

	/* search field: filter (searches package name) */
	if (isset_get_var("search_filter")) {
		$filter_array["name"] = get_get_var("search_filter");
	}

	/* get a list of all packages on this page */
	$packages = api_package_list($filter_array);

	form_start("packages.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Template Packages") . "</strong>", "packages.php?action=new");
	html_header_checkbox(array(_("Name"), _("Author"), _("Category")), $box_id);

	$i = 0;
	if (sizeof($packages) > 0) {
		foreach ($packages as $package) {
			?>
			<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')">
				<td class="title">
					<a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" href="packages.php?action=view&id=<?php echo $package["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $package["id"];?>"><?php echo html_highlight_words(get_get_var("search_filter"), $package["name"]);?></span></a>
				</td>
				<td>
					Ian Berry
				</td>
				<td>
					<?php echo $package["category"];?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' title="<?php echo $package["name"];?>">
				</td>
			</tr>
			<?php
		}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				No template packages found.
			</td>
		</tr>
		<?php
	}
	html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NONE);
	html_end_box(false);

	//html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_hidden_box("action_post", "package_list");
	form_end();

	echo "<br />\n";

	form_start("packages.php", "import_package", true);

	html_start_box("<strong>" . _("Import Package") . "</strong>");

	_package_import_field__file("import_package_file");
	_package_import_field__text("import_package_text");

	?>
	<tr>
		<td style="border-top: 1px solid #b5b5b5; padding: 1px;" colspan="2">
			<table width="100%" cellpadding="2" cellspacing="0">
				<tr>
					<td align="right">
						&nbsp;<input type="image" src="<?php echo html_get_theme_images_path('button_import.gif');?>" alt="<?php echo _('Import');?>" name="package_import" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php

	html_end_box();

	form_hidden_box("action", "save");
	form_hidden_box("action_post", "package_import");
	form_end();

	//print_a(htmlspecialchars(package_export("1")));

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php
}
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
head('Site management');
menu_management();
section_subhead('Edit dynamic menu item');
$menu_item = db_select_one('dynamic_menu', array('*'), array('id' => $_GET['id']));
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_dynamic_menu_item');
form_input_text('Title', $menu_item['title']);
form_input_text('Permalink', $menu_item['permalink']);
dynamic_visibility_select($menu_item['visibility']);
$pages = db_select_all('dynamic_pages', array('id', 'title'));
array_unshift($pages, array('id' => 0, 'title' => '--- No internal link ---'));
form_select($pages, 'Internal page', 'id', $menu_item['internal_page'], 'title');
user_class_select($menu_item['min_user_class']);
form_input_text('URL', $menu_item['url']);
form_input_text('Priority', $menu_item['priority']);
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete menu item');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_dynamic_menu_item');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
form_button_submit('Delete menu item', 'danger');
form_end();
foot();
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
$rule = db_select_one('instances', array('*'), array('id' => $_SESSION['IID']));
head('Site management');
menu_management();
section_subhead('Edit Instance Settings');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_settings');
echo '<div class="form-group">
      <label class="col-sm-2 control-label" for="rule">Registration Token</label>
      <div class="col-sm-10">
          <input id="rule" readonly name="rule" class="form-control" placeholder="Registration Token" value="', $rule['registrationToken'] != 0 ? $rule['registrationToken'] : 'Registration Tokens are not enabled.', '" type="text">
      </div>
    </div>';
form_hidden('action', 'edit');
echo $rule['registrationToken'] == 0 ? form_button_submit('Enable Registration Token') : form_button_submit('Disable Registration Token');
form_end();
foot();
function preset_show_all_presets($user_id)
{
    assert(is_numeric($user_id));
    echo "<table align=center widht=75%>\n";
    echo "  <tr class=wb>\n";
    echo "    <th>Preset name</th>\n";
    echo "    <th>Distance</th>\n";
    echo "    <th>Angle</th>\n";
    echo "    <th>&nbsp;</th>\n";
    echo "  </tr>\n";
    // Get all presets
    $result = sql_query("SELECT * FROM g_presets WHERE user_id=" . $user_id);
    while ($preset = sql_fetchrow($result)) {
        echo "  <tr class=bl>\n";
        echo "    <td>&nbsp;" . $preset['name'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $preset['distance'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $preset['angle'] . "&nbsp;</td>\n";
        echo "    <td>&nbsp;[ <a href=vesselpreset.php?cmd=" . encrypt_get_vars("delete") . "&uid=" . encrypt_get_vars($user_id) . "&pid=" . encrypt_get_vars($preset['id']) . ">Delete</a> ]&nbsp;</td>\n";
        echo "  </tr>\n";
    }
    // And add room to create a new one...
    echo "  <tr class=bl>\n";
    form_start();
    echo "    <input type=hidden name=cmd value=" . encrypt_get_vars("create") . ">\n";
    echo "    <input type=hidden name=uid value=" . encrypt_get_vars($user_id) . ">\n";
    echo "    <td><input type=text name=ne_name size=20 maxlength=20></td>\n";
    echo "    <td><input type=text name=ne_distance size=6 maxlength=6></td>\n";
    echo "    <td><input type=text name=ne_angle size=7 maxlength=7></td>\n";
    echo "    <td><input type=submit name=name=submit value=Add></td>\n";
    form_end();
    echo "  </tr>\n";
    echo "</table>\n";
}