Ejemplo n.º 1
0
<?php

require "logic/connect.php";
if (arevalid(array("interessi"), $_POST)) {
    $query = "INSERT INTO interesse VALUES ";
    foreach ($_POST["interessi"] as $catid) {
        $query .= "('{$_SESSION['user']}',{$catid}),";
    }
    $result = pg_query($conn, substr($query, 0, -1));
}
/* RECURSIVE -> KILL APACHE
     $query = "SELECT * FROM categoria EXCEPT SELECT id, titolo FROM categoria AS c JOIN sottocategoria AS s ON c.id = s.categoriafiglio";
    $result = pg_query($conn, $query);

    if($result && pg_fetch_array($result, 0)){
      $compose = "<ul>";
      while($cat = pg_fetch_array($result)){
        $compose .= printSubcategories($cat, $conn);
      }
      $compose.= "</ul>";
    }
    //register_window();
    echo $compose;
  //}

  function printSubcategories($cat, $db){
    $query = "SELECT DISTINCT id, titolo FROM categoria AS c JOIN sottocategoria AS s ON c.id = s.categoriafiglio and categoriapadre = {$cat["id"]}";
    $result = pg_query($db, $query);
    if($result){
      if(pg_fetch_array($result, 0)){
        $compose = "<li data-cat-id='{$cat["id"]}'>{$cat["titolo"]}<ul>";
Ejemplo n.º 2
0
<?php

require "logic/connect.php";
if (arevalid(array("text", "topic"), $_POST)) {
    $id = NULL;
    if ($_POST["sond"] !== NULL) {
        $query = "INSERT INTO domanda(testo, autore, link, descrizione,sondaggio) VALUES ('{$_POST["text"]}','{$_SESSION["user"]}','{$_POST["image"]}','{$_POST["desc"]}','true') RETURNING id";
        $result = pg_query($conn, $query);
        $id = pg_fetch_array($result, 0)[0];
        $query = "INSERT INTO rispostasondaggio(domanda, testo) VALUES ";
        foreach ($_POST["risps"] as $risps) {
            if ($risps !== "") {
                $query .= "({$id},'{$risps}'),";
            }
        }
        $result = pg_query($conn, substr($query, 0, -1));
    } else {
        $query = "INSERT INTO domanda(testo, autore, link, descrizione) VALUES ('{$_POST["text"]}','{$_SESSION["user"]}','{$_POST["image"]}','{$_POST["desc"]}') RETURNING id";
        $result = pg_query($conn, $query);
        $id = pg_fetch_array($result, 0)[0];
    }
    $query = "INSERT INTO argomentodomanda VALUES ";
    foreach ($_POST["topic"] as $catid) {
        $query .= "({$id},{$catid}),";
    }
    $result = pg_query($conn, substr($query, 0, -1));
}
if (arevalid(array("close"), $_POST)) {
    $query = "UPDATE domanda SET open=false WHERE id={$_POST["close"]}";
    pg_query($conn, $query);
}
Ejemplo n.º 3
0
<?php

require "logic/connect.php";
if (arevalid(array("sond_ans"), $_POST)) {
    if (isset($_POST["anon"])) {
        $query = "INSERT INTO votosondaggio(risposta, utente, anon) VALUES ({$_POST["sond_ans"]},'{$_SESSION["user"]}','true')";
    } else {
        $query = "INSERT INTO votosondaggio(risposta,utente) VALUES ({$_POST["sond_ans"]},'{$_SESSION["user"]}')";
    }
    $result = pg_query($conn, $query);
}
Ejemplo n.º 4
0
<?php

include "logic/connect.php";
if (arevalid(array("date"), $_POST)) {
    $query = "UPDATE utente SET datanascita = '{$_POST["date"]}' WHERE username='{$_SESSION["user"]}'";
    $result = pg_query($conn, $query);
}
if (arevalid(array("res"), $_POST)) {
    $query = "UPDATE utente SET residenza = '{$_POST["res"]}' WHERE username='{$_SESSION["user"]}'";
    $result = pg_query($conn, $query);
}
if (isset($_GET["user"]) && $_GET["user"] !== $_SESSION["user"]) {
    $query = "SELECT * FROM utente WHERE username='{$_GET["user"]}'";
    $myself = pg_fetch_array(pg_query($conn, $query), 0);
    echo "<div class=\"uk-vertical-align uk-text-center uk-height-1-1\">\n      <div class=\"uk-vertical-align-middle\" style=\"width: 600px;\">\n      <div class='uk-panel uk-panel-space'>\n      <h2>{$myself["username"]}</h2>\n      <p>email: {$myself["email"]}</p>\n      <p>punteggio: {$myself["punteggio"]}</p>";
    if ($myself["vip"] === 't') {
        echo "<p>E' un utente VIP!</p>";
    }
    if (isset($myself["residenza"])) {
        echo "<p>Residente a {$myself["residenza"]}</p>";
    } else {
        echo "<p>Residente a Sconosciuto</p>";
    }
    if (isset($myself["datanascita"])) {
        echo "<p>Nato il {$myself["datanascita"]}</p>";
    } else {
        echo "<p>Nato il Sconosciuto</p>";
    }
    echo "<a class='uk-button uk-button-primary uk-button-large' href='index.php?user={$_SESSION["user"]}'>Mio profilo</a></div></div></div>";
} else {
    $query = "SELECT * FROM utente WHERE username='{$_SESSION["user"]}'";
Ejemplo n.º 5
0
<?php

require "logic/connect.php";
if (arevalid(array("qid"), $_GET) && arevalid(array("risp"), $_POST)) {
    $query = "INSERT INTO rispostadiretta(testo, autore, domanda) VALUES ('{$_POST["risp"]}','{$_SESSION["user"]}',{$_GET["qid"]})";
    $result = pg_query($conn, $query);
}
if (arevalid(array("qid"), $_GET) && arevalid(array("vote"), $_POST)) {
    $query = "INSERT INTO votorisposta(utente, risposta,punteggio) VALUES ('{$_SESSION["user"]}',{$_GET["qid"]},'{$_POST["vote"]}')";
    $result = pg_query($conn, $query);
}