Commit dbafbf6a authored by diesys's avatar diesys 🎈

working on submit.php for creating and managing tournaments

parent 815bb2c1
......@@ -68,7 +68,7 @@
<div class='btn-group mr-2' role='group' aria-label='2g'>
<form action="/pomelo/submit.php" method="post">
<input type="hidden" name="action" value="add">
<input type="hidden" name="action" value="create">
<div class="input-group input-padding">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Crea torneo</span>
......
......@@ -41,8 +41,6 @@
<span id='titolo'>
<h1 id='itolo'>singolo</h1>
<!-- <a href='admin.php' class='adminButton'> -->
<!-- <a href='#' onclick="$('#menu').collapse('toggle')" class='adminButton'> -->
<a href='#' id="admin_button" class='adminButton'>
<ion-icon id="admin_icon" size='large' name='add'></ion-icon>
</a>
......@@ -53,10 +51,9 @@
<h4>Partite</h4><br>
<!-- aggiungi risultato doppio -->
<form action="/pomelo/submit.php" method="post">
<!-- aggiungi risultato -->
<form action="/pomelo/submit.php?torneo=singolo" method="post">
<input type="hidden" name="action" value="update">
<input type="hidden" name="torneo" value="singolo">
<div class="input-group input-padding">
<select class="custom-select" name="giocatore1" required>
<option value="" disabled selected>Giocat. 1</option>
......@@ -108,12 +105,11 @@
<option value='tommaso'>tommaso</option>
<option value='trespo'>trespo</option>
<!-- <?php echo shell_exec('./pomelo.py -g singolo --web 2>&1'); ?> -->
</select>
<div class="input-group-append">
<span class="input-group-text torneo-icon">
vs
vs
<!-- <ion-icon name="md-swap" size="large"></ion-icon> -->
</span>
</div>
......@@ -168,7 +164,6 @@
<option value='tommaso'>tommaso</option>
<option value='trespo'>trespo</option>
<!-- <?php echo shell_exec('./pomelo.py -g singolo --web 2>&1'); ?> -->
</select>
<select class="custom-select col-xs-3 col-md-2" id="inputGroupSelect01" name="esito" required>
......@@ -189,13 +184,13 @@
<br /><h4>Giocatori e squadre</h4><br>
<!-- elimina giocatore -->
<form action="/pomelo/submit.php" method="post">
<form action="/pomelo/submit.php?torneo=singolo" method="post">
<input type="hidden" name="action" value="delete">
<div class="input-group input-padding">
<div class="input-group-prepend">
<span class="input-group-text">elimina</span>
</div>
<select class="custom-select" name="giocatoreS">
<select class="custom-select" name="giocatore">
<option value="" disabled selected>Giocatore</option>
<option value='1'>1</option>
<option value='2'>2</option>
......@@ -256,7 +251,7 @@
</form>
<!-- aggiungi giocatore -->
<form action="/pomelo/submit.php" method="post">
<form action="/pomelo/submit.php?torneo=singolo" method="post">
<input type="hidden" name="action" value="add">
<div class="input-group input-padding">
<div class="input-group-prepend">
......
<?php header("Location: .?action=".$_POST['action']."&torneo=".$_POST["torneo"]); ?>
<?php //header("Location: .?action=".$_POST['action']."&torneo=".$_POST["torneo"]); ?>
<?php //header("Location: .?acon=".$_POST['action']."&torneo=".$_POST["torneo"]."&g1=".$_POST["giocatore1"]."&g2=".$_POST["giocatore2"]."&gS=".$_POST["giocatoreS"]."&gD=".$_POST["giocatoreD"]."&nG=".$_POST["nuovoGiocatore"]."&r=".$_POST["esito"]); ?>
<?php
......@@ -31,33 +31,55 @@
if (!($g1==$g2 and $g1!="")) {
if ($torneo and $g1 and $g2 and $esito> -1) {
$command = "./tornelo.py -u $torneo \"$g1\" \"$g2\" $esito 2>&1";
$command = "./pomelo.py $torneo -u \"$g1\" \"$g2\" $esito 2>&1";
$alert_msg = "Partita aggiunta al $torneo: \"$g1\" vs \"$g2\" ($esito)";
}
}
}
}
elseif($action == 'delete') {
if(isset($_POST["giocatoreS"])){
$torneo = 'singolo'; $giocatore = $_POST["giocatoreS"];
elseif($action == 'goto') {
if(isset($_POST["torneo"])) {
$torneo = $_POST["torneo"];
header('Location: ./r/'.$_POST["torneo"]);
}
}
elseif($action == 'create') {
if(isset($_POST["torneo"])) {
$torneo = $_POST["torneo"];
// check ALPHANUMERIC
// if (ctype_alnum($torneo) and $torneo != "") {
$command = "./pomelo.py -n \"".$_POST["torneo"]."\" 2>&1";
$alert_msg = "Creato un nuovo torneo: ".$_POST["torneo"];
// }
}
}
elseif(isset($_POST["giocatoreD"])) {
$torneo = 'doppio'; $giocatore = $_POST["giocatoreD"];
elseif($action == 'delete') {
if(isset($_POST["giocatore"])) {
$torneo = $_GET["torneo"]; // passed from the py tournament template
$giocatore = $_POST["giocatore"];
}
else {
$command = '';
$alert_msg = 'Qualche errore rimuovendo il giocatore!';
}
$command = "./tornelo.py -d $torneo \"$giocatore\" 2>&1";
$command = "./pomelo.py $torneo -d \"$giocatore\" 2>&1";
$alert_msg = "$giocatore. rimosso dal torneo \"$torneo\"";
echo $command;
}
elseif($action == 'add') {
if(isset($_POST["nuovoGiocatore"]) and isset($_POST["torneo"])) {
$torneo = $_POST["torneo"]; $giocatore = $_POST["nuovoGiocatore"];
$command = "./tornelo.py -a $torneo \"$giocatore\" 2>&1";
$alert_msg = "$giocatore. ora fa parte del torneo \"$torneo\"";
// check ALPHANUMERIC
// if (ctype_alnum($giocatore) and $giocatore != "") {
$command = "./pomelo.py $torneo -a \"$giocatore\" 2>&1";
$alert_msg = "$giocatore. ora fa parte del torneo \"$torneo\"";
// }
}
else {
$command = '';
......@@ -72,11 +94,11 @@
// print(shell_exec('whoami'));
echo ($command.'\n\n'.$alert_msg);
// echo ($command."\n".$alert_msg);
echo shell_exec($command);
// costruisce il nuovo index
echo shell_exec("./tornelo.py --gen-index 2>&1");
echo shell_exec("./pomelo.py \"".$torneo."\" --gen-index 2>&1");
// alert($alert_msg);
}
......
<!doctype html>
<html lang='it'>
<head>
<!-- Required meta tags -->
<title>Pomelo</title>
<meta charset='utf-8'>
<meta name='description' content='Pomelo is a self-hosted opensource tournament web-server and local script' />
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
<link rel='stylesheet' media='screen' href='https://fontlibrary.org/face/raleway' type='text/css'/>
<link rel='icon' href='/pomelo/img/favicon.png'>
<!-- Colors and bars -->
<!-- Chrome, Firefox OS and Opera -->
<meta name="theme-color" content="#ffffff" id="browserColor">
<!-- Windows Phone -->
<meta name="msapplication-navbutton-color" content="#ffffff" id="browserColorwp">
<!-- iOS Safari -->
<meta name="apple-mobile-web-app-status-bar-style" content="#ffffff" id="browserColorap">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name='HandheldFriendly' content='true' />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name='mobile-web-app-capable' content='yes'>
<!-- bootstrap -->
<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>
<!-- <script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script> -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script>
<script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script>
<script src='/pomelo/js/script.js'></script>
<link rel='stylesheet' href='/pomelo/css/main.css' />
</head>
<body>
<img id='logo' src='img/logo.gif' height='90px' width='90px' alt='Logo description' />
<span id='titolo'>
<h1 id='itolo'></h1>
<!-- <a href='admin.php' class='adminButton'> -->
<!-- <a href='#' onclick="$('#menu').collapse('toggle')" class='adminButton'> -->
<a href='#' id="admin_button" class='adminButton'>
<ion-icon id="admin_icon" size='large' name='add'></ion-icon>
</a>
</span>
<center>
<div id="menu" class="hidden">
<h4>Menu</h4><br>
</div>
</center>
<div id='content' class='container-fluid'>
<center>
<img id='qr' src='img/logo.gif' height='140px' width='140px' alt='logo' /><br>
<caption>Benvenuto su Pomelo!</caption><br>
<br>
<div class='mr-2' role='group' aria-label='1g'>
<div class='btn-group mr-2' role='group' aria-label='2g'>
<form action="/pomelo/submit.php" method="post">
<input type="hidden" name="action" value="create">
<div class="input-group input-padding">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Crea torneo</span>
</div>
<input class="form-control" name="torneo" placeholder="Nome">
<div class="input-group-append">
<button class="btn btn-outline-secondary bg-danger text-white bigFontButton"
type="submit">
<ion-icon size="large" name="md-add"></ion-icon>
</button>
</div>
</div>
</form>
</div>
<div class='btn-group mr-2' role='group' aria-label='2g'>
<form action="/pomelo/submit.php" method="post">
<input type="hidden" name="action" value="goto">
<div class="input-group input-padding">
<div class="input-group-prepend">
<span class="input-group-text">Mostra</span>
</div>
<select class="custom-select" name="torneo">
<option value="" disabled selected>Torneo</option>
{TORNEI}
</select>
<div class="input-group-append">
<button class="btn btn-outline-secondary bg-danger text-white bigFontButton" type="submit">
<ion-icon size="large" name="md-arrow-round-forward"></ion-icon>
</button>
</div>
</div>
</form>
</div>
</div>
</center>
</div>
<!-- ion-icons -->
<script src='https://unpkg.com/ionicons@4.5.5/dist/ionicons.js'></script>
</body>
</html>
\ No newline at end of file
......@@ -41,8 +41,6 @@
<span id='titolo'>
<h1 id='itolo'>{TORNEO}</h1>
<!-- <a href='admin.php' class='adminButton'> -->
<!-- <a href='#' onclick="$('#menu').collapse('toggle')" class='adminButton'> -->
<a href='#' id="admin_button" class='adminButton'>
<ion-icon id="admin_icon" size='large' name='add'></ion-icon>
</a>
......@@ -53,20 +51,18 @@
<h4>Partite</h4><br>
<!-- aggiungi risultato doppio -->
<form action="/pomelo/submit.php" method="post">
<!-- aggiungi risultato -->
<form action="/pomelo/submit.php?torneo={TORNEO}" method="post">
<input type="hidden" name="action" value="update">
<input type="hidden" name="torneo" value="singolo">
<div class="input-group input-padding">
<select class="custom-select" name="giocatore1" required>
<option value="" disabled selected>Giocat. 1</option>
{GIOCATORI}
<!-- <?php echo shell_exec('./pomelo.py -g singolo --web 2>&1'); ?> -->
</select>
<div class="input-group-append">
<span class="input-group-text torneo-icon">
vs
vs
<!-- <ion-icon name="md-swap" size="large"></ion-icon> -->
</span>
</div>
......@@ -74,7 +70,6 @@
<select class="custom-select" name="giocatore2" required>
<option value="" disabled selected>Giocat. 2</option>
{GIOCATORI}
<!-- <?php echo shell_exec('./pomelo.py -g singolo --web 2>&1'); ?> -->
</select>
<select class="custom-select col-xs-3 col-md-2" id="inputGroupSelect01" name="esito" required>
......@@ -95,13 +90,13 @@
<br /><h4>Giocatori e squadre</h4><br>
<!-- elimina giocatore -->
<form action="/pomelo/submit.php" method="post">
<form action="/pomelo/submit.php?torneo={TORNEO}" method="post">
<input type="hidden" name="action" value="delete">
<div class="input-group input-padding">
<div class="input-group-prepend">
<span class="input-group-text">elimina</span>
</div>
<select class="custom-select" name="giocatoreS">
<select class="custom-select" name="giocatore">
<option value="" disabled selected>Giocatore</option>
{GIOCATORI}
</select>
......@@ -115,7 +110,7 @@
</form>
<!-- aggiungi giocatore -->
<form action="/pomelo/submit.php" method="post">
<form action="/pomelo/submit.php?torneo={TORNEO}" method="post">
<input type="hidden" name="action" value="add">
<div class="input-group input-padding">
<div class="input-group-prepend">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment