Ejemplo n.º 1
0
function getAddServer()
{
    include 'func/hasPerm.php';
    if (hasPermission("addServer")) {
        if (isset($_POST['nazwa']) && ($_POST['nazwa'] == "" || $_POST['serv_id'] == "" || $_POST['serv_ip'] == "" || $_POST['port_q'] == "" || $_POST['port_r'] == "" || $_POST['pass_r'] == "")) {
            echo '
							<div class="alert alert-danger" role="alert">
							  Zostawiłeś puste pola! Spróbuj ponownie!
							</div>
					';
            echoForm();
        } else {
            if (!isset($_POST['nazwa'])) {
                echoForm();
            } else {
                if (is_numeric($_POST['port_q']) && is_numeric($_POST['port_r']) && ctype_alnum($_POST['nazwa']) && ctype_alnum($_POST['serv_id']) && ctype_alnum($_POST['pass_r']) && ip2long($_POST['serv_ip']) !== false) {
                    include '../config/mysql.php';
                    $sql = "INSERT INTO servers (server_id, nazwa, ip, port_query, port_rcon, pasw_rcon)\n\t\t\t\t\t\t\tVALUES ('" . $_POST['serv_id'] . "', '" . $_POST['nazwa'] . "', '" . $_POST['serv_ip'] . "',  '" . $_POST['port_q'] . "',  '" . $_POST['port_r'] . "',  '" . $_POST['pass_r'] . "')";
                    if ($conn->query($sql) === TRUE) {
                        echo '
										<div class="alert alert-success" role="alert">
										  Nowy serwer został dodany!<br>
										  Możesz teraz przystąpić do dodawania usług.
										</div>
								';
                        echo '<meta http-equiv="refresh" content="3; url=index.php?page=serverList" />';
                    } else {
                        echo '
										<div class="alert alert-danger" role="alert">
										  Wystąpił błąd podczas dodawania wpisu do bazy danych!
										</div>
								';
                    }
                } else {
                    echo '
							
							<div class="alert alert-danger" role="alert">
							  Porty muszą być cyframi, nazwa, ID serwera oraz hasło RCON nie może zawierać znaków specjalnych, lub IP jest nie poprawne.
							</div>
							
							';
                }
            }
        }
    } else {
        echo '
			
					<div class="alert alert-danger" role="alert">
					 	Nie masz uprawnień do dodawania serwerów!
					</div>
			
			';
    }
}
<?php

//printForm.php
//This prints a time edit request form
require '../includes/includeMeBlank.php';
$formNum = $_GET['num'];
echoForm($formNum);
function echoForm($num)
{
    $newNum = $num + 1;
    echo '
<table border="1" cellpadding="3" style="margin:auto; border-collapse:collapse;">	
	<tr>
		<th>Add/Remove</th><th>Clock In/Out</th><th>Time</th><th>Date</th>
	</tr>
		
	<tr>
		<td>
		<input name="' . $num . '[addRemove]" type="radio" value="1">
		Add
		<input name="' . $num . '[addRemove]" type="radio" value="0">
		Remove
		</td>
		<td>
		<input name="' . $num . '[inOut]" type="radio" value="1">
		In
		<input name="' . $num . '[inOut]" type="radio" value="0">
		Out
		</td>
		<td>
		<input type="text" id="time' . $num . '" name="' . $num . '[time]" value="' . date("h:00A") . '" size="8" class="inlineConfig{useMouseWheel:true}"/>