]> matita.cs.unibo.it Git - logicplayer.git/commitdiff
New version.
authorwww-data <www-data@lahar.helm.cs.unibo.it>
Thu, 11 Dec 2014 13:23:45 +0000 (14:23 +0100)
committerwww-data <www-data@lahar.helm.cs.unibo.it>
Thu, 11 Dec 2014 13:23:45 +0000 (14:23 +0100)
public_html/login.css
public_html/login.js
public_html/login.php
public_html/main.php
public_html/printEs.php
public_html/prova.js
public_html/serverRequest.php
public_html/upload.php
public_html/xmlPharse.php

index dc4f5da525df424b68a384b69a01346d8e3e53dc..1b0c1c9c0cf6564e97b5b0575d9d95b662282141 100755 (executable)
@@ -1,16 +1,69 @@
 #login
+{
+       display: inline-block;
+       padding: 15px;
+       border-radius: 5px;
+       background-color: darkgray;
+       margin:15%;
+       border: solid 1px;
+       border-color: darkslateblue;
+}
+
+#esTable {
+       display: inline-block;
+       padding: 5px;
+       border-radius: 5px;
+       background-color: darkgray;
+       vertical-align:top;
+}
+#tabella
+{
+       display: inline-block;
+       padding: 5px;
+       border-radius: 5px;
+       background-color: lightgray;
+       vertical-align:top;
+}
+#esTa{
+       display: inline-block;
+       padding: 5px;
+       border-radius: 5px;
+       background-color: darkgray;
+       vertical-align:top;
+}
+#tab
+{
+       display: inline-block;
+       padding: 5px;
+       border-radius: 5px;
+       background-color: lightgray;
+       vertical-align:top;
+}
+#corpo
 {
        width:100%;
        display:inline-block;
        text-align:center;
 }
-#esTable
+#upload
 {
-       display:block;
-       float:left;
+       border-radius: 5px;
+       background-color: cadetblue;
+       display: inline-block;
+       padding: 10px;
+       margin: 5px;
 }
-#tabella
+body
+{
+       background: lightslategrey;
+       text-align:center;
+}
+input
+{
+       border-radius: 5px;
+}
+button
 {
-       display:block;
-       float:left;
+       border-radius: 5px;
 }
+
index e9afdc4b09d0c9c81c8aa0e2379b03ac9c35b7ef..f3a29f452eccd497a5ed9cf311e5a9989d152908 100755 (executable)
@@ -1,8 +1,8 @@
 function change()
 {
-/*Quando viene chiamata, modifica il campo "location" di document*/
-/*effettuando un redirect sulla pagina main.php*/
-document.location.href="./main.php";
+       /*Quando viene chiamata, modifica il campo "location" di document*/
+       /*effettuando un redirect sulla pagina main.php*/
+       document.location.href="./main.php";
 }
 
 
@@ -31,7 +31,7 @@ function login()
                                $("#errlogin").fadeIn();
                                setTimeout(function(){$("#errlogin").fadeOut()}, 2000);
 
-                       }
+                       },
     });
 }
 
index adadff4ac30484c837120946a8b8295a9d488b89..e3a96c8f5ce9e5e57caac8fa50115b58273222b8 100755 (executable)
@@ -1,8 +1,10 @@
 <?php\r
+       include 'util.php';\r
+       include './dbData.php';\r
        session_start();                                /*Inizia una sessione*/\r
        $data = file_get_contents('php://input'); /*file_get_contents:data una stringa, recupera i parametri di query. In questo caso viene presa la stringa inviata come dato dal JS*/\r
        $result = json_decode($data);\r
-       $con=mysqli_connect("localhost","root","csc@CerCo!","logintesi");\r
+       $con=mysqli_connect($DATA['dbLink'],$DATA['dbAdmin'],$DATA['dbPassword'],$DATA['dbName']);\r
        if ($con==false)\r
        {\r
                $arr=array('result'=>"errore nella connessione al database");\r
@@ -12,7 +14,7 @@
        }\r
        else\r
        {\r
-               $str="SELECT * FROM admin WHERE username='".$result->username."' AND password='".$result->password."';";\r
+               $str="SELECT * FROM ".$DATA['tbWebAdmin']." WHERE ".$DATA['clUser']."='".$result->username."' AND ".$DATA['clPass']."='".$result->password."';";\r
                $exists= mysqli_query($con,$str);\r
                if (!($exists))\r
                {\r
index 2866325dab4e8dd186c4401a78b0904b95d587a8..d88e8ca1471318debfc351e7192d69f9bc9cb920 100755 (executable)
@@ -17,8 +17,8 @@
                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
                <script type="text/javascript" src="./prova.js"></script>
        </head>
-       <body>
-               <form action="upload.php" method="post" enctype="multipart/form-data">
+       <body id="corpo">
+               <form id="upload" action="upload.php" method="post" enctype="multipart/form-data">
                        Select file to upload:
                        <input type="file" name="fileToUpload" id="fileToUpload">
                        <input type="submit" value="Upload" name="submit">
                                <tr id="intestazione">
                                        <th>Nome Esercizio</th>
                                        <th>Studente</th>
-                               <th>click</th>
-                       </tr>
+                                       <th>voto</th>
+                               </tr>
+                       </table>
+               </div>
+               <br/>
+               <div>
+                       <table id="esTa">
+                               <tr>
+                                       <th>Lista studenti</th>
+                               </tr>
+                       </table>
+                       <table id="tab">
+                               <tr id="in">
+                                       <th>Studente</th>
+                                       <th>Nome Esercizio</th>
+                                       <th>voto</th>
+                               </tr>
+                       </table>
                </div>
        </body>
 </html>
index 6c4b6e8213205fd046f7ea0b2b3810b33d2ceeff..3a25c9ea3ea8e0f658fe3b93c490e8aae9d7f57b 100755 (executable)
@@ -1,5 +1,5 @@
 <?php
-       if ($handle = opendir('/var/www/html/esercizi')) 
+       if ($handle = opendir($DATA['locationEsercizi'])) 
        {
                echo "File:<br/>";
 
index 62d03ef1bec2a2f3513b3fce3411b5cc2a08131f..454156b2b37f984eb7fa263263fa20362bed7643 100755 (executable)
@@ -21,20 +21,71 @@ function update(event)
                success:function(val)
                {
                        $("#tabella").empty();
-                       $("#tabella").append("<tr><th>Nome Esercizio</th><th>Studente</th><th>Click</th>");
+                       $("#tabella").append("<tr><th>Nome Esercizio</th><th>Studente</th><th>voto</th>");
                        $.each(val.esercizi, function(i, item) {
                                var id="es"+i;
-                               for(j=0;j<item.risultati.length;j++)
+                               if(item.risultati[0].id!=null)
                                {
-                                       var id_i=id+j;
-                                       $("#tabella").append($('<tr>').attr('id',id_i));
-                                       id_i="#"+id_i;
-                                       $(id_i).append($('<td>').text(item.esercizio));
-                                       $(id_i).append($('<td>').text(item.risultati[j].utente));
-                                       $(id_i).append($('<td>').text(item.risultati[j].click));
-                                       $(id_i).append($('<input class="eliminaRis" type="submit" value="elimina">').attr('risultato',item.risultati[j].click));
+                                       for(j=0;j<item.risultati.length;j++)
+                                       {
+                                               var id_i=id+j;
+                                               var tmpel='<input class="elimina" type="submit" risultato='+item.risultati[j].id+' value="elimina">';
+                                               $("#tabella").append($('<tr>').attr('id',id_i));
+                                               id_i="#"+id_i;
+                                               $(id_i).append($('<td>').text(item.esercizio));
+                                               $(id_i).append($('<td>').text(item.risultati[j].utente));
+                                               $(id_i).append($('<td>').text(item.risultati[j].click));
+                                               $(id_i).append($('<td>').append(tmpel));
+                                       }
                                }
                        });
+                       $(".elimina").click(function(event){elimina(event);});
+               },
+       });
+}
+
+function updateUsr(event)
+{
+       var str;
+       if (event==null)
+               str='all';
+    else{
+               var object=event.target;
+               str=object.getAttribute("utente");
+       }
+       var query="./esForUsr.php";
+       var request=new Object();
+       request.name=str;
+       var sendstr=JSON.stringify(request);
+       $.ajax({
+               url:query,
+               type:"POST",
+               async: "true",
+               dataType: "json",
+               data:sendstr,
+               contentType: "application/json; charset=utf-8",
+               success:function(val)
+               {
+                       $("#tab").empty();
+                       $("#tab").append("<tr><th>Studente</th><th>Nome Esercizio</th><th>voto</th>");
+                       $.each(val.esercizi, function(i, item) {
+                               var id="ut"+i;
+                               if(item.risultati[0].id!=null)
+                               {
+                                       for(j=0;j<item.risultati.length;j++)
+                                       {
+                                               var id_i=id+j;
+                                               var tmpel='<input class="elimina" type="submit" risultato='+item.risultati[j].id+' value="elimina">';
+                                               $("#tab").append($('<tr>').attr('id',id_i));
+                                               id_i="#"+id_i;
+                                               $(id_i).append($('<td>').text(item.risultati[j].utente));
+                                               $(id_i).append($('<td>').text(item.esercizio));
+                                               $(id_i).append($('<td>').text(item.risultati[j].click));
+                                               $(id_i).append($('<td>').append(tmpel));
+                                       }
+                               }
+                       });
+                       $(".elimina").click(function(event){elimina(event);});
                },
        });
 }
@@ -50,23 +101,97 @@ function esList()
                accepts: {json:"application/json"},
                success:function(val)
                {
+                       var ok=0;
                        $("#esTable").empty();
                        $("#esTable").append("<tr><th>Nome Esercizio</th>");
                        $.each(val.esercizi, function(i, item) {
-                               var id="ex"+i;
-                               $("#esTable").append($('<tr>').attr('id',id));
-                               $("#ex"+i).append($('<td>').text(item));
-                               $("#ex"+i).append($('<input class="seleziona" type="submit" value="seleziona">').attr('esercizio',item));
-                               $("#ex"+i).append($('<input class="elimina" type="submit" value="elimina">').attr('esercizio',item));
+                               if(item!=null)
+                               {
+                                       ok=1;
+                                       var id="ex"+i;
+                                       var tmpel='<input class="elimina" type="submit" esercizio='+item+' risultato="0" value="elimina">';
+                                       var tmpsel='<input class="seleziona" type="submit" esercizio='+item+' risultato="0" value="seleziona">';
+                                       $("#esTable").append($('<tr>').attr('id',id));
+                                       $("#ex"+i).append($('<td>').text(item));
+                                       $("#ex"+i).append($('<td></td>').append(tmpsel));
+                                       $("#ex"+i).append($('<td></td>').append(tmpel));
+                               }
                        });
-                       $("#esTable").append('<button type="button" esercizio="all" class="seleziona">seleziona tutti</button>');
+                       if(ok==1)       
+                               $("#esTable").append('<button type="button" esercizio="all" class="seleziona">seleziona tutti</button>');
                        $(".seleziona").click(function(event){update(event);});
+                       $(".elimina").click(function(event){elimina(event);});
+               },
+       });
+}
+
+function usrList()
+{
+       var query="./utenti.php";
+       $.ajax({
+               url:query,
+               type:"GET",
+               async: "true",
+               dataType: "json",
+               accepts: {json:"application/json"},
+               success:function(val)
+               {
+                       var ok=0;
+                       $("#esTa").empty();
+                       $("#esTa").append("<tr><th>Nome Studente</th>");
+                       $.each(val.utenti, function(i, item) {
+                               if(item!=null)
+                               {
+                                       ok=1;
+                                       var id="ut"+i;
+                                       var tmpel='<input class="elimina" type="submit" utente='+item+' risultato="-1" value="elimina">';
+                                       var tmpsel='<input class="selezionaUT" type="submit" utente='+item+' risultato="-1" value="seleziona">';
+                                       $("#esTa").append($('<tr>').attr('id',id));
+                                       $("#ut"+i).append($('<td>').text(item));
+                                       $("#ut"+i).append($('<td></td>').append(tmpsel));
+                                       $("#ut"+i).append($('<td></td>').append(tmpel));
+                               }
+                       });
+                       if(ok==1)       
+                               $("#esTa").append('<button type="button" utente="all" class="selezionaUT">seleziona tutti</button>');
+                       $(".selezionaUT").click(function(event){updateUsr(event);});
+                       $(".elimina").click(function(event){elimina(event);});
                },
        });
 }
 
+function elimina(event)
+{
+       var object=event.target;
+       var query="./elimina_esercizio.php";
+       var request=new Object();
+       request.id=object.getAttribute("risultato");
+       if(request.id==0)
+               request.esercizio=object.getAttribute("esercizio");
+       else if(request.id<0)
+               request.utente=object.getAttribute("utente");
+       var sendstr=JSON.stringify(request);
+       $.ajax({
+               url:query,
+               type:"POST",
+               async: "true",
+               dataType: "json",
+               data:sendstr,
+               contentType: "application/json; charset=utf-8",
+               success:function(val)
+               {
+                               esList();
+                               update();
+                               usrList();
+                               updateUsr();
+               }
+       });
+}
+
 $(document).ready(function(){
                esList();
+               usrList();
                update();
+               updateUsr();
                $(".seleziona").click(function(event){update(event);});
 });
index 9f7a781cd409457f348286ecc55bf34ef0b1ae90..230344087a7293f03e1e35f2bb23d3f1676c0122 100755 (executable)
@@ -1,8 +1,9 @@
 <?php
        include 'util.php';
+       include './dbData.php';
        $data = file_get_contents('php://input'); /*file_get_contents:data una stringa, recupera i parametri di query. In questo caso viene presa la stringa inviata come dato dal JS*/
        $result = json_decode($data);
-       $con=mysqli_connect("localhost","root","csc@CerCo!","logintesi");
+       $con=mysqli_connect($DATA['dbLink'],$DATA['dbAdmin'],$DATA['dbPassword'],$DATA['dbName']);
        if ($con==false)
        {
                $arr=array('result'=>"errore nella connessione al database");
@@ -11,9 +12,9 @@
                die;
        }
        if($result->name=='all')
-               $str="SELECT * FROM esercizi;";
+               $str="SELECT * FROM ".$DATA['tbEsercizi'].";";
        else
-               $str="SELECT * FROM esercizi WHERE esercizio='".$result->name."' ORDER BY esercizio;";
+               $str="SELECT * FROM ".$DATA['tbEsercizi']." WHERE ".$DATA['clEsercizio']."='".$result->name."' ORDER BY ".$DATA['clEsercizio'].";";
        $str=mysqli_query($con,$str);
        if (!$str)
        {
        $esercizi;
        $risp=mysqli_fetch_array($str);
        $risultati;
-       $esercizio['esercizio']=$risp['esercizio'];
+       $esercizio['esercizio']=$risp[$DATA['clEsercizio']];
        do
        {
-               if($esercizio['esercizio']==$risp['esercizio'])
+               if($esercizio['esercizio']==$risp[$DATA['clEsercizio']])
                {
                        //aggiungo utenti e click ell'es corrente
-                       $risultati[]=array('id'=>$risp['id'],'utente'=>$risp['utente'],'click'=>$risp['click']);
+                       $risultati[]=array('id'=>$risp[$DATA['clId']],'utente'=>$risp[$DATA['clUser']],'click'=>$risp[$DATA['clVoto']]);
                }
                else
                {
@@ -40,8 +41,8 @@
                        $esercizi[]=$esercizio;
                        unset($esercizio);
                        unset($risultati);
-                       $esercizio['esercizio']=$risp['esercizio'];
-                       $risultati[]=array('id'=>$risp['id'],'utente'=>$risp['utente'],'click'=>$risp['click']);
+                       $esercizio['esercizio']=$risp[$DATA['clEsercizio']];
+                       $risultati[]=array('id'=>$risp[$DATA['clId']],'utente'=>$risp[$DATA['clUser']],'click'=>$risp[$DATA['clVoto']]);
                }
        }while($risp=mysqli_fetch_array($str));      
        $esercizio['risultati']=$risultati;
index 67c3a7ad2344d266b20814ad5f89d0b03a12d80c..c0446c638cb5c433a3e04a67e053a31f4768ba77 100755 (executable)
@@ -1,4 +1,5 @@
 <?php
+       include './dbData.php';
        $target_dir = "esercizi/";
        $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
        $uploadOk = 1;
        // if everything is ok, try to upload file
        } else {
                if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
-                       echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
-               } else {
-                       echo "Sorry, there was an error uploading your file.";
+                       sleep(1);
+                       $xml = simplexml_load_file($DATA['listaEsercizi']);
+                       foreach($xml->esercizio as $esercizio)
+                       {
+                               if($esercizio==basename( $_FILES["fileToUpload"]["name"]))
+                               {
+                                       echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; 
+                                       die;
+                               }
+                       }
                }
+               echo "Sorry, there was an error uploading your file.";
        }
 ?>
 <!DOCTYPE html>
index 6dbe115526634838570b919e2178f15a6e2601c3..7cfcce3807f727e36371550946295d8e1a10f45a 100755 (executable)
@@ -1,6 +1,7 @@
 <?php
        include 'util.php';
-       $xml = simplexml_load_file('/projects/logicplayer/Server/server/tesi/src/com/company/esercizi.xml');
+       include './dbData.php';
+       $xml = simplexml_load_file($DATA['listaEsercizi']);
        $esercizi;
        foreach($xml->esercizio as $esercizio)
        {