From: www-data Date: Tue, 2 Dec 2014 10:34:39 +0000 (+0100) Subject: Shuffling. X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=edfa62efb21b128dce6de134a3fb0d85f77bd2b8;p=logicplayer.git Shuffling. --- diff --git a/JOURNAL b/JOURNAL new file mode 100644 index 0000000..9714212 --- /dev/null +++ b/JOURNAL @@ -0,0 +1,28 @@ +### Librerie ### +- installare: apache, php5, php5-mysql, mysql-server, openjdk-8-jdk + +### Database ### +- aggiungere a logintesi.sql USE logintesi; se non c'e' +- mysql -u root -p + create database logintesi; +- mysql < ~claudio/tesi_applet/logintesi.sql -u root -p + +### Php server ### +- mkdir Server && cd Server && tar -zxvf ../Server.tar.gz +- cp -R ~claudio/tesi_applet/Server/webApp/* /var/www/html/ +- chown -R www-data:www-data esercizi +- serverRequest.php: /localhost, impostare password +- login.php: /localhost, impostare password +- username e password admin sono nel db, tabella admin + mysql -u root -p logintesi + mysql> insert into admin values("admin","AdMin#@"); +- xmlPharse.php: ~claudio/tesi_applet/Server/server/tesi/src/com/company/esercizi.xml + +### Java server ### +- vim ~/tesi_applet/Server/server/tesi/src/com/company/global.java + editare home, servername, ... +- cp ~claudio/tesi_applet/Server/java-8-oracle/jre/lib/ext/* /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/ + PERCHE' IL CLASSPATH NON FUNZIONA?? +- javac *.java +- cd /home/claudio/tesi_applet/Server/server/tesi/src + java com.company.superServer diff --git a/Server/JOURNAL b/Server/JOURNAL deleted file mode 100644 index 9714212..0000000 --- a/Server/JOURNAL +++ /dev/null @@ -1,28 +0,0 @@ -### Librerie ### -- installare: apache, php5, php5-mysql, mysql-server, openjdk-8-jdk - -### Database ### -- aggiungere a logintesi.sql USE logintesi; se non c'e' -- mysql -u root -p - create database logintesi; -- mysql < ~claudio/tesi_applet/logintesi.sql -u root -p - -### Php server ### -- mkdir Server && cd Server && tar -zxvf ../Server.tar.gz -- cp -R ~claudio/tesi_applet/Server/webApp/* /var/www/html/ -- chown -R www-data:www-data esercizi -- serverRequest.php: /localhost, impostare password -- login.php: /localhost, impostare password -- username e password admin sono nel db, tabella admin - mysql -u root -p logintesi - mysql> insert into admin values("admin","AdMin#@"); -- xmlPharse.php: ~claudio/tesi_applet/Server/server/tesi/src/com/company/esercizi.xml - -### Java server ### -- vim ~/tesi_applet/Server/server/tesi/src/com/company/global.java - editare home, servername, ... -- cp ~claudio/tesi_applet/Server/java-8-oracle/jre/lib/ext/* /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/ - PERCHE' IL CLASSPATH NON FUNZIONA?? -- javac *.java -- cd /home/claudio/tesi_applet/Server/server/tesi/src - java com.company.superServer diff --git a/Server/logintesi.sql b/Server/logintesi.sql deleted file mode 100644 index ec57f9c..0000000 --- a/Server/logintesi.sql +++ /dev/null @@ -1,195 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generato il: Nov 14, 2014 alle 16:45 --- Versione del server: 5.5.38-0ubuntu0.14.04.1 --- Versione PHP: 5.5.9-1ubuntu4.4 - -USE logintesi; - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `logintesi` --- - --- -------------------------------------------------------- - --- --- Struttura della tabella `admin` --- - -CREATE TABLE IF NOT EXISTS `admin` ( - `username` varchar(30) COLLATE utf8_bin NOT NULL, - `password` varchar(30) COLLATE utf8_bin NOT NULL, - UNIQUE KEY `username` (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- --- Dump dei dati per la tabella `admin` --- - -INSERT INTO `admin` (`username`, `password`) VALUES -('danilo.berardinelli', '123stella'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `aggprova` --- - -CREATE TABLE IF NOT EXISTS `aggprova` ( - `chiave` varchar(50) COLLATE utf8_bin NOT NULL, - `time` double NOT NULL, - `checks` int(11) NOT NULL, - PRIMARY KEY (`chiave`), - UNIQUE KEY `key` (`chiave`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- --- Dump dei dati per la tabella `aggprova` --- - -INSERT INTO `aggprova` (`chiave`, `time`, `checks`) VALUES -('10157426982320510', 1415145803639, 1), -('10244937857444543', 1415284664538, 1), -('10308106918353456', 1415243065790, 1), -('10385651273134167', 1415289922479, 1), -('10414239987472834', 1415285560312, 1), -('1097785784725414', 1415284853312, 1), -('10983265112121106', 1415242393295, 1), -('1286713061377424', 1415036978051, 1), -('1408285479764558', 1415278883075, 1), -('1490801371315190', 1415285333816, 1), -('1741331087669285', 1415811578318, 1), -('18516070104459806', 1415276863684, 1), -('2217380018747176', 1415145507080, 1), -('2260502250327125', 1415284745047, 1), -('2473377684156933', 1415284628252, 1), -('2504043195911198', 1415285115955, 1), -('2686774762838581', 1415278911038, 1), -('2744239278608085', 1415036291300, 1), -('2956509786688513', 1415271435934, 1), -('2961042458190883', 1415277033282, 1), -('3109253928772677', 1415284540445, 1), -('3311335330604631', 1415237862686, 1), -('3486758220086141', 1415242975878, 1), -('3571361357113219', 1415285156048, 1), -('4091389111256716', 1415025754182, 1), -('42848425102166715', 1415242068918, 1), -('4457124515989723', 1415811050681, 1), -('4577865146663611', 1415285170075, 1), -('4796791993070257', 1415288554998, 1), -('5005653368852396', 1415285312682, 1), -('5226217037177487', 1415145721770, 1), -('5308112899337743', 1415037335958, 1), -('5362524692721963', 1415811381242, 1), -('5382075363462279', 1415272904986, 1), -('5650512812480934', 1415271249954, 1), -('5735648814288922', 1415036889526, 1), -('62029084106069252', 1415241839377, 1), -('6712150141518271', 1415285510994, 1), -('6786243849285602', 1415811389915, 1), -('6992436366972266', 1415242705239, 1), -('7106071695334106', 1415811170493, 1), -('7158700078303143', 1415284726466, 1), -('7307203380313108', 1415819825863, 1), -('75372031101482498', 1415284519581, 1), -('7703030541673651', 1415272914342, 1), -('8065501483698608', 1415819808393, 1), -('8468895456378674', 1415241733824, 1), -('8760904545449404', 1415285230458, 1), -('8838732364680254', 1415271877269, 1), -('9576830372163956', 1415283251776, 1); - --- -------------------------------------------------------- - --- --- Struttura della tabella `confmail` --- - -CREATE TABLE IF NOT EXISTS `confmail` ( - `user` varchar(50) COLLATE utf8_bin NOT NULL, - `pass` varchar(50) COLLATE utf8_bin NOT NULL, - `hash` varchar(50) COLLATE utf8_bin NOT NULL, - `time` double DEFAULT NULL, - UNIQUE KEY `user` (`user`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- -------------------------------------------------------- - --- --- Struttura della tabella `connessi` --- - -CREATE TABLE IF NOT EXISTS `connessi` ( - `user` varchar(50) COLLATE utf8_bin NOT NULL, - `tempkey` varchar(50) COLLATE utf8_bin NOT NULL, - `thread` tinyint(1) NOT NULL, - `time` double NOT NULL, - UNIQUE KEY `tempkey` (`tempkey`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- --- Dump dei dati per la tabella `connessi` --- - -INSERT INTO `connessi` (`user`, `tempkey`, `thread`, `time`) VALUES -('danilo.berardinelli@studio.unibo.it', '2545550210880139', 0, 1415975986391); - --- -------------------------------------------------------- - --- --- Struttura della tabella `esercizi` --- - -CREATE TABLE IF NOT EXISTS `esercizi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `esercizio` varchar(20) COLLATE utf8_bin NOT NULL, - `utente` varchar(50) COLLATE utf8_bin NOT NULL, - `click` int(11) NOT NULL, - `time` double NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `id` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=4 ; - --- --- Dump dei dati per la tabella `esercizi` --- - -INSERT INTO `esercizi` (`id`, `esercizio`, `utente`, `click`, `time`) VALUES -(1, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 1, 1415923860705), -(2, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 1, 1415975624027), -(3, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 3, 1415975983857); - --- -------------------------------------------------------- - --- --- Struttura della tabella `utenti` --- - -CREATE TABLE IF NOT EXISTS `utenti` ( - `user` varchar(50) COLLATE utf8_bin NOT NULL, - `pass` varchar(15) COLLATE utf8_bin NOT NULL, - UNIQUE KEY `user` (`user`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- --- Dump dei dati per la tabella `utenti` --- - -INSERT INTO `utenti` (`user`, `pass`) VALUES -('danilo.berardinelli@studio.unibo.it', '123stella'); - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Server/server/tesi/.idea/compiler.xml b/Server/server/tesi/.idea/compiler.xml deleted file mode 100644 index 9a8b7e5..0000000 --- a/Server/server/tesi/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/copyright/profiles_settings.xml b/Server/server/tesi/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/Server/server/tesi/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/description.html b/Server/server/tesi/.idea/description.html deleted file mode 100644 index db5f129..0000000 --- a/Server/server/tesi/.idea/description.html +++ /dev/null @@ -1 +0,0 @@ -Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Server/server/tesi/.idea/encodings.xml b/Server/server/tesi/.idea/encodings.xml deleted file mode 100644 index d821048..0000000 --- a/Server/server/tesi/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/misc.xml b/Server/server/tesi/.idea/misc.xml deleted file mode 100644 index 728f444..0000000 --- a/Server/server/tesi/.idea/misc.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/modules.xml b/Server/server/tesi/.idea/modules.xml deleted file mode 100644 index d9c1a63..0000000 --- a/Server/server/tesi/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/project-template.xml b/Server/server/tesi/.idea/project-template.xml deleted file mode 100644 index 1f08b88..0000000 --- a/Server/server/tesi/.idea/project-template.xml +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/Server/server/tesi/.idea/scopes/scope_settings.xml b/Server/server/tesi/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b..0000000 --- a/Server/server/tesi/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/uiDesigner.xml b/Server/server/tesi/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/Server/server/tesi/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/vcs.xml b/Server/server/tesi/.idea/vcs.xml deleted file mode 100644 index 6564d52..0000000 --- a/Server/server/tesi/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Server/server/tesi/.idea/workspace.xml b/Server/server/tesi/.idea/workspace.xml deleted file mode 100644 index 7ff99c0..0000000 --- a/Server/server/tesi/.idea/workspace.xml +++ /dev/null @@ -1,1003 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Control flow issues - - - - - InfiniteLoopStatement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1415700559063 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - tesi - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Server/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class b/Server/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class deleted file mode 100644 index cfca534..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/EmailSender.class b/Server/server/tesi/out/production/tesi/com/company/EmailSender.class deleted file mode 100644 index f7d68c0..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/EmailSender.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/EsNameParser.class b/Server/server/tesi/out/production/tesi/com/company/EsNameParser.class deleted file mode 100644 index 6b5cef6..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/EsNameParser.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/MD5.class b/Server/server/tesi/out/production/tesi/com/company/MD5.class deleted file mode 100644 index e5246c0..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/MD5.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/dbConnect.class b/Server/server/tesi/out/production/tesi/com/company/dbConnect.class deleted file mode 100644 index 982753e..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/dbConnect.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/esercizi.xml b/Server/server/tesi/out/production/tesi/com/company/esercizi.xml deleted file mode 100644 index 50ba729..0000000 --- a/Server/server/tesi/out/production/tesi/com/company/esercizi.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - aalbero.xml - tautologia.xml - diff --git a/Server/server/tesi/out/production/tesi/com/company/global.class b/Server/server/tesi/out/production/tesi/com/company/global.class deleted file mode 100644 index dc41980..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/global.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/guestServer.class b/Server/server/tesi/out/production/tesi/com/company/guestServer.class deleted file mode 100644 index dbbf2f7..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/guestServer.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class b/Server/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class deleted file mode 100644 index 0db2b2c..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/httpget.class b/Server/server/tesi/out/production/tesi/com/company/httpget.class deleted file mode 100644 index 9593347..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/httpget.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/keystore.bks b/Server/server/tesi/out/production/tesi/com/company/keystore.bks deleted file mode 100644 index ecec326..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/keystore.bks and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/keystore.crt b/Server/server/tesi/out/production/tesi/com/company/keystore.crt deleted file mode 100644 index e60e9db..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/keystore.crt and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/keystore.jks b/Server/server/tesi/out/production/tesi/com/company/keystore.jks deleted file mode 100644 index 4edd598..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/keystore.jks and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/personalServer.class b/Server/server/tesi/out/production/tesi/com/company/personalServer.class deleted file mode 100644 index 81fabd7..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/personalServer.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/suString.class b/Server/server/tesi/out/production/tesi/com/company/suString.class deleted file mode 100644 index d504a2d..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/suString.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/superServer.class b/Server/server/tesi/out/production/tesi/com/company/superServer.class deleted file mode 100644 index 74de9bc..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/superServer.class and /dev/null differ diff --git a/Server/server/tesi/out/production/tesi/com/company/xmlOperation.class b/Server/server/tesi/out/production/tesi/com/company/xmlOperation.class deleted file mode 100644 index 143c104..0000000 Binary files a/Server/server/tesi/out/production/tesi/com/company/xmlOperation.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/DeleteFileExample.class b/Server/server/tesi/out/production/testi/com/company/DeleteFileExample.class deleted file mode 100644 index 0e024f6..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/DeleteFileExample.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/EmailSender.class b/Server/server/tesi/out/production/testi/com/company/EmailSender.class deleted file mode 100644 index e4c00d6..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/EmailSender.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/EsNameParser.class b/Server/server/tesi/out/production/testi/com/company/EsNameParser.class deleted file mode 100644 index bc79739..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/EsNameParser.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/dbConnect.class b/Server/server/tesi/out/production/testi/com/company/dbConnect.class deleted file mode 100644 index c6a1217..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/dbConnect.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/esercizi.xml b/Server/server/tesi/out/production/testi/com/company/esercizi.xml deleted file mode 100644 index 2d06edb..0000000 --- a/Server/server/tesi/out/production/testi/com/company/esercizi.xml +++ /dev/null @@ -1,3 +0,0 @@ - - albero.xml - \ No newline at end of file diff --git a/Server/server/tesi/out/production/testi/com/company/guestServer.class b/Server/server/tesi/out/production/testi/com/company/guestServer.class deleted file mode 100644 index cc9ff21..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/guestServer.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/httpget$MyHandler.class b/Server/server/tesi/out/production/testi/com/company/httpget$MyHandler.class deleted file mode 100644 index 2426f4a..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/httpget$MyHandler.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/httpget.class b/Server/server/tesi/out/production/testi/com/company/httpget.class deleted file mode 100644 index 740b705..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/httpget.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/keystore.bks b/Server/server/tesi/out/production/testi/com/company/keystore.bks deleted file mode 100644 index ecec326..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/keystore.bks and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/keystore.crt b/Server/server/tesi/out/production/testi/com/company/keystore.crt deleted file mode 100644 index e60e9db..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/keystore.crt and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/keystore.jks b/Server/server/tesi/out/production/testi/com/company/keystore.jks deleted file mode 100644 index 4edd598..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/keystore.jks and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/personalServer.class b/Server/server/tesi/out/production/testi/com/company/personalServer.class deleted file mode 100644 index 03678d6..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/personalServer.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/suString.class b/Server/server/tesi/out/production/testi/com/company/suString.class deleted file mode 100644 index d8301c9..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/suString.class and /dev/null differ diff --git a/Server/server/tesi/out/production/testi/com/company/superServer.class b/Server/server/tesi/out/production/testi/com/company/superServer.class deleted file mode 100644 index 44b721f..0000000 Binary files a/Server/server/tesi/out/production/testi/com/company/superServer.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/DeleteFileExample.class b/Server/server/tesi/src/com/company/DeleteFileExample.class deleted file mode 100644 index 25a7db8..0000000 Binary files a/Server/server/tesi/src/com/company/DeleteFileExample.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/DirectoryWatcher.class b/Server/server/tesi/src/com/company/DirectoryWatcher.class deleted file mode 100644 index fb7ef98..0000000 Binary files a/Server/server/tesi/src/com/company/DirectoryWatcher.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/DirectoryWhatcer.java b/Server/server/tesi/src/com/company/DirectoryWhatcer.java deleted file mode 100644 index 8b376a1..0000000 --- a/Server/server/tesi/src/com/company/DirectoryWhatcer.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.company; - -import java.io.*; -import java.nio.file.Path; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchEvent.Kind; -import java.nio.file.WatchKey; -import java.nio.file.WatchService; -import java.security.NoSuchAlgorithmException; -import java.sql.SQLException; -import java.util.ArrayList; - -// Simple class to watch directory events. -class DirectoryWatcher implements Runnable { - - private Path path; - - public DirectoryWatcher(Path path) { - this.path = path; - } - - //rimuove tutti gli elementi non validi - private void pulisciCartella() { - File dir = new File(global.locationEsercizi); - String[] lista=dir.list(); - for(String name : lista) - { - if (!EsNameParser.check(name)) - { - File file = new File(global.locationEsercizi+name); - if (file.delete()) - System.out.println("eliminato: "+name); - else - System.out.println("problema di eliminazione file"); - } - else - { - xmlOperation es=new xmlOperation(); - File car=new File(global.listaEsercizi); - if (car.exists()) { - dbConnect db=new dbConnect(); - try { - ArrayList esercizi=suString.stringToArrayList(db.dbQuery("4")); - boolean add=true; - for(String esercizio : esercizi) - { - if(esercizio.equals(name)) - add=false; - } - if(add) - es.add(name); - } catch (SQLException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } - } - } - } - - // print the events and the affected file - private void printEvent(WatchEvent event) throws IOException { - Kind kind = event.kind(); - if (kind.equals(StandardWatchEventKinds.ENTRY_CREATE)) - { - Path pathCreated = (Path) event.context(); - System.out.println("Entry created:" + pathCreated); - boolean check = EsNameParser.check(pathCreated.getFileName().toString()); - if(!check) - { - File file = new File(global.locationEsercizi+pathCreated.getFileName().toString()); - if(file.delete()) - System.out.println("eliminato"); - else - System.out.println("problema di eliminazione file"); - } - else - { - xmlOperation es=new xmlOperation(); - File dir=new File(global.listaEsercizi); - if (dir.exists()) - es.add(pathCreated.getFileName().toString()); - } - } - else if (kind.equals(StandardWatchEventKinds.ENTRY_DELETE)) - { - Path pathDeleted = (Path) event.context(); - System.out.println("Entry deleted:" + pathDeleted); - xmlOperation es=new xmlOperation(); - File dir=new File(global.listaEsercizi); - if (dir.exists()) - es.remove(pathDeleted.getFileName().toString()); - } - else if (kind.equals(StandardWatchEventKinds.ENTRY_MODIFY)) - { - Path pathModified = (Path) event.context(); - System.out.println("Entry modified:" + pathModified); - } - } - - @Override - public void run() { - try { - pulisciCartella(); - WatchService watchService = path.getFileSystem().newWatchService(); - path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE); - - // loop forever to watch directory - while (true) { - WatchKey watchKey; - watchKey = watchService.take(); // this call is blocking until events are present - - // poll for file system events on the WatchKey - for (final WatchEvent event : watchKey.pollEvents()) { - printEvent(event); - } - - // if the watched directed gets deleted, get out of run method - if (!watchKey.reset()) { - System.out.println("No longer valid"); - watchKey.cancel(); - watchService.close(); - break; - } - } - - } catch (InterruptedException ex) { - System.out.println("interrupted. Goodbye"); - return; - } catch (IOException ex) { - ex.printStackTrace(); // don't do this in production code. Use a loggin framework - return; - } - } - -} diff --git a/Server/server/tesi/src/com/company/EmailSender.class b/Server/server/tesi/src/com/company/EmailSender.class deleted file mode 100644 index 8c301a8..0000000 Binary files a/Server/server/tesi/src/com/company/EmailSender.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/EmailSender.java b/Server/server/tesi/src/com/company/EmailSender.java deleted file mode 100644 index 1abf701..0000000 --- a/Server/server/tesi/src/com/company/EmailSender.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.company; - -import java.util.Date; -import java.util.Properties; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.NoSuchProviderException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; - - - -public class EmailSender { - private String user; - private String password; - private String host; - private String mittente; - private String destinatario; - private String oggetto; - private String mess; - - - EmailSender(String user, String password, String host, - String mittente, String destinatario, - String oggetto, String mess){ - - this.user = user; - this.password = password; - this.host = host; - this.mittente = mittente; - this.destinatario = destinatario; - this.oggetto = oggetto; - this.mess=mess; - } - - - // Metodo che si occupa dell'invio effettivo della mail - public void inviaEmail() { - int port = 465; //porta 25 per non usare SSL - - Properties props = new Properties(); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.user", mittente); - props.put("mail.smtp.host", host); - props.put("mail.smtp.port", port); - - // commentare la riga seguente per non usare SSL - props.put("mail.smtp.starttls.enable","true"); - props.put("mail.smtp.socketFactory.port", port); - - // commentare la riga seguente per non usare SSL - props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); - props.put("mail.smtp.socketFactory.fallback", "false"); - - Session session = Session.getInstance(props, null); - session.setDebug(true); - - // Creazione delle BodyParts del messaggio - MimeBodyPart messageBodyPart1 = new MimeBodyPart(); - - try{ - // COSTRUZIONE DEL MESSAGGIO - Multipart multipart = new MimeMultipart(); - MimeMessage msg = new MimeMessage(session); - - // header del messaggio - msg.setSubject(oggetto); - msg.setSentDate(new Date()); - msg.setFrom(new InternetAddress(mittente)); - - // destinatario - msg.addRecipient(Message.RecipientType.TO, - new InternetAddress(destinatario)); - - // corpo del messaggio - messageBodyPart1.setText(mess); - multipart.addBodyPart(messageBodyPart1); - - // allegato al messaggio - /*DataSource source = new FileDataSource(allegato); - messageBodyPart2.setDataHandler(new DataHandler(source)); - messageBodyPart2.setFileName(allegato); - multipart.addBodyPart(messageBodyPart2);*/ - - // inserimento delle parti nel messaggio - msg.setContent(multipart); - - Transport transport = session.getTransport("smtps"); //("smtp") per non usare SSL - transport.connect(host, user, password); - transport.sendMessage(msg, msg.getAllRecipients()); - transport.close(); - - System.out.println("Invio dell'email Terminato"); - - }catch(AddressException ae) { - ae.printStackTrace(); - }catch(NoSuchProviderException nspe){ - nspe.printStackTrace(); - }catch(MessagingException me){ - me.printStackTrace(); - } - - } -} diff --git a/Server/server/tesi/src/com/company/EsNameParser.class b/Server/server/tesi/src/com/company/EsNameParser.class deleted file mode 100644 index d2cfbe3..0000000 Binary files a/Server/server/tesi/src/com/company/EsNameParser.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/EsNameParser.java b/Server/server/tesi/src/com/company/EsNameParser.java deleted file mode 100644 index f4f1105..0000000 --- a/Server/server/tesi/src/com/company/EsNameParser.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.company; - -import java.io.File; -import java.io.FileInputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Document; - -import java.lang.Integer; -import java.io.FileReader; -import java.io.BufferedReader; - -public class EsNameParser { - EsNameParser(){} - - static public String esName() - { - try { - FileInputStream file = new FileInputStream(new File(global.listaEsercizi)); - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = builderFactory.newDocumentBuilder(); - Document xmlDocument = builder.parse(file); - XPath xPath = XPathFactory.newInstance().newXPath(); - int esNumber = Integer.parseInt(xPath.compile("count(/esercizi/esercizio)").evaluate(xmlDocument)); - String returnValue = null; - for (int i = 1; i <= esNumber; i++) { - String name = xPath.compile("/esercizi/esercizio[" + i + "]").evaluate(xmlDocument); - if (name == null || name.isEmpty()) - continue; - else { - if(returnValue==null) - returnValue=name; - else - returnValue = returnValue + "/" + name; - } - } - file.close(); - return returnValue; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static boolean check(String esercizio) - { - boolean value=false; - try - { - String cartellaEs=global.locationEsercizi; - - BufferedReader br = new BufferedReader(new FileReader(cartellaEs+esercizio)); - if (br.readLine() == null) { - br.close(); - return false; - } - FileInputStream file = new FileInputStream(new File(cartellaEs+"/"+esercizio)); - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = builderFactory.newDocumentBuilder(); - Document xmlDocument = builder.parse(file); - value=checkFormula(xmlDocument,"/esercizio/tesi/formula[1]"); - if(value) - value=checkIpotesi(xmlDocument); - file.close(); - } catch (Exception e) { - e.printStackTrace(); - } - return value; - } - - static public boolean checkFormula(Document xmlDocument, String position) { - try - { - XPath xPath = XPathFactory.newInstance().newXPath(); - if(Integer.parseInt(xPath.compile("count(" + position + ")").evaluate(xmlDocument))==1) { - String type = xPath.compile(position + "/@type").evaluate(xmlDocument); - int numbOfElements = 5; - if (type.contentEquals("and") || type.contentEquals("or") || type.contentEquals("impl")) - numbOfElements = 2; - else if (type.contentEquals("not")) - numbOfElements = 1; - else if (type.contentEquals("literal") || type.contentEquals("atomic")) - numbOfElements = 0; - int count = Integer.parseInt(xPath.compile("count(" + position + "/formula)").evaluate(xmlDocument)); - if (count == numbOfElements) { - if (numbOfElements == 2) { - boolean firstChild = checkFormula(xmlDocument, position + "/formula[1]"); - boolean secondChild = checkFormula(xmlDocument, position + "/formula[2]"); - if (!firstChild || !secondChild) - return false; - else - return true; - } - else if (numbOfElements == 1) - { - boolean child = checkFormula(xmlDocument, position + "/formula[1]"); - if (!child) - return false; - return true; - } - else if (numbOfElements == 0) - { - String child = xPath.compile(position).evaluate(xmlDocument); - if (child == null || child.isEmpty()) - return false; - else - return true; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - static public boolean checkIpotesi(Document xmlDocument) - { - XPath xPath = XPathFactory.newInstance().newXPath(); - boolean returnValue=false; - try - { - int count = Integer.parseInt(xPath.compile("count(/esercizio/ipotesi)").evaluate(xmlDocument)); - int numberHp=Integer.parseInt(xPath.compile("count(/esercizio/ipotesi/formula)").evaluate(xmlDocument)); - if(count==1 && numberHp==0)//se non ci sono ipotesi - return true; - for(int i=1;i<=numberHp;i++) - { - boolean valore = checkFormula(xmlDocument, "/esercizio/ipotesi/formula["+i+"]"); - if(!valore) - return false; - else - returnValue=true; - } - }catch (Exception e) { - e.printStackTrace(); - } - return returnValue; - } -} diff --git a/Server/server/tesi/src/com/company/MD5.class b/Server/server/tesi/src/com/company/MD5.class deleted file mode 100644 index 79abbc1..0000000 Binary files a/Server/server/tesi/src/com/company/MD5.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/MD5.java b/Server/server/tesi/src/com/company/MD5.java deleted file mode 100644 index 623f11f..0000000 --- a/Server/server/tesi/src/com/company/MD5.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.company; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - - -public class MD5 { - - MD5(){} - public static String digest(String filePath) { - InputStream inputStream = null; - try { - inputStream = new FileInputStream(global.locationEsercizi+filePath); - byte[] buffer = new byte[1024]; - MessageDigest digest = MessageDigest.getInstance("MD5"); - int numRead = 0; - while (numRead != -1) { - numRead = inputStream.read(buffer); - if (numRead > 0) - digest.update(buffer, 0, numRead); - } - byte [] md5Bytes = digest.digest(); - System.out.println(convertHashToString(md5Bytes)); - return convertHashToString(md5Bytes); - } catch (Exception e) { - return null; - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (Exception e) { } - } - } - } - - private static String convertHashToString(byte[] md5Bytes) { - String returnVal = ""; - for (int i = 0; i < md5Bytes.length; i++) { - returnVal += Integer.toString(( md5Bytes[i] & 0xff ) + 0x100, 16).substring(1); - } - return returnVal; - } -} diff --git a/Server/server/tesi/src/com/company/Makefile b/Server/server/tesi/src/com/company/Makefile deleted file mode 100644 index 2cc75ec..0000000 --- a/Server/server/tesi/src/com/company/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - javac -cp "/tmp/ext/mysql-connector-java.jar:/tmp/ext/jdom-2.0.5.jar:/tmp/ext/mail-1.4.1.jar:." *.java diff --git a/Server/server/tesi/src/com/company/dbConnect.class b/Server/server/tesi/src/com/company/dbConnect.class deleted file mode 100644 index 03ff58b..0000000 Binary files a/Server/server/tesi/src/com/company/dbConnect.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/dbConnect.java b/Server/server/tesi/src/com/company/dbConnect.java deleted file mode 100644 index 28d851c..0000000 --- a/Server/server/tesi/src/com/company/dbConnect.java +++ /dev/null @@ -1,355 +0,0 @@ -package com.company; - -import java.sql.*; -import java.io.IOException; - -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import java.util.Random; - -import java.sql.Timestamp; - -import java.util.ArrayList; - -import java.lang.Double; - -public class dbConnect -{ - private static Connection db; - private static Statement stmt; - dbConnect() - {} - - - public static Long time() - { - java.util.Date date= new java.util.Date(); - Timestamp now=new Timestamp(date.getTime()); - return now.getTime(); - } - - //pulisce confmail e connessi da tutte le richieste maggiori di 10 minuti - private static void deletetmp() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - PreparedStatement preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE time<=?"); - preparedStmt.setLong (1,(time()-600000)); - preparedStmt.execute(); - preparedStmt = db.prepareStatement("DELETE FROM connessi WHERE time<=?"); - preparedStmt.setLong (1,(time()-600000)); - preparedStmt.execute(); - } - - //divide la stringa in user e password - private static String splitUsrPass(String userAndPass, int code) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - String user=null; - String pass=null; - ArrayList userPass= suString.stringToArrayList(userAndPass); - if(userPass.size()>=1) - user=userPass.get(0); - if(userPass.size()>=2) - pass=userPass.get(1); - - assert user != null; - if(!user.contains("@studio.unibo.it") && user.length()<16) - return "mail-error"; - else { - assert pass != null; - if(code==0) - return registration(user, pass); - else if(code==1) - return login(user, pass); - else if(code==2) - return recupero(user); - else - return "error"; - } - } - - //routin di gestione recupero pass - private static String recupero(String user) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - EmailSender email = new EmailSender(global.email, - global.emailPass, - "smtp.gmail.com", - global.email, - user, - "OGGETTO: recupero password", - "la tua password è "+returnQuery.getString("pass")); - email.inviaEmail(); - return "mail-pass-ok"; - } - else - return "user-error"; - } - else - return "user-error"; - } - - - //routin di gestione della registrazione - private static String registration(String user, String pass) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - String ran; - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - if(returnQuery.getString("user").compareTo(user)==0 && returnQuery.getString("pass").compareTo(pass)==0) - return "già-registrato"; - } - } - returnQuery=stmt.executeQuery("SELECT * FROM confmail where user='"+user+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - ran=returnQuery.getString("hash"); - if(returnQuery.getString("pass").compareTo(pass)!=0) - { - PreparedStatement preparedStmt = db.prepareStatement("UPDATE confmail SET pass =? where user=?"); - preparedStmt.setString (1,pass); - preparedStmt.setString (2,user); - preparedStmt.execute(); - } - } - else - { - Random random = new Random(); - ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); - //returnQuery=stmt.executeQuery("INSERT INTO confmail VALUES('"+user+"','"+pass+"',"+hash+"')"); - PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO confmail (user,pass,hash,time) VALUES(?,?,?,?)"); - preparedStmt.setString (1,user); - preparedStmt.setString (2,pass); - preparedStmt.setString (3,ran); - preparedStmt.setDouble (4,(double)time()); - preparedStmt.execute(); - } - } - else - { - Random random = new Random(); - ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); - //returnQuery=stmt.executeQuery("INSERT INTO confmail VALUES('"+user+"','"+pass+"',"+hash+"')"); - PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO confmail (user,pass,hash,time) VALUES(?,?,?,?)"); - preparedStmt.setString (1,user); - preparedStmt.setString (2,pass); - preparedStmt.setString (3,ran); - preparedStmt.setDouble (4,(double)time()); - preparedStmt.execute(); - } - EmailSender email = new EmailSender(global.email, - global.emailPass, - "smtp.gmail.com", - global.email, - user, - "OGGETTO: Registrazione App", - "per confermare la tua email clicka sul link: http://"+global.serverName+"/test?id="+ran); - email.inviaEmail(); - return "mail-reg-ok"; - } - - //routin conferma registrazione - private static String confirmRegistration(String hash) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM confmail where hash='"+hash+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO utenti (user,pass) VALUES(?,?)"); - preparedStmt.setString (1,returnQuery.getString("user")); - preparedStmt.setString (2,returnQuery.getString("pass")); - preparedStmt.execute(); - preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE hash=?"); - preparedStmt.setString (1,hash); - preparedStmt.execute(); - return "registrazione-ok"; - } - } - return "registrazione-error"; - } - - //routin di gestione login - private static String login(String user, String pass) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"' and pass='"+pass+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - if(returnQuery.getString("user").compareTo(user)==0 && returnQuery.getString("pass").compareTo(pass)==0) - return putConnessi(user); - } - } - return "login-error"; - } - - - //informazioni sulla connessione dell'utente - private String infoConnessi(String message) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - ArrayList split= suString.stringToArrayList(message); - if(split.size()>=1) - { - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi WHERE tempkey='"+split.get(1)+"'"); - if(returnQuery!=null) - { - if(returnQuery.next()) - { - return "loggato"; - } - } - } - return "request-login"; - } - - //inserisce l'utente in connessi - private static String putConnessi(String user) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - Random random = new Random(); - String ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); - PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO connessi (user,tempkey,thread,time) VALUES(?,?,?,?)"); - preparedStmt.setString (1,user); - preparedStmt.setString (2,ran); - preparedStmt.setBoolean (3,false); - preparedStmt.setDouble (4,(double)time()); - preparedStmt.execute(); - return ran; - } - - //segnalare morte di un thread - private String threadDead(String key) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - PreparedStatement preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE tempkey=?"); - preparedStmt.setString (1,key); - preparedStmt.execute(); - return "kill-ok"; - } - - //remposta il rimer dell'utente nella tabella connessi - private String connessiTimer(String key) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException - { - PreparedStatement preparedStmt = db.prepareStatement("UPDATE connessi SET time =? where tempkey=?"); - preparedStmt.setDouble (1,(double)time()); - preparedStmt.setString (2,key); - preparedStmt.execute(); - return "timer-settato"; - } - - private String exerciseAccept(String request) throws SQLException, IOException, NoSuchAlgorithmException { - ArrayList input=suString.stringToArrayList(request); - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi where tempkey='"+input.get(0)+"'"); - String utente=null; - if(returnQuery!=null) - { - if(returnQuery.next()) - utente=returnQuery.getString("user"); - } - if(utente!=null) - { - String[] esercizi=suString.stringToVectorString(EsNameParser.esName()); - for(String esercizio : esercizi) - { - if(esercizio.contentEquals(input.get(1)))//se l'esercizio esiste - { - if(MD5.digest(esercizio).contentEquals(input.get(2)))//se il digest è uguale - { - PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO esercizi (esercizio,utente,click,time) VALUES(?,?,?,?)"); - preparedStmt.setDouble(4, Double.parseDouble(input.get(3))); - preparedStmt.setInt (3,Integer.valueOf(input.get(4))); - preparedStmt.setString (2,utente); - preparedStmt.setString (1,input.get(1)); - preparedStmt.execute(); - return "es-ok"; - } - } - } - } - return "es-err"; - } - - private String userExercise(String request) throws SQLException { - ArrayList arrayResult=new ArrayList(); - ArrayList input=suString.stringToArrayList(request); - String result=null; - ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi where tempkey='"+input.get(0)+"'"); - String utente=null; - if(returnQuery!=null) - { - if(returnQuery.next()) - utente=returnQuery.getString("user"); - } - if(utente!=null) - { - returnQuery=stmt.executeQuery("SELECT * FROM esercizi where utente='"+utente+"'"); - while(returnQuery.next()) - { - arrayResult.add(returnQuery.getString("esercizio")+"/"+MD5.digest(returnQuery.getString("esercizio"))+"/"+returnQuery.getDouble("time")+"/"+returnQuery.getInt("click")); - } - result=suString.multiToString(arrayResult); - } - return result; - } - - private String cambiaPass(String request) throws ClassNotFoundException, SQLException, InstantiationException, IOException, IllegalAccessException { - ArrayList input=suString.stringToArrayList(request); - if(input.size()>=3) { - String result = login(input.get(0), input.get(1)); - if(!result.contains("err")) - { - PreparedStatement preparedStmt = db.prepareStatement("UPDATE utenti SET pass =? where user=?"); - preparedStmt.setString (1,input.get(2)); - preparedStmt.setString (2,input.get(0)); - preparedStmt.execute(); - return "cambiata"; - } - } - return "error"; - } - - public String dbQuery(String input) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, NoSuchAlgorithmException { - Class.forName("com.mysql.jdbc.Driver").newInstance(); - db = DriverManager.getConnection("jdbc:mysql://localhost/logintesi", "root", "csc@CerCo!"); - stmt = db.createStatement(); - deletetmp(); - if (input.charAt(0) == '0') - return splitUsrPass(input.substring(2), 0); - else if (input.charAt(0) == '1') - return splitUsrPass(input.substring(2), 1); - else if (input.charAt(0) == '2') - return recupero(input.substring(2)); - else if (input.charAt(0) == '3') - return confirmRegistration(input.substring(1)); - else if (input.charAt(0) == '4') - return EsNameParser.esName(); - else if (input.charAt(0) == '5') - return infoConnessi(input.substring(2)); - else if (input.charAt(0) == '6') - return connessiTimer(input.substring(2)); - /*else if (input.charAt(0) == '7') - return threadDead(input.substring(2));*/ - /*else if(input.charAt(0)=='8') - return aggToClient(input.substring(2)); - else if(input.charAt(0)=='9') - return aggForClient(input.substring(2)); - else if(input.charAt(0)=='a' && input.charAt(1)=='0') - return check(input.substring(3));*/ - else if (input.charAt(0) == '8') - return exerciseAccept(input.substring(2)); - else if (input.charAt(0) == '9') - return userExercise(input.substring(2)); - else if(input.charAt(0)=='a' && input.charAt(1)=='0') - return cambiaPass(input.substring(3)); - return "error"; - } -} diff --git a/Server/server/tesi/src/com/company/esercizi.xml b/Server/server/tesi/src/com/company/esercizi.xml deleted file mode 100644 index c28cd97..0000000 --- a/Server/server/tesi/src/com/company/esercizi.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - aalbero.xml - tautologia.xml - demorgan.xml - triviale.xml - test.xml - risolvibile.xml - demorgan2.xml - diff --git a/Server/server/tesi/src/com/company/esercizi.xml~ b/Server/server/tesi/src/com/company/esercizi.xml~ deleted file mode 100644 index 47eb032..0000000 --- a/Server/server/tesi/src/com/company/esercizi.xml~ +++ /dev/null @@ -1,4 +0,0 @@ - - - aalbero.xml - diff --git a/Server/server/tesi/src/com/company/global.class b/Server/server/tesi/src/com/company/global.class deleted file mode 100644 index 00f0bd3..0000000 Binary files a/Server/server/tesi/src/com/company/global.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/global.java b/Server/server/tesi/src/com/company/global.java deleted file mode 100644 index 2bf06c4..0000000 --- a/Server/server/tesi/src/com/company/global.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.company; - - -public class global { - public static final String listaEsercizi="/projects/logicplayer/Server/server/tesi/src/com/company/esercizi.xml"; - public static final String locationEsercizi="/projects/logicplayer/public_html/esercizi/"; - public static String home="/projects/logicplayer/Server/server/tesi/src/com/company/"; - public static String keyStorePass="123456"; - public static String keyStoreName="keystore.jks"; - public static String serverName="130.136.129.1"; - public static String email="confermaiscrizioneserver@gmail.com"; - public static String emailPass="tes6phev8n"; - public static int portaServer=25000; - public static int portaHttpServer=8000; - -} diff --git a/Server/server/tesi/src/com/company/guestServer.class b/Server/server/tesi/src/com/company/guestServer.class deleted file mode 100644 index 59b4c18..0000000 Binary files a/Server/server/tesi/src/com/company/guestServer.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/guestServer.java b/Server/server/tesi/src/com/company/guestServer.java deleted file mode 100644 index 1fb6ce9..0000000 --- a/Server/server/tesi/src/com/company/guestServer.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.company; - -import java.io.*; - -import javax.net.ssl.*; - -class guestServer implements Runnable -{ - private SSLSocket socket; - - guestServer(SSLSocket client) - { - socket=client; - } - - public void run() - { - try - { - - //Reading the message from the client - InputStream is = socket.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - String requestMessage = br.readLine(); - System.out.println("ho ricevuto: "+requestMessage); - /*System.out.println("Message received from client is "+returnMessage); - dbConnect request=new dbConnect(); - String returnQuery=request.dbQuery(returnMessage); - OutputStream os = socket.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - BufferedWriter bw = new BufferedWriter(osw); - System.out.println(returnQuery); - bw.write(returnQuery+"\n"); - bw.flush();*/ - if(requestMessage!=null) - { - dbConnect request = new dbConnect(); - String returnQuery; - if ( requestMessage.charAt(0) == '0' || - requestMessage.charAt(0) == '1' || - requestMessage.charAt(0) == '2' || - (requestMessage.charAt(0) == 'a' && requestMessage.charAt(1) == '0')) { - returnQuery = request.dbQuery(requestMessage); - OutputStream os = socket.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - BufferedWriter bw = new BufferedWriter(osw); - bw.write(returnQuery + "\n"); - bw.flush(); - System.out.println("ho inviato: " + returnQuery); - } - else - { - returnQuery = request.dbQuery("5/" + requestMessage); - if (returnQuery.contains("request-login") || returnQuery.contains("request-error")) - { - OutputStream os = socket.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - BufferedWriter bw = new BufferedWriter(osw); - bw.write(returnQuery + "\n"); - bw.flush(); - System.out.println("ho inviato: " + returnQuery); - } - else if (returnQuery.contains("loggato")) - { - personalServer nuovaConnessione = new personalServer(socket, requestMessage); - Thread t = new Thread(nuovaConnessione); - t.start(); - } - } - } - - } - catch (Exception e) - { - e.printStackTrace(); - } - - } -} diff --git a/Server/server/tesi/src/com/company/httpget$MyHandler.class b/Server/server/tesi/src/com/company/httpget$MyHandler.class deleted file mode 100644 index 7862be8..0000000 Binary files a/Server/server/tesi/src/com/company/httpget$MyHandler.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/httpget.class b/Server/server/tesi/src/com/company/httpget.class deleted file mode 100644 index b710c11..0000000 Binary files a/Server/server/tesi/src/com/company/httpget.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/httpget.java b/Server/server/tesi/src/com/company/httpget.java deleted file mode 100644 index 079cc01..0000000 --- a/Server/server/tesi/src/com/company/httpget.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.company; - -import java.io.*; -import java.net.*; -import java.security.NoSuchAlgorithmException; -import java.util.*; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import java.sql.*; - -public class httpget implements Runnable { - - httpget(){} - - public static Map splitQuery(String query) throws UnsupportedEncodingException - { - Map query_pairs = new LinkedHashMap(); - String[] pairs = query.split("&"); - for (String pair : pairs) - { - int idx = pair.indexOf("="); - query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); - } - return query_pairs; - } - - @Override - public void run() { - try { - HttpServer server = HttpServer.create(new InetSocketAddress(global.portaHttpServer), 0); - server.createContext("/test", new MyHandler()); - server.setExecutor(null); // creates a default executor - server.start(); - }catch (Exception e) - { - e.printStackTrace(); - } - } - - static class MyHandler implements HttpHandler - { - public void handle(HttpExchange t) throws IOException - { - - /*String response = "This is the response"; - System.out.println("mannaggia santa"); - t.sendResponseHeaders(200, response.length()); - OutputStream os = t.getResponseBody(); - os.write(response.getBytes());*/ - URI req=t.getRequestURI(); - String query=req.getQuery(); - Map result=splitQuery(query); - String id=result.get("id"); - //System.out.println(id); - try - { - dbConnect request=new dbConnect(); - String returnQuery=request.dbQuery("3"+id); - t.sendResponseHeaders(200, returnQuery.length()); - OutputStream os = t.getResponseBody(); - os.write(returnQuery.getBytes()); - os.close(); - } - catch(SQLException e) - {} - catch(ClassNotFoundException c) - {} - catch(IllegalAccessException a) - {} - catch(InstantiationException i) - {} catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } - } - -} diff --git a/Server/server/tesi/src/com/company/keystore.bks b/Server/server/tesi/src/com/company/keystore.bks deleted file mode 100644 index ecec326..0000000 Binary files a/Server/server/tesi/src/com/company/keystore.bks and /dev/null differ diff --git a/Server/server/tesi/src/com/company/keystore.crt b/Server/server/tesi/src/com/company/keystore.crt deleted file mode 100644 index e60e9db..0000000 Binary files a/Server/server/tesi/src/com/company/keystore.crt and /dev/null differ diff --git a/Server/server/tesi/src/com/company/keystore.jks b/Server/server/tesi/src/com/company/keystore.jks deleted file mode 100644 index 4edd598..0000000 Binary files a/Server/server/tesi/src/com/company/keystore.jks and /dev/null differ diff --git a/Server/server/tesi/src/com/company/personalServer.class b/Server/server/tesi/src/com/company/personalServer.class deleted file mode 100644 index 1d5b025..0000000 Binary files a/Server/server/tesi/src/com/company/personalServer.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/personalServer.java b/Server/server/tesi/src/com/company/personalServer.java deleted file mode 100644 index 1d338eb..0000000 --- a/Server/server/tesi/src/com/company/personalServer.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.company; - -import java.io.BufferedWriter; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import javax.net.ssl.*; - - -import java.util.ArrayList; - -class personalServer implements Runnable -{ - private SSLSocket socket; - private String key; - private String requestMessage; - - personalServer(SSLSocket client, String message) - { - socket=client; - ArrayList split= suString.stringToArrayList(message); - key=split.get(1); - requestMessage=message; - } - - public void run() - { - try - { - dbConnect request=new dbConnect(); - String returnQuery=request.dbQuery(requestMessage); - OutputStream os = socket.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os); - BufferedWriter bw = new BufferedWriter(osw); - bw.write(returnQuery+"\n"); - bw.flush(); - System.out.println("ho inviato: "+returnQuery); - request.dbQuery("6/"+key); - socket.close(); - } - catch (Exception e) - { - try - { - e.printStackTrace(); - dbConnect request=new dbConnect(); - request.dbQuery("7/"+key); - } - catch (Exception k) - { - //k.printStackTrace(); - System.out.println("PANIC!"); - } - } - } -} diff --git a/Server/server/tesi/src/com/company/suString.class b/Server/server/tesi/src/com/company/suString.class deleted file mode 100644 index 6d094cb..0000000 Binary files a/Server/server/tesi/src/com/company/suString.class and /dev/null differ diff --git a/Server/server/tesi/src/com/company/suString.java b/Server/server/tesi/src/com/company/suString.java deleted file mode 100644 index 666febe..0000000 --- a/Server/server/tesi/src/com/company/suString.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.company; - -import java.util.ArrayList; -import java.util.Collections; - -public class suString -{ - suString() - {} - - - public static ArrayList stringToArrayList(String string) - { - ArrayList returnValue=new ArrayList(); - int j=0; - for(int i=0;i vectorStringToArrayList(String[] vectorString) - { - ArrayList returnValue=new ArrayList(); - Collections.addAll(returnValue, vectorString); - return returnValue; - } - - public static String arrayListToString (ArrayList arraylist) - { - String returnValue= ""; - for(int i=0;i arraylist) - { - String[] returnValue=new String[arraylist.size()]; - for(int i=0;i input) - { - String returnValue=null; - int size=input.size(); - for(int i=0;i stringToMultiArray(String input) - { - ArrayList result=new ArrayList(); - int j=0; - for(int i=0;i - - - - - - - - - - \ No newline at end of file diff --git a/Server/webApp/.prova.php.swp b/Server/webApp/.prova.php.swp deleted file mode 100644 index 48d1c1c..0000000 Binary files a/Server/webApp/.prova.php.swp and /dev/null differ diff --git a/Server/webApp/esercizi/aalbero.xml b/Server/webApp/esercizi/aalbero.xml deleted file mode 100644 index 8591816..0000000 --- a/Server/webApp/esercizi/aalbero.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - a - b - - - c - d - - - - diff --git a/Server/webApp/esercizi/demorgan.xml b/Server/webApp/esercizi/demorgan.xml deleted file mode 100644 index 1445f1f..0000000 --- a/Server/webApp/esercizi/demorgan.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - A - B - - - - - A - - - B - - - - - - - 13 - 60 - 5 - - diff --git a/Server/webApp/esercizi/demorgan2.xml b/Server/webApp/esercizi/demorgan2.xml deleted file mode 100644 index 1445f1f..0000000 --- a/Server/webApp/esercizi/demorgan2.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - A - B - - - - - A - - - B - - - - - - - 13 - 60 - 5 - - diff --git a/Server/webApp/esercizi/risolvibile.xml b/Server/webApp/esercizi/risolvibile.xml deleted file mode 100644 index ee115e9..0000000 --- a/Server/webApp/esercizi/risolvibile.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - A - - B - - - R - - - - A - B - - - R - - - - - A - - - - - B - - - 13 - 60 - 5 - - diff --git a/Server/webApp/esercizi/tautologia.xml b/Server/webApp/esercizi/tautologia.xml deleted file mode 100644 index 4c8d1c3..0000000 --- a/Server/webApp/esercizi/tautologia.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - A - A - - - - 13 - 60 - 5 - - diff --git a/Server/webApp/esercizi/test.xml b/Server/webApp/esercizi/test.xml deleted file mode 100644 index 4a1e680..0000000 --- a/Server/webApp/esercizi/test.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - top - - - - - - - diff --git a/Server/webApp/index.html b/Server/webApp/index.html deleted file mode 100755 index 62e3446..0000000 --- a/Server/webApp/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - -

Benvenuto nella pagina di amministazione

-
- - - -
- - diff --git a/Server/webApp/index.html~ b/Server/webApp/index.html~ deleted file mode 100755 index e566e53..0000000 --- a/Server/webApp/index.html~ +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - -

Benvenuto nella pagina di amministazione

-
- - - -
- - \ No newline at end of file diff --git a/Server/webApp/login.css b/Server/webApp/login.css deleted file mode 100755 index dc4f5da..0000000 --- a/Server/webApp/login.css +++ /dev/null @@ -1,16 +0,0 @@ -#login -{ - width:100%; - display:inline-block; - text-align:center; -} -#esTable -{ - display:block; - float:left; -} -#tabella -{ - display:block; - float:left; -} diff --git a/Server/webApp/login.js b/Server/webApp/login.js deleted file mode 100755 index e9afdc4..0000000 --- a/Server/webApp/login.js +++ /dev/null @@ -1,65 +0,0 @@ -function change() -{ -/*Quando viene chiamata, modifica il campo "location" di document*/ -/*effettuando un redirect sulla pagina main.php*/ -document.location.href="./main.php"; -} - - - - -function login() -{ - var jsonlogin=new Object(); - jsonlogin.username=$('#username').val(); //recupero i dati di login dai rispettivi campi dell'HTML - jsonlogin.password=$('#password').val(); - var sendstr = JSON.stringify(jsonlogin); //creo il JSON di invio al server - $.ajax - ({ - type: 'POST', - url: 'login.php', - async: false, - contentType: 'application/json; charset=utf-8', - dataType: 'json', - data: sendstr, - success: function(response) - { //in caso di successo della richiesta viene eseguita questa funzione - if (response['result']=="login effettuato con successo") - //cioè se il server ha ritornato che l'utente è stato trovato con successo - change(); - else - $("#errlogin").fadeIn(); - setTimeout(function(){$("#errlogin").fadeOut()}, 2000); - - } - }); -} - - - - - -$(document).ready -( - function () - { - $("#errlogin").hide(); //nasconde i div di errore del login - //funzione che effettua login se bottone viene cliccato - $("#loginForm").click - ( - function() - { - login(); - } - ); - //funzione che effettua login se tasto "INVIO" viene cliccato - $("#password").keyup( - function(invio) - { - if(invio.keyCode == 13) { - login(); - } - - }); - } -); diff --git a/Server/webApp/login.js~ b/Server/webApp/login.js~ deleted file mode 100755 index 5866524..0000000 --- a/Server/webApp/login.js~ +++ /dev/null @@ -1,66 +0,0 @@ -function change() -{ -/*Quando viene chiamata, modifica il campo "location" di document*/ -/*effettuando un redirect sulla pagina main.php*/ -document.location.href="./prova.html"; -} - - - - -function login() -{ - var jsonlogin=new Object(); - jsonlogin.username=$('#username').val(); //recupero i dati di login dai rispettivi campi dell'HTML - jsonlogin.password=$('#password').val(); - window.alert($('#username').val()+$('#password').val()); - var sendstr = JSON.stringify(jsonlogin); //creo il JSON di invio al server - $.ajax - ({ - type: 'POST', - url: 'login.php', - async: false, - contentType: 'application/json; charset=utf-8', - dataType: 'json', - data: sendstr, - success: function(response) - { //in caso di successo della richiesta viene eseguita questa funzione - if (response['result']=="login effettuato con successo") - //cioè se il server ha ritornato che l'utente è stato trovato con successo - change(); - else - $("#errlogin").fadeIn(); - setTimeout(function(){$("#errlogin").fadeOut()}, 2000); - - } - }); -} - - - - - -$(document).ready -( - function () - { - $("#errlogin").hide(); //nasconde i div di errore del login - //funzione che effettua login se bottone viene cliccato - $("#loginForm").click - ( - function() - { - login(); - } - ); - //funzione che effettua login se tasto "INVIO" viene cliccato - $("#password").keyup( - function(invio) - { - if(invio.keyCode == 13) { - login(); - } - - }); - } -); diff --git a/Server/webApp/login.php b/Server/webApp/login.php deleted file mode 100755 index 4053a81..0000000 --- a/Server/webApp/login.php +++ /dev/null @@ -1,41 +0,0 @@ -"errore nella connessione al database"); - $ris=json_encode($arr); - echo $ris; - die; - } - else - { - $str="SELECT * FROM admin WHERE username='".$result->username."' AND password='".$result->password."';"; - $exists= mysqli_query($con,$str); - if (!($exists)) - { - $arr=array('result'=>"errore nella ricerca all'interno del database"); - $ris=json_encode($arr); - echo $ris; - die; - } - $res=mysqli_num_rows($exists); - if ($res==1) - { - $ID=mysqli_fetch_array($exists); - $_SESSION["username"]=$result->username; - $arr = array('result'=>"login effettuato con successo"); - $ris=json_encode($arr); - echo $ris; - } - else - { - $arr= array('result'=>"Utente non trovato"); - $ris=json_encode($arr); - echo $ris; - } - } - mysqli_close($con) -?> diff --git a/Server/webApp/login.php~ b/Server/webApp/login.php~ deleted file mode 100755 index 5206e97..0000000 --- a/Server/webApp/login.php~ +++ /dev/null @@ -1,42 +0,0 @@ -"errore nella connessione al database"); - $ris=json_encode($arr); - echo $ris; - die; - } - else - { - $str="SELECT * FROM admin WHERE username='danilo.berardinelli' AND password='123stella';"; - $exists= mysqli_query($con,$str); - if (!($exists)) - { - $arr=array('result'=>"errore nella ricerca all'interno del database"); - $ris=json_encode($arr); - echo $ris; - die; - } - $res=mysqli_num_rows($exists); - if ($res==1) - { - $ID=mysqli_fetch_array($exists); - $_SESSION["username"]=$result->username; - $arr = array('result'=>"login effettuato con successo"); - $ris=json_encode($arr); - echo $ris; - } - else - { - $arr= array('result'=>"Utente non trovato"); - $ris=json_encode($arr); - echo $ris; - } - - } - mysqli_close($con) -?> diff --git a/Server/webApp/logout.js b/Server/webApp/logout.js deleted file mode 100755 index 9817f6a..0000000 --- a/Server/webApp/logout.js +++ /dev/null @@ -1,18 +0,0 @@ -function change() -{ - document.location.href="index.html"; -} -function logout() -{ - $.ajax({ - type: 'POST', - url: 'logout.php', - async: false - }).success - ( - function(response) - { - change(); - } - ); -} diff --git a/Server/webApp/logout.php b/Server/webApp/logout.php deleted file mode 100755 index 7060d00..0000000 --- a/Server/webApp/logout.php +++ /dev/null @@ -1,7 +0,0 @@ -"logout effettuato con successo"); - $ris=json_encode($arr); - echo $ris; -?> diff --git a/Server/webApp/main.php b/Server/webApp/main.php deleted file mode 100755 index 2866325..0000000 --- a/Server/webApp/main.php +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - -
- Select file to upload: - - -
-
-
- - - - -
Lista Esercizi
- - - - - - - - - diff --git a/Server/webApp/printEs.php b/Server/webApp/printEs.php deleted file mode 100755 index 6c4b6e8..0000000 --- a/Server/webApp/printEs.php +++ /dev/null @@ -1,13 +0,0 @@ -"; - - while (false !== ($file = readdir($handle))) { - if($file!="." && $file!="..") - echo "$file
"; - } - - closedir($handle); - } -?> diff --git a/Server/webApp/prova.html~ b/Server/webApp/prova.html~ deleted file mode 100755 index 0e3d827..0000000 --- a/Server/webApp/prova.html~ +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/Server/webApp/prova.js b/Server/webApp/prova.js deleted file mode 100755 index 62d03ef..0000000 --- a/Server/webApp/prova.js +++ /dev/null @@ -1,72 +0,0 @@ -function update(event) -{ - var str; - if (event==null) - str='all'; - else{ - var object=event.target; - str=object.getAttribute("esercizio"); - } - var query="./serverRequest.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) - { - $("#tabella").empty(); - $("#tabella").append(""); - $.each(val.esercizi, function(i, item) { - var id="es"+i; - for(j=0;j').attr('id',id_i)); - id_i="#"+id_i; - $(id_i).append($('"); - $.each(val.esercizi, function(i, item) { - var id="ex"+i; - $("#esTable").append($('').attr('id',id)); - $("#ex"+i).append($('
Nome EsercizioStudenteclick
Nome EsercizioStudenteClick').text(item.esercizio)); - $(id_i).append($('').text(item.risultati[j].utente)); - $(id_i).append($('').text(item.risultati[j].click)); - $(id_i).append($('').attr('risultato',item.risultati[j].click)); - } - }); - }, - }); -} - -function esList() -{ - var query="./xmlPharse.php"; - $.ajax({ - url:query, - type:"GET", - async: "true", - dataType: "json", - accepts: {json:"application/json"}, - success:function(val) - { - $("#esTable").empty(); - $("#esTable").append("
Nome Esercizio
').text(item)); - $("#ex"+i).append($('').attr('esercizio',item)); - $("#ex"+i).append($('').attr('esercizio',item)); - }); - $("#esTable").append(''); - $(".seleziona").click(function(event){update(event);}); - }, - }); -} - -$(document).ready(function(){ - esList(); - update(); - $(".seleziona").click(function(event){update(event);}); -}); diff --git a/Server/webApp/prova.pho b/Server/webApp/prova.pho deleted file mode 100755 index e69de29..0000000 diff --git a/Server/webApp/prova.pho~ b/Server/webApp/prova.pho~ deleted file mode 100755 index e69de29..0000000 diff --git a/Server/webApp/prova.php b/Server/webApp/prova.php deleted file mode 100755 index 6284333..0000000 --- a/Server/webApp/prova.php +++ /dev/null @@ -1,39 +0,0 @@ - 500000) { - echo "Sorry, your file is too large."; - $uploadOk = 0; - } - // Check if $uploadOk is set to 0 by an error - if ($uploadOk == 0) { - echo "Sorry, your file was not uploaded."; - // 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."; - } - } - echo exec("php-cli main.php"); -?> - - - - - -
- Select file to upload: - - -
- diff --git a/Server/webApp/prova.php~ b/Server/webApp/prova.php~ deleted file mode 100755 index 0f7fcaa..0000000 --- a/Server/webApp/prova.php~ +++ /dev/null @@ -1,44 +0,0 @@ - 500000) { - echo "Sorry, your file is too large."; - $uploadOk = 0; - } - // Allow certain file formats - /*if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" - && $imageFileType != "gif" ) { - echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; - $uploadOk = 0; - }*/ - // Check if $uploadOk is set to 0 by an error - if ($uploadOk == 0) { - echo "Sorry, your file was not uploaded."; - // 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."; - } - } -?> diff --git a/Server/webApp/prova.txt b/Server/webApp/prova.txt deleted file mode 100755 index 28c1837..0000000 --- a/Server/webApp/prova.txt +++ /dev/null @@ -1,2 +0,0 @@ -mi sei riuscito a scaricare - diff --git a/Server/webApp/prova.txt~ b/Server/webApp/prova.txt~ deleted file mode 100755 index e69de29..0000000 diff --git a/Server/webApp/serverRequest.php b/Server/webApp/serverRequest.php deleted file mode 100755 index 9140fd7..0000000 --- a/Server/webApp/serverRequest.php +++ /dev/null @@ -1,54 +0,0 @@ -"errore nella connessione al database"); - $ris=json_encode($arr); - echo $ris; - die; - } - if($result->name=='all') - $str="SELECT * FROM esercizi;"; - else - $str="SELECT * FROM esercizi WHERE esercizio='".$result->name."' ORDER BY esercizio;"; - $str=mysqli_query($con,$str); - if (!$str) - { - $arr= array('result'=>"nessun elemento presente"); - $ris=json_encode($arr); - echo $ris; - die; - } - $esercizi; - $risp=mysqli_fetch_array($str); - $risultati; - $esercizio['esercizio']=$risp['esercizio']; - do - { - if($esercizio['esercizio']==$risp['esercizio']) - { - //aggiungo utenti e click ell'es corrente - $risultati[]=array('id'=>$risp['id'],'utente'=>$risp['utente'],'click'=>$risp['click']); - } - else - { - //reimposto i campi per un nuovo esercizio - $esercizio['risultati']=$risultati; - $esercizi[]=$esercizio; - unset($esercizio); - unset($risultati); - $esercizio['esercizio']=$risp['esercizio']; - $risultati[]=array('id'=>$risp['id'],'utente'=>$risp['utente'],'click'=>$risp['click']); - } - }while($risp=mysqli_fetch_array($str)); - $esercizio['risultati']=$risultati; - $esercizi[]=$esercizio; - $ex=array('esercizi'=>$esercizi); - unset($esercizio); - unset($risultati); - $return_json=__json_encode($ex); - echo $return_json; -?> diff --git a/Server/webApp/upload.php b/Server/webApp/upload.php deleted file mode 100755 index 67c3a7a..0000000 --- a/Server/webApp/upload.php +++ /dev/null @@ -1,53 +0,0 @@ - 500000) { - echo "Sorry, your file is too large."; - $uploadOk = 0; - } - // Allow certain file formats - /*if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" - && $imageFileType != "gif" ) { - echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; - $uploadOk = 0; - }*/ - // Check if $uploadOk is set to 0 by an error - if ($uploadOk == 0) { - echo "Sorry, your file was not uploaded."; - // 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."; - } - } -?> - - - - - -
- -
- diff --git a/Server/webApp/upload.php~ b/Server/webApp/upload.php~ deleted file mode 100755 index 9cf7a77..0000000 --- a/Server/webApp/upload.php~ +++ /dev/null @@ -1,33 +0,0 @@ - diff --git a/Server/webApp/util.php b/Server/webApp/util.php deleted file mode 100755 index 0c7fbec..0000000 --- a/Server/webApp/util.php +++ /dev/null @@ -1,41 +0,0 @@ - $value ) { - $items [] = __json_encode ( "$key" ) . ':' . __json_encode ( $value ); - } - $json = '{' . implode ( ',', $items ) . '}'; - } - } elseif (is_string ( $data )) { - $json = '"' . addcslashes ( $data, '\\"' ) . '"'; - } else { - // int, floats, bools, null - $json = strtolower ( var_export ( $data, true ) ); - } - return $json; -} - -function GET_check() -{ -if (!isset($_GET['scope']) or !isset($_GET['type']) or !($_GET['lat']) or !isset($_GET['lng']) or !isset($_GET['radius']) or !isset($_GET['timemin']) or !isset($_GET['timemax']) or !isset($_GET['status'])) - return false; -else return true; -} -function POST_check($params) -{ -if (!$params->type or !$params->lat or !$params->lng) return false; -else return true; -} - -function NOTIFY_check($params) -{ -if (!$params->event_id or !$params->lat or !$params->lng or !$params->status) return false; -else return true; -} -?> diff --git a/Server/webApp/xmlPharse.php b/Server/webApp/xmlPharse.php deleted file mode 100755 index a2090df..0000000 --- a/Server/webApp/xmlPharse.php +++ /dev/null @@ -1,11 +0,0 @@ -esercizio as $esercizio) - { - $esercizi['esercizi'][]="$esercizio"; - } - $return_json=__json_encode($esercizi); - echo $return_json; -?> diff --git a/logintesi.sql b/logintesi.sql new file mode 100644 index 0000000..ec57f9c --- /dev/null +++ b/logintesi.sql @@ -0,0 +1,195 @@ +-- phpMyAdmin SQL Dump +-- version 4.0.10deb1 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generato il: Nov 14, 2014 alle 16:45 +-- Versione del server: 5.5.38-0ubuntu0.14.04.1 +-- Versione PHP: 5.5.9-1ubuntu4.4 + +USE logintesi; + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `logintesi` +-- + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `admin` +-- + +CREATE TABLE IF NOT EXISTS `admin` ( + `username` varchar(30) COLLATE utf8_bin NOT NULL, + `password` varchar(30) COLLATE utf8_bin NOT NULL, + UNIQUE KEY `username` (`username`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dump dei dati per la tabella `admin` +-- + +INSERT INTO `admin` (`username`, `password`) VALUES +('danilo.berardinelli', '123stella'); + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `aggprova` +-- + +CREATE TABLE IF NOT EXISTS `aggprova` ( + `chiave` varchar(50) COLLATE utf8_bin NOT NULL, + `time` double NOT NULL, + `checks` int(11) NOT NULL, + PRIMARY KEY (`chiave`), + UNIQUE KEY `key` (`chiave`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dump dei dati per la tabella `aggprova` +-- + +INSERT INTO `aggprova` (`chiave`, `time`, `checks`) VALUES +('10157426982320510', 1415145803639, 1), +('10244937857444543', 1415284664538, 1), +('10308106918353456', 1415243065790, 1), +('10385651273134167', 1415289922479, 1), +('10414239987472834', 1415285560312, 1), +('1097785784725414', 1415284853312, 1), +('10983265112121106', 1415242393295, 1), +('1286713061377424', 1415036978051, 1), +('1408285479764558', 1415278883075, 1), +('1490801371315190', 1415285333816, 1), +('1741331087669285', 1415811578318, 1), +('18516070104459806', 1415276863684, 1), +('2217380018747176', 1415145507080, 1), +('2260502250327125', 1415284745047, 1), +('2473377684156933', 1415284628252, 1), +('2504043195911198', 1415285115955, 1), +('2686774762838581', 1415278911038, 1), +('2744239278608085', 1415036291300, 1), +('2956509786688513', 1415271435934, 1), +('2961042458190883', 1415277033282, 1), +('3109253928772677', 1415284540445, 1), +('3311335330604631', 1415237862686, 1), +('3486758220086141', 1415242975878, 1), +('3571361357113219', 1415285156048, 1), +('4091389111256716', 1415025754182, 1), +('42848425102166715', 1415242068918, 1), +('4457124515989723', 1415811050681, 1), +('4577865146663611', 1415285170075, 1), +('4796791993070257', 1415288554998, 1), +('5005653368852396', 1415285312682, 1), +('5226217037177487', 1415145721770, 1), +('5308112899337743', 1415037335958, 1), +('5362524692721963', 1415811381242, 1), +('5382075363462279', 1415272904986, 1), +('5650512812480934', 1415271249954, 1), +('5735648814288922', 1415036889526, 1), +('62029084106069252', 1415241839377, 1), +('6712150141518271', 1415285510994, 1), +('6786243849285602', 1415811389915, 1), +('6992436366972266', 1415242705239, 1), +('7106071695334106', 1415811170493, 1), +('7158700078303143', 1415284726466, 1), +('7307203380313108', 1415819825863, 1), +('75372031101482498', 1415284519581, 1), +('7703030541673651', 1415272914342, 1), +('8065501483698608', 1415819808393, 1), +('8468895456378674', 1415241733824, 1), +('8760904545449404', 1415285230458, 1), +('8838732364680254', 1415271877269, 1), +('9576830372163956', 1415283251776, 1); + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `confmail` +-- + +CREATE TABLE IF NOT EXISTS `confmail` ( + `user` varchar(50) COLLATE utf8_bin NOT NULL, + `pass` varchar(50) COLLATE utf8_bin NOT NULL, + `hash` varchar(50) COLLATE utf8_bin NOT NULL, + `time` double DEFAULT NULL, + UNIQUE KEY `user` (`user`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `connessi` +-- + +CREATE TABLE IF NOT EXISTS `connessi` ( + `user` varchar(50) COLLATE utf8_bin NOT NULL, + `tempkey` varchar(50) COLLATE utf8_bin NOT NULL, + `thread` tinyint(1) NOT NULL, + `time` double NOT NULL, + UNIQUE KEY `tempkey` (`tempkey`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dump dei dati per la tabella `connessi` +-- + +INSERT INTO `connessi` (`user`, `tempkey`, `thread`, `time`) VALUES +('danilo.berardinelli@studio.unibo.it', '2545550210880139', 0, 1415975986391); + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `esercizi` +-- + +CREATE TABLE IF NOT EXISTS `esercizi` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `esercizio` varchar(20) COLLATE utf8_bin NOT NULL, + `utente` varchar(50) COLLATE utf8_bin NOT NULL, + `click` int(11) NOT NULL, + `time` double NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=4 ; + +-- +-- Dump dei dati per la tabella `esercizi` +-- + +INSERT INTO `esercizi` (`id`, `esercizio`, `utente`, `click`, `time`) VALUES +(1, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 1, 1415923860705), +(2, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 1, 1415975624027), +(3, 'tautologia.xml', 'danilo.berardinelli@studio.unibo.it', 3, 1415975983857); + +-- -------------------------------------------------------- + +-- +-- Struttura della tabella `utenti` +-- + +CREATE TABLE IF NOT EXISTS `utenti` ( + `user` varchar(50) COLLATE utf8_bin NOT NULL, + `pass` varchar(15) COLLATE utf8_bin NOT NULL, + UNIQUE KEY `user` (`user`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dump dei dati per la tabella `utenti` +-- + +INSERT INTO `utenti` (`user`, `pass`) VALUES +('danilo.berardinelli@studio.unibo.it', '123stella'); + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/server/tesi/.idea/compiler.xml b/server/tesi/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/server/tesi/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/server/tesi/.idea/copyright/profiles_settings.xml b/server/tesi/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/server/tesi/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/server/tesi/.idea/description.html b/server/tesi/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/server/tesi/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/server/tesi/.idea/encodings.xml b/server/tesi/.idea/encodings.xml new file mode 100644 index 0000000..d821048 --- /dev/null +++ b/server/tesi/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/server/tesi/.idea/misc.xml b/server/tesi/.idea/misc.xml new file mode 100644 index 0000000..728f444 --- /dev/null +++ b/server/tesi/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/server/tesi/.idea/modules.xml b/server/tesi/.idea/modules.xml new file mode 100644 index 0000000..d9c1a63 --- /dev/null +++ b/server/tesi/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/server/tesi/.idea/project-template.xml b/server/tesi/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/server/tesi/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/server/tesi/.idea/scopes/scope_settings.xml b/server/tesi/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/server/tesi/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/server/tesi/.idea/uiDesigner.xml b/server/tesi/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/server/tesi/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/tesi/.idea/vcs.xml b/server/tesi/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/server/tesi/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/server/tesi/.idea/workspace.xml b/server/tesi/.idea/workspace.xml new file mode 100644 index 0000000..7ff99c0 --- /dev/null +++ b/server/tesi/.idea/workspace.xml @@ -0,0 +1,1003 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Control flow issues + + + + + InfiniteLoopStatement + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1415700559063 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + tesi + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class b/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class new file mode 100644 index 0000000..cfca534 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/DirectoryWatcher.class differ diff --git a/server/tesi/out/production/tesi/com/company/EmailSender.class b/server/tesi/out/production/tesi/com/company/EmailSender.class new file mode 100644 index 0000000..f7d68c0 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/EmailSender.class differ diff --git a/server/tesi/out/production/tesi/com/company/EsNameParser.class b/server/tesi/out/production/tesi/com/company/EsNameParser.class new file mode 100644 index 0000000..6b5cef6 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/EsNameParser.class differ diff --git a/server/tesi/out/production/tesi/com/company/MD5.class b/server/tesi/out/production/tesi/com/company/MD5.class new file mode 100644 index 0000000..e5246c0 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/MD5.class differ diff --git a/server/tesi/out/production/tesi/com/company/dbConnect.class b/server/tesi/out/production/tesi/com/company/dbConnect.class new file mode 100644 index 0000000..982753e Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/dbConnect.class differ diff --git a/server/tesi/out/production/tesi/com/company/esercizi.xml b/server/tesi/out/production/tesi/com/company/esercizi.xml new file mode 100644 index 0000000..50ba729 --- /dev/null +++ b/server/tesi/out/production/tesi/com/company/esercizi.xml @@ -0,0 +1,5 @@ + + + aalbero.xml + tautologia.xml + diff --git a/server/tesi/out/production/tesi/com/company/global.class b/server/tesi/out/production/tesi/com/company/global.class new file mode 100644 index 0000000..dc41980 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/global.class differ diff --git a/server/tesi/out/production/tesi/com/company/guestServer.class b/server/tesi/out/production/tesi/com/company/guestServer.class new file mode 100644 index 0000000..dbbf2f7 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/guestServer.class differ diff --git a/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class b/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class new file mode 100644 index 0000000..0db2b2c Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/httpget$MyHandler.class differ diff --git a/server/tesi/out/production/tesi/com/company/httpget.class b/server/tesi/out/production/tesi/com/company/httpget.class new file mode 100644 index 0000000..9593347 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/httpget.class differ diff --git a/server/tesi/out/production/tesi/com/company/keystore.bks b/server/tesi/out/production/tesi/com/company/keystore.bks new file mode 100644 index 0000000..ecec326 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/keystore.bks differ diff --git a/server/tesi/out/production/tesi/com/company/keystore.crt b/server/tesi/out/production/tesi/com/company/keystore.crt new file mode 100644 index 0000000..e60e9db Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/keystore.crt differ diff --git a/server/tesi/out/production/tesi/com/company/keystore.jks b/server/tesi/out/production/tesi/com/company/keystore.jks new file mode 100644 index 0000000..4edd598 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/keystore.jks differ diff --git a/server/tesi/out/production/tesi/com/company/personalServer.class b/server/tesi/out/production/tesi/com/company/personalServer.class new file mode 100644 index 0000000..81fabd7 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/personalServer.class differ diff --git a/server/tesi/out/production/tesi/com/company/suString.class b/server/tesi/out/production/tesi/com/company/suString.class new file mode 100644 index 0000000..d504a2d Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/suString.class differ diff --git a/server/tesi/out/production/tesi/com/company/superServer.class b/server/tesi/out/production/tesi/com/company/superServer.class new file mode 100644 index 0000000..74de9bc Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/superServer.class differ diff --git a/server/tesi/out/production/tesi/com/company/xmlOperation.class b/server/tesi/out/production/tesi/com/company/xmlOperation.class new file mode 100644 index 0000000..143c104 Binary files /dev/null and b/server/tesi/out/production/tesi/com/company/xmlOperation.class differ diff --git a/server/tesi/out/production/testi/com/company/DeleteFileExample.class b/server/tesi/out/production/testi/com/company/DeleteFileExample.class new file mode 100644 index 0000000..0e024f6 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/DeleteFileExample.class differ diff --git a/server/tesi/out/production/testi/com/company/EmailSender.class b/server/tesi/out/production/testi/com/company/EmailSender.class new file mode 100644 index 0000000..e4c00d6 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/EmailSender.class differ diff --git a/server/tesi/out/production/testi/com/company/EsNameParser.class b/server/tesi/out/production/testi/com/company/EsNameParser.class new file mode 100644 index 0000000..bc79739 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/EsNameParser.class differ diff --git a/server/tesi/out/production/testi/com/company/dbConnect.class b/server/tesi/out/production/testi/com/company/dbConnect.class new file mode 100644 index 0000000..c6a1217 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/dbConnect.class differ diff --git a/server/tesi/out/production/testi/com/company/esercizi.xml b/server/tesi/out/production/testi/com/company/esercizi.xml new file mode 100644 index 0000000..2d06edb --- /dev/null +++ b/server/tesi/out/production/testi/com/company/esercizi.xml @@ -0,0 +1,3 @@ + + albero.xml + \ No newline at end of file diff --git a/server/tesi/out/production/testi/com/company/guestServer.class b/server/tesi/out/production/testi/com/company/guestServer.class new file mode 100644 index 0000000..cc9ff21 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/guestServer.class differ diff --git a/server/tesi/out/production/testi/com/company/httpget$MyHandler.class b/server/tesi/out/production/testi/com/company/httpget$MyHandler.class new file mode 100644 index 0000000..2426f4a Binary files /dev/null and b/server/tesi/out/production/testi/com/company/httpget$MyHandler.class differ diff --git a/server/tesi/out/production/testi/com/company/httpget.class b/server/tesi/out/production/testi/com/company/httpget.class new file mode 100644 index 0000000..740b705 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/httpget.class differ diff --git a/server/tesi/out/production/testi/com/company/keystore.bks b/server/tesi/out/production/testi/com/company/keystore.bks new file mode 100644 index 0000000..ecec326 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/keystore.bks differ diff --git a/server/tesi/out/production/testi/com/company/keystore.crt b/server/tesi/out/production/testi/com/company/keystore.crt new file mode 100644 index 0000000..e60e9db Binary files /dev/null and b/server/tesi/out/production/testi/com/company/keystore.crt differ diff --git a/server/tesi/out/production/testi/com/company/keystore.jks b/server/tesi/out/production/testi/com/company/keystore.jks new file mode 100644 index 0000000..4edd598 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/keystore.jks differ diff --git a/server/tesi/out/production/testi/com/company/personalServer.class b/server/tesi/out/production/testi/com/company/personalServer.class new file mode 100644 index 0000000..03678d6 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/personalServer.class differ diff --git a/server/tesi/out/production/testi/com/company/suString.class b/server/tesi/out/production/testi/com/company/suString.class new file mode 100644 index 0000000..d8301c9 Binary files /dev/null and b/server/tesi/out/production/testi/com/company/suString.class differ diff --git a/server/tesi/out/production/testi/com/company/superServer.class b/server/tesi/out/production/testi/com/company/superServer.class new file mode 100644 index 0000000..44b721f Binary files /dev/null and b/server/tesi/out/production/testi/com/company/superServer.class differ diff --git a/server/tesi/src/com/company/DeleteFileExample.class b/server/tesi/src/com/company/DeleteFileExample.class new file mode 100644 index 0000000..25a7db8 Binary files /dev/null and b/server/tesi/src/com/company/DeleteFileExample.class differ diff --git a/server/tesi/src/com/company/DirectoryWatcher.class b/server/tesi/src/com/company/DirectoryWatcher.class new file mode 100644 index 0000000..fb7ef98 Binary files /dev/null and b/server/tesi/src/com/company/DirectoryWatcher.class differ diff --git a/server/tesi/src/com/company/DirectoryWhatcer.java b/server/tesi/src/com/company/DirectoryWhatcer.java new file mode 100644 index 0000000..8b376a1 --- /dev/null +++ b/server/tesi/src/com/company/DirectoryWhatcer.java @@ -0,0 +1,147 @@ +package com.company; + +import java.io.*; +import java.nio.file.Path; +import java.nio.file.StandardWatchEventKinds; +import java.nio.file.WatchEvent; +import java.nio.file.WatchEvent.Kind; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; +import java.security.NoSuchAlgorithmException; +import java.sql.SQLException; +import java.util.ArrayList; + +// Simple class to watch directory events. +class DirectoryWatcher implements Runnable { + + private Path path; + + public DirectoryWatcher(Path path) { + this.path = path; + } + + //rimuove tutti gli elementi non validi + private void pulisciCartella() { + File dir = new File(global.locationEsercizi); + String[] lista=dir.list(); + for(String name : lista) + { + if (!EsNameParser.check(name)) + { + File file = new File(global.locationEsercizi+name); + if (file.delete()) + System.out.println("eliminato: "+name); + else + System.out.println("problema di eliminazione file"); + } + else + { + xmlOperation es=new xmlOperation(); + File car=new File(global.listaEsercizi); + if (car.exists()) { + dbConnect db=new dbConnect(); + try { + ArrayList esercizi=suString.stringToArrayList(db.dbQuery("4")); + boolean add=true; + for(String esercizio : esercizi) + { + if(esercizio.equals(name)) + add=false; + } + if(add) + es.add(name); + } catch (SQLException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + } + } + } + + // print the events and the affected file + private void printEvent(WatchEvent event) throws IOException { + Kind kind = event.kind(); + if (kind.equals(StandardWatchEventKinds.ENTRY_CREATE)) + { + Path pathCreated = (Path) event.context(); + System.out.println("Entry created:" + pathCreated); + boolean check = EsNameParser.check(pathCreated.getFileName().toString()); + if(!check) + { + File file = new File(global.locationEsercizi+pathCreated.getFileName().toString()); + if(file.delete()) + System.out.println("eliminato"); + else + System.out.println("problema di eliminazione file"); + } + else + { + xmlOperation es=new xmlOperation(); + File dir=new File(global.listaEsercizi); + if (dir.exists()) + es.add(pathCreated.getFileName().toString()); + } + } + else if (kind.equals(StandardWatchEventKinds.ENTRY_DELETE)) + { + Path pathDeleted = (Path) event.context(); + System.out.println("Entry deleted:" + pathDeleted); + xmlOperation es=new xmlOperation(); + File dir=new File(global.listaEsercizi); + if (dir.exists()) + es.remove(pathDeleted.getFileName().toString()); + } + else if (kind.equals(StandardWatchEventKinds.ENTRY_MODIFY)) + { + Path pathModified = (Path) event.context(); + System.out.println("Entry modified:" + pathModified); + } + } + + @Override + public void run() { + try { + pulisciCartella(); + WatchService watchService = path.getFileSystem().newWatchService(); + path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE); + + // loop forever to watch directory + while (true) { + WatchKey watchKey; + watchKey = watchService.take(); // this call is blocking until events are present + + // poll for file system events on the WatchKey + for (final WatchEvent event : watchKey.pollEvents()) { + printEvent(event); + } + + // if the watched directed gets deleted, get out of run method + if (!watchKey.reset()) { + System.out.println("No longer valid"); + watchKey.cancel(); + watchService.close(); + break; + } + } + + } catch (InterruptedException ex) { + System.out.println("interrupted. Goodbye"); + return; + } catch (IOException ex) { + ex.printStackTrace(); // don't do this in production code. Use a loggin framework + return; + } + } + +} diff --git a/server/tesi/src/com/company/EmailSender.class b/server/tesi/src/com/company/EmailSender.class new file mode 100644 index 0000000..8c301a8 Binary files /dev/null and b/server/tesi/src/com/company/EmailSender.class differ diff --git a/server/tesi/src/com/company/EmailSender.java b/server/tesi/src/com/company/EmailSender.java new file mode 100644 index 0000000..1abf701 --- /dev/null +++ b/server/tesi/src/com/company/EmailSender.java @@ -0,0 +1,110 @@ +package com.company; + +import java.util.Date; +import java.util.Properties; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Multipart; +import javax.mail.NoSuchProviderException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + + + +public class EmailSender { + private String user; + private String password; + private String host; + private String mittente; + private String destinatario; + private String oggetto; + private String mess; + + + EmailSender(String user, String password, String host, + String mittente, String destinatario, + String oggetto, String mess){ + + this.user = user; + this.password = password; + this.host = host; + this.mittente = mittente; + this.destinatario = destinatario; + this.oggetto = oggetto; + this.mess=mess; + } + + + // Metodo che si occupa dell'invio effettivo della mail + public void inviaEmail() { + int port = 465; //porta 25 per non usare SSL + + Properties props = new Properties(); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.user", mittente); + props.put("mail.smtp.host", host); + props.put("mail.smtp.port", port); + + // commentare la riga seguente per non usare SSL + props.put("mail.smtp.starttls.enable","true"); + props.put("mail.smtp.socketFactory.port", port); + + // commentare la riga seguente per non usare SSL + props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + props.put("mail.smtp.socketFactory.fallback", "false"); + + Session session = Session.getInstance(props, null); + session.setDebug(true); + + // Creazione delle BodyParts del messaggio + MimeBodyPart messageBodyPart1 = new MimeBodyPart(); + + try{ + // COSTRUZIONE DEL MESSAGGIO + Multipart multipart = new MimeMultipart(); + MimeMessage msg = new MimeMessage(session); + + // header del messaggio + msg.setSubject(oggetto); + msg.setSentDate(new Date()); + msg.setFrom(new InternetAddress(mittente)); + + // destinatario + msg.addRecipient(Message.RecipientType.TO, + new InternetAddress(destinatario)); + + // corpo del messaggio + messageBodyPart1.setText(mess); + multipart.addBodyPart(messageBodyPart1); + + // allegato al messaggio + /*DataSource source = new FileDataSource(allegato); + messageBodyPart2.setDataHandler(new DataHandler(source)); + messageBodyPart2.setFileName(allegato); + multipart.addBodyPart(messageBodyPart2);*/ + + // inserimento delle parti nel messaggio + msg.setContent(multipart); + + Transport transport = session.getTransport("smtps"); //("smtp") per non usare SSL + transport.connect(host, user, password); + transport.sendMessage(msg, msg.getAllRecipients()); + transport.close(); + + System.out.println("Invio dell'email Terminato"); + + }catch(AddressException ae) { + ae.printStackTrace(); + }catch(NoSuchProviderException nspe){ + nspe.printStackTrace(); + }catch(MessagingException me){ + me.printStackTrace(); + } + + } +} diff --git a/server/tesi/src/com/company/EsNameParser.class b/server/tesi/src/com/company/EsNameParser.class new file mode 100644 index 0000000..d2cfbe3 Binary files /dev/null and b/server/tesi/src/com/company/EsNameParser.class differ diff --git a/server/tesi/src/com/company/EsNameParser.java b/server/tesi/src/com/company/EsNameParser.java new file mode 100644 index 0000000..f4f1105 --- /dev/null +++ b/server/tesi/src/com/company/EsNameParser.java @@ -0,0 +1,144 @@ +package com.company; + +import java.io.File; +import java.io.FileInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; + +import java.lang.Integer; +import java.io.FileReader; +import java.io.BufferedReader; + +public class EsNameParser { + EsNameParser(){} + + static public String esName() + { + try { + FileInputStream file = new FileInputStream(new File(global.listaEsercizi)); + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = builderFactory.newDocumentBuilder(); + Document xmlDocument = builder.parse(file); + XPath xPath = XPathFactory.newInstance().newXPath(); + int esNumber = Integer.parseInt(xPath.compile("count(/esercizi/esercizio)").evaluate(xmlDocument)); + String returnValue = null; + for (int i = 1; i <= esNumber; i++) { + String name = xPath.compile("/esercizi/esercizio[" + i + "]").evaluate(xmlDocument); + if (name == null || name.isEmpty()) + continue; + else { + if(returnValue==null) + returnValue=name; + else + returnValue = returnValue + "/" + name; + } + } + file.close(); + return returnValue; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static boolean check(String esercizio) + { + boolean value=false; + try + { + String cartellaEs=global.locationEsercizi; + + BufferedReader br = new BufferedReader(new FileReader(cartellaEs+esercizio)); + if (br.readLine() == null) { + br.close(); + return false; + } + FileInputStream file = new FileInputStream(new File(cartellaEs+"/"+esercizio)); + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = builderFactory.newDocumentBuilder(); + Document xmlDocument = builder.parse(file); + value=checkFormula(xmlDocument,"/esercizio/tesi/formula[1]"); + if(value) + value=checkIpotesi(xmlDocument); + file.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return value; + } + + static public boolean checkFormula(Document xmlDocument, String position) { + try + { + XPath xPath = XPathFactory.newInstance().newXPath(); + if(Integer.parseInt(xPath.compile("count(" + position + ")").evaluate(xmlDocument))==1) { + String type = xPath.compile(position + "/@type").evaluate(xmlDocument); + int numbOfElements = 5; + if (type.contentEquals("and") || type.contentEquals("or") || type.contentEquals("impl")) + numbOfElements = 2; + else if (type.contentEquals("not")) + numbOfElements = 1; + else if (type.contentEquals("literal") || type.contentEquals("atomic")) + numbOfElements = 0; + int count = Integer.parseInt(xPath.compile("count(" + position + "/formula)").evaluate(xmlDocument)); + if (count == numbOfElements) { + if (numbOfElements == 2) { + boolean firstChild = checkFormula(xmlDocument, position + "/formula[1]"); + boolean secondChild = checkFormula(xmlDocument, position + "/formula[2]"); + if (!firstChild || !secondChild) + return false; + else + return true; + } + else if (numbOfElements == 1) + { + boolean child = checkFormula(xmlDocument, position + "/formula[1]"); + if (!child) + return false; + return true; + } + else if (numbOfElements == 0) + { + String child = xPath.compile(position).evaluate(xmlDocument); + if (child == null || child.isEmpty()) + return false; + else + return true; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + static public boolean checkIpotesi(Document xmlDocument) + { + XPath xPath = XPathFactory.newInstance().newXPath(); + boolean returnValue=false; + try + { + int count = Integer.parseInt(xPath.compile("count(/esercizio/ipotesi)").evaluate(xmlDocument)); + int numberHp=Integer.parseInt(xPath.compile("count(/esercizio/ipotesi/formula)").evaluate(xmlDocument)); + if(count==1 && numberHp==0)//se non ci sono ipotesi + return true; + for(int i=1;i<=numberHp;i++) + { + boolean valore = checkFormula(xmlDocument, "/esercizio/ipotesi/formula["+i+"]"); + if(!valore) + return false; + else + returnValue=true; + } + }catch (Exception e) { + e.printStackTrace(); + } + return returnValue; + } +} diff --git a/server/tesi/src/com/company/MD5.class b/server/tesi/src/com/company/MD5.class new file mode 100644 index 0000000..79abbc1 Binary files /dev/null and b/server/tesi/src/com/company/MD5.class differ diff --git a/server/tesi/src/com/company/MD5.java b/server/tesi/src/com/company/MD5.java new file mode 100644 index 0000000..623f11f --- /dev/null +++ b/server/tesi/src/com/company/MD5.java @@ -0,0 +1,46 @@ +package com.company; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + + +public class MD5 { + + MD5(){} + public static String digest(String filePath) { + InputStream inputStream = null; + try { + inputStream = new FileInputStream(global.locationEsercizi+filePath); + byte[] buffer = new byte[1024]; + MessageDigest digest = MessageDigest.getInstance("MD5"); + int numRead = 0; + while (numRead != -1) { + numRead = inputStream.read(buffer); + if (numRead > 0) + digest.update(buffer, 0, numRead); + } + byte [] md5Bytes = digest.digest(); + System.out.println(convertHashToString(md5Bytes)); + return convertHashToString(md5Bytes); + } catch (Exception e) { + return null; + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (Exception e) { } + } + } + } + + private static String convertHashToString(byte[] md5Bytes) { + String returnVal = ""; + for (int i = 0; i < md5Bytes.length; i++) { + returnVal += Integer.toString(( md5Bytes[i] & 0xff ) + 0x100, 16).substring(1); + } + return returnVal; + } +} diff --git a/server/tesi/src/com/company/Makefile b/server/tesi/src/com/company/Makefile new file mode 100644 index 0000000..2cc75ec --- /dev/null +++ b/server/tesi/src/com/company/Makefile @@ -0,0 +1,2 @@ +all: + javac -cp "/tmp/ext/mysql-connector-java.jar:/tmp/ext/jdom-2.0.5.jar:/tmp/ext/mail-1.4.1.jar:." *.java diff --git a/server/tesi/src/com/company/dbConnect.class b/server/tesi/src/com/company/dbConnect.class new file mode 100644 index 0000000..03ff58b Binary files /dev/null and b/server/tesi/src/com/company/dbConnect.class differ diff --git a/server/tesi/src/com/company/dbConnect.java b/server/tesi/src/com/company/dbConnect.java new file mode 100644 index 0000000..28d851c --- /dev/null +++ b/server/tesi/src/com/company/dbConnect.java @@ -0,0 +1,355 @@ +package com.company; + +import java.sql.*; +import java.io.IOException; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import java.util.Random; + +import java.sql.Timestamp; + +import java.util.ArrayList; + +import java.lang.Double; + +public class dbConnect +{ + private static Connection db; + private static Statement stmt; + dbConnect() + {} + + + public static Long time() + { + java.util.Date date= new java.util.Date(); + Timestamp now=new Timestamp(date.getTime()); + return now.getTime(); + } + + //pulisce confmail e connessi da tutte le richieste maggiori di 10 minuti + private static void deletetmp() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + PreparedStatement preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE time<=?"); + preparedStmt.setLong (1,(time()-600000)); + preparedStmt.execute(); + preparedStmt = db.prepareStatement("DELETE FROM connessi WHERE time<=?"); + preparedStmt.setLong (1,(time()-600000)); + preparedStmt.execute(); + } + + //divide la stringa in user e password + private static String splitUsrPass(String userAndPass, int code) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + String user=null; + String pass=null; + ArrayList userPass= suString.stringToArrayList(userAndPass); + if(userPass.size()>=1) + user=userPass.get(0); + if(userPass.size()>=2) + pass=userPass.get(1); + + assert user != null; + if(!user.contains("@studio.unibo.it") && user.length()<16) + return "mail-error"; + else { + assert pass != null; + if(code==0) + return registration(user, pass); + else if(code==1) + return login(user, pass); + else if(code==2) + return recupero(user); + else + return "error"; + } + } + + //routin di gestione recupero pass + private static String recupero(String user) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + EmailSender email = new EmailSender(global.email, + global.emailPass, + "smtp.gmail.com", + global.email, + user, + "OGGETTO: recupero password", + "la tua password è "+returnQuery.getString("pass")); + email.inviaEmail(); + return "mail-pass-ok"; + } + else + return "user-error"; + } + else + return "user-error"; + } + + + //routin di gestione della registrazione + private static String registration(String user, String pass) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + String ran; + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + if(returnQuery.getString("user").compareTo(user)==0 && returnQuery.getString("pass").compareTo(pass)==0) + return "già-registrato"; + } + } + returnQuery=stmt.executeQuery("SELECT * FROM confmail where user='"+user+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + ran=returnQuery.getString("hash"); + if(returnQuery.getString("pass").compareTo(pass)!=0) + { + PreparedStatement preparedStmt = db.prepareStatement("UPDATE confmail SET pass =? where user=?"); + preparedStmt.setString (1,pass); + preparedStmt.setString (2,user); + preparedStmt.execute(); + } + } + else + { + Random random = new Random(); + ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); + //returnQuery=stmt.executeQuery("INSERT INTO confmail VALUES('"+user+"','"+pass+"',"+hash+"')"); + PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO confmail (user,pass,hash,time) VALUES(?,?,?,?)"); + preparedStmt.setString (1,user); + preparedStmt.setString (2,pass); + preparedStmt.setString (3,ran); + preparedStmt.setDouble (4,(double)time()); + preparedStmt.execute(); + } + } + else + { + Random random = new Random(); + ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); + //returnQuery=stmt.executeQuery("INSERT INTO confmail VALUES('"+user+"','"+pass+"',"+hash+"')"); + PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO confmail (user,pass,hash,time) VALUES(?,?,?,?)"); + preparedStmt.setString (1,user); + preparedStmt.setString (2,pass); + preparedStmt.setString (3,ran); + preparedStmt.setDouble (4,(double)time()); + preparedStmt.execute(); + } + EmailSender email = new EmailSender(global.email, + global.emailPass, + "smtp.gmail.com", + global.email, + user, + "OGGETTO: Registrazione App", + "per confermare la tua email clicka sul link: http://"+global.serverName+"/test?id="+ran); + email.inviaEmail(); + return "mail-reg-ok"; + } + + //routin conferma registrazione + private static String confirmRegistration(String hash) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM confmail where hash='"+hash+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO utenti (user,pass) VALUES(?,?)"); + preparedStmt.setString (1,returnQuery.getString("user")); + preparedStmt.setString (2,returnQuery.getString("pass")); + preparedStmt.execute(); + preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE hash=?"); + preparedStmt.setString (1,hash); + preparedStmt.execute(); + return "registrazione-ok"; + } + } + return "registrazione-error"; + } + + //routin di gestione login + private static String login(String user, String pass) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM utenti where user='"+user+"' and pass='"+pass+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + if(returnQuery.getString("user").compareTo(user)==0 && returnQuery.getString("pass").compareTo(pass)==0) + return putConnessi(user); + } + } + return "login-error"; + } + + + //informazioni sulla connessione dell'utente + private String infoConnessi(String message) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + ArrayList split= suString.stringToArrayList(message); + if(split.size()>=1) + { + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi WHERE tempkey='"+split.get(1)+"'"); + if(returnQuery!=null) + { + if(returnQuery.next()) + { + return "loggato"; + } + } + } + return "request-login"; + } + + //inserisce l'utente in connessi + private static String putConnessi(String user) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + Random random = new Random(); + String ran=String.valueOf(random.nextInt(100000000)+10000000)+String.valueOf(random.nextInt(100000000)+10000000); + PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO connessi (user,tempkey,thread,time) VALUES(?,?,?,?)"); + preparedStmt.setString (1,user); + preparedStmt.setString (2,ran); + preparedStmt.setBoolean (3,false); + preparedStmt.setDouble (4,(double)time()); + preparedStmt.execute(); + return ran; + } + + //segnalare morte di un thread + private String threadDead(String key) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + PreparedStatement preparedStmt = db.prepareStatement("DELETE FROM confmail WHERE tempkey=?"); + preparedStmt.setString (1,key); + preparedStmt.execute(); + return "kill-ok"; + } + + //remposta il rimer dell'utente nella tabella connessi + private String connessiTimer(String key) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException + { + PreparedStatement preparedStmt = db.prepareStatement("UPDATE connessi SET time =? where tempkey=?"); + preparedStmt.setDouble (1,(double)time()); + preparedStmt.setString (2,key); + preparedStmt.execute(); + return "timer-settato"; + } + + private String exerciseAccept(String request) throws SQLException, IOException, NoSuchAlgorithmException { + ArrayList input=suString.stringToArrayList(request); + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi where tempkey='"+input.get(0)+"'"); + String utente=null; + if(returnQuery!=null) + { + if(returnQuery.next()) + utente=returnQuery.getString("user"); + } + if(utente!=null) + { + String[] esercizi=suString.stringToVectorString(EsNameParser.esName()); + for(String esercizio : esercizi) + { + if(esercizio.contentEquals(input.get(1)))//se l'esercizio esiste + { + if(MD5.digest(esercizio).contentEquals(input.get(2)))//se il digest è uguale + { + PreparedStatement preparedStmt = db.prepareStatement("INSERT INTO esercizi (esercizio,utente,click,time) VALUES(?,?,?,?)"); + preparedStmt.setDouble(4, Double.parseDouble(input.get(3))); + preparedStmt.setInt (3,Integer.valueOf(input.get(4))); + preparedStmt.setString (2,utente); + preparedStmt.setString (1,input.get(1)); + preparedStmt.execute(); + return "es-ok"; + } + } + } + } + return "es-err"; + } + + private String userExercise(String request) throws SQLException { + ArrayList arrayResult=new ArrayList(); + ArrayList input=suString.stringToArrayList(request); + String result=null; + ResultSet returnQuery=stmt.executeQuery("SELECT * FROM connessi where tempkey='"+input.get(0)+"'"); + String utente=null; + if(returnQuery!=null) + { + if(returnQuery.next()) + utente=returnQuery.getString("user"); + } + if(utente!=null) + { + returnQuery=stmt.executeQuery("SELECT * FROM esercizi where utente='"+utente+"'"); + while(returnQuery.next()) + { + arrayResult.add(returnQuery.getString("esercizio")+"/"+MD5.digest(returnQuery.getString("esercizio"))+"/"+returnQuery.getDouble("time")+"/"+returnQuery.getInt("click")); + } + result=suString.multiToString(arrayResult); + } + return result; + } + + private String cambiaPass(String request) throws ClassNotFoundException, SQLException, InstantiationException, IOException, IllegalAccessException { + ArrayList input=suString.stringToArrayList(request); + if(input.size()>=3) { + String result = login(input.get(0), input.get(1)); + if(!result.contains("err")) + { + PreparedStatement preparedStmt = db.prepareStatement("UPDATE utenti SET pass =? where user=?"); + preparedStmt.setString (1,input.get(2)); + preparedStmt.setString (2,input.get(0)); + preparedStmt.execute(); + return "cambiata"; + } + } + return "error"; + } + + public String dbQuery(String input) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, NoSuchAlgorithmException { + Class.forName("com.mysql.jdbc.Driver").newInstance(); + db = DriverManager.getConnection("jdbc:mysql://localhost/logintesi", "root", "csc@CerCo!"); + stmt = db.createStatement(); + deletetmp(); + if (input.charAt(0) == '0') + return splitUsrPass(input.substring(2), 0); + else if (input.charAt(0) == '1') + return splitUsrPass(input.substring(2), 1); + else if (input.charAt(0) == '2') + return recupero(input.substring(2)); + else if (input.charAt(0) == '3') + return confirmRegistration(input.substring(1)); + else if (input.charAt(0) == '4') + return EsNameParser.esName(); + else if (input.charAt(0) == '5') + return infoConnessi(input.substring(2)); + else if (input.charAt(0) == '6') + return connessiTimer(input.substring(2)); + /*else if (input.charAt(0) == '7') + return threadDead(input.substring(2));*/ + /*else if(input.charAt(0)=='8') + return aggToClient(input.substring(2)); + else if(input.charAt(0)=='9') + return aggForClient(input.substring(2)); + else if(input.charAt(0)=='a' && input.charAt(1)=='0') + return check(input.substring(3));*/ + else if (input.charAt(0) == '8') + return exerciseAccept(input.substring(2)); + else if (input.charAt(0) == '9') + return userExercise(input.substring(2)); + else if(input.charAt(0)=='a' && input.charAt(1)=='0') + return cambiaPass(input.substring(3)); + return "error"; + } +} diff --git a/server/tesi/src/com/company/esercizi.xml b/server/tesi/src/com/company/esercizi.xml new file mode 100644 index 0000000..c28cd97 --- /dev/null +++ b/server/tesi/src/com/company/esercizi.xml @@ -0,0 +1,10 @@ + + + aalbero.xml + tautologia.xml + demorgan.xml + triviale.xml + test.xml + risolvibile.xml + demorgan2.xml + diff --git a/server/tesi/src/com/company/esercizi.xml~ b/server/tesi/src/com/company/esercizi.xml~ new file mode 100644 index 0000000..47eb032 --- /dev/null +++ b/server/tesi/src/com/company/esercizi.xml~ @@ -0,0 +1,4 @@ + + + aalbero.xml + diff --git a/server/tesi/src/com/company/global.class b/server/tesi/src/com/company/global.class new file mode 100644 index 0000000..00f0bd3 Binary files /dev/null and b/server/tesi/src/com/company/global.class differ diff --git a/server/tesi/src/com/company/global.java b/server/tesi/src/com/company/global.java new file mode 100644 index 0000000..2bf06c4 --- /dev/null +++ b/server/tesi/src/com/company/global.java @@ -0,0 +1,16 @@ +package com.company; + + +public class global { + public static final String listaEsercizi="/projects/logicplayer/Server/server/tesi/src/com/company/esercizi.xml"; + public static final String locationEsercizi="/projects/logicplayer/public_html/esercizi/"; + public static String home="/projects/logicplayer/Server/server/tesi/src/com/company/"; + public static String keyStorePass="123456"; + public static String keyStoreName="keystore.jks"; + public static String serverName="130.136.129.1"; + public static String email="confermaiscrizioneserver@gmail.com"; + public static String emailPass="tes6phev8n"; + public static int portaServer=25000; + public static int portaHttpServer=8000; + +} diff --git a/server/tesi/src/com/company/guestServer.class b/server/tesi/src/com/company/guestServer.class new file mode 100644 index 0000000..59b4c18 Binary files /dev/null and b/server/tesi/src/com/company/guestServer.class differ diff --git a/server/tesi/src/com/company/guestServer.java b/server/tesi/src/com/company/guestServer.java new file mode 100644 index 0000000..1fb6ce9 --- /dev/null +++ b/server/tesi/src/com/company/guestServer.java @@ -0,0 +1,80 @@ +package com.company; + +import java.io.*; + +import javax.net.ssl.*; + +class guestServer implements Runnable +{ + private SSLSocket socket; + + guestServer(SSLSocket client) + { + socket=client; + } + + public void run() + { + try + { + + //Reading the message from the client + InputStream is = socket.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String requestMessage = br.readLine(); + System.out.println("ho ricevuto: "+requestMessage); + /*System.out.println("Message received from client is "+returnMessage); + dbConnect request=new dbConnect(); + String returnQuery=request.dbQuery(returnMessage); + OutputStream os = socket.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + System.out.println(returnQuery); + bw.write(returnQuery+"\n"); + bw.flush();*/ + if(requestMessage!=null) + { + dbConnect request = new dbConnect(); + String returnQuery; + if ( requestMessage.charAt(0) == '0' || + requestMessage.charAt(0) == '1' || + requestMessage.charAt(0) == '2' || + (requestMessage.charAt(0) == 'a' && requestMessage.charAt(1) == '0')) { + returnQuery = request.dbQuery(requestMessage); + OutputStream os = socket.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + bw.write(returnQuery + "\n"); + bw.flush(); + System.out.println("ho inviato: " + returnQuery); + } + else + { + returnQuery = request.dbQuery("5/" + requestMessage); + if (returnQuery.contains("request-login") || returnQuery.contains("request-error")) + { + OutputStream os = socket.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + bw.write(returnQuery + "\n"); + bw.flush(); + System.out.println("ho inviato: " + returnQuery); + } + else if (returnQuery.contains("loggato")) + { + personalServer nuovaConnessione = new personalServer(socket, requestMessage); + Thread t = new Thread(nuovaConnessione); + t.start(); + } + } + } + + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} diff --git a/server/tesi/src/com/company/httpget$MyHandler.class b/server/tesi/src/com/company/httpget$MyHandler.class new file mode 100644 index 0000000..7862be8 Binary files /dev/null and b/server/tesi/src/com/company/httpget$MyHandler.class differ diff --git a/server/tesi/src/com/company/httpget.class b/server/tesi/src/com/company/httpget.class new file mode 100644 index 0000000..b710c11 Binary files /dev/null and b/server/tesi/src/com/company/httpget.class differ diff --git a/server/tesi/src/com/company/httpget.java b/server/tesi/src/com/company/httpget.java new file mode 100644 index 0000000..079cc01 --- /dev/null +++ b/server/tesi/src/com/company/httpget.java @@ -0,0 +1,79 @@ +package com.company; + +import java.io.*; +import java.net.*; +import java.security.NoSuchAlgorithmException; +import java.util.*; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.sql.*; + +public class httpget implements Runnable { + + httpget(){} + + public static Map splitQuery(String query) throws UnsupportedEncodingException + { + Map query_pairs = new LinkedHashMap(); + String[] pairs = query.split("&"); + for (String pair : pairs) + { + int idx = pair.indexOf("="); + query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); + } + return query_pairs; + } + + @Override + public void run() { + try { + HttpServer server = HttpServer.create(new InetSocketAddress(global.portaHttpServer), 0); + server.createContext("/test", new MyHandler()); + server.setExecutor(null); // creates a default executor + server.start(); + }catch (Exception e) + { + e.printStackTrace(); + } + } + + static class MyHandler implements HttpHandler + { + public void handle(HttpExchange t) throws IOException + { + + /*String response = "This is the response"; + System.out.println("mannaggia santa"); + t.sendResponseHeaders(200, response.length()); + OutputStream os = t.getResponseBody(); + os.write(response.getBytes());*/ + URI req=t.getRequestURI(); + String query=req.getQuery(); + Map result=splitQuery(query); + String id=result.get("id"); + //System.out.println(id); + try + { + dbConnect request=new dbConnect(); + String returnQuery=request.dbQuery("3"+id); + t.sendResponseHeaders(200, returnQuery.length()); + OutputStream os = t.getResponseBody(); + os.write(returnQuery.getBytes()); + os.close(); + } + catch(SQLException e) + {} + catch(ClassNotFoundException c) + {} + catch(IllegalAccessException a) + {} + catch(InstantiationException i) + {} catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/server/tesi/src/com/company/keystore.bks b/server/tesi/src/com/company/keystore.bks new file mode 100644 index 0000000..ecec326 Binary files /dev/null and b/server/tesi/src/com/company/keystore.bks differ diff --git a/server/tesi/src/com/company/keystore.crt b/server/tesi/src/com/company/keystore.crt new file mode 100644 index 0000000..e60e9db Binary files /dev/null and b/server/tesi/src/com/company/keystore.crt differ diff --git a/server/tesi/src/com/company/keystore.jks b/server/tesi/src/com/company/keystore.jks new file mode 100644 index 0000000..4edd598 Binary files /dev/null and b/server/tesi/src/com/company/keystore.jks differ diff --git a/server/tesi/src/com/company/personalServer.class b/server/tesi/src/com/company/personalServer.class new file mode 100644 index 0000000..1d5b025 Binary files /dev/null and b/server/tesi/src/com/company/personalServer.class differ diff --git a/server/tesi/src/com/company/personalServer.java b/server/tesi/src/com/company/personalServer.java new file mode 100644 index 0000000..1d338eb --- /dev/null +++ b/server/tesi/src/com/company/personalServer.java @@ -0,0 +1,56 @@ +package com.company; + +import java.io.BufferedWriter; +import java.io.OutputStream; +import java.io.OutputStreamWriter; + +import javax.net.ssl.*; + + +import java.util.ArrayList; + +class personalServer implements Runnable +{ + private SSLSocket socket; + private String key; + private String requestMessage; + + personalServer(SSLSocket client, String message) + { + socket=client; + ArrayList split= suString.stringToArrayList(message); + key=split.get(1); + requestMessage=message; + } + + public void run() + { + try + { + dbConnect request=new dbConnect(); + String returnQuery=request.dbQuery(requestMessage); + OutputStream os = socket.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os); + BufferedWriter bw = new BufferedWriter(osw); + bw.write(returnQuery+"\n"); + bw.flush(); + System.out.println("ho inviato: "+returnQuery); + request.dbQuery("6/"+key); + socket.close(); + } + catch (Exception e) + { + try + { + e.printStackTrace(); + dbConnect request=new dbConnect(); + request.dbQuery("7/"+key); + } + catch (Exception k) + { + //k.printStackTrace(); + System.out.println("PANIC!"); + } + } + } +} diff --git a/server/tesi/src/com/company/suString.class b/server/tesi/src/com/company/suString.class new file mode 100644 index 0000000..6d094cb Binary files /dev/null and b/server/tesi/src/com/company/suString.class differ diff --git a/server/tesi/src/com/company/suString.java b/server/tesi/src/com/company/suString.java new file mode 100644 index 0000000..666febe --- /dev/null +++ b/server/tesi/src/com/company/suString.java @@ -0,0 +1,96 @@ +package com.company; + +import java.util.ArrayList; +import java.util.Collections; + +public class suString +{ + suString() + {} + + + public static ArrayList stringToArrayList(String string) + { + ArrayList returnValue=new ArrayList(); + int j=0; + for(int i=0;i vectorStringToArrayList(String[] vectorString) + { + ArrayList returnValue=new ArrayList(); + Collections.addAll(returnValue, vectorString); + return returnValue; + } + + public static String arrayListToString (ArrayList arraylist) + { + String returnValue= ""; + for(int i=0;i arraylist) + { + String[] returnValue=new String[arraylist.size()]; + for(int i=0;i input) + { + String returnValue=null; + int size=input.size(); + for(int i=0;i stringToMultiArray(String input) + { + ArrayList result=new ArrayList(); + int j=0; + for(int i=0;i + + + + + + + + + + \ No newline at end of file