-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.php
125 lines (104 loc) · 2.99 KB
/
library.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/*
* This file is part of Project Lumiére <http://monossido.ath.cx/cinema>
*
* Project Lumiére is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Project Lumiére is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Project Lumiére. If not, see <http://www.gnu.org/licenses/>.
*
*/
require("configure.php");
/*inizio pagina*/
function page_start($title) {
echo "<HTML>
<HEAD><TITLE>Project Lumiére $title</TITLE><p align='right'><a href='index.php'><b>Home</b></a></p><HR />";
};
function page_end() {
echo "
</BODY>
</HTML>";
};
function get_pwd($login) {
$query= "SELECT * FROM Utenti WHERE Username='".$login."'";
/* connessione al server */
$conn=mysql_connect(dbhost, dbuser, dbpwd)
or die("Connessione al server MySQL fallita!");
mysql_select_db(dbname);
$result=mysql_query($query,$conn)
or die("Query fallita" . mysql_error($conn));
$output=mysql_fetch_assoc($result);
if ($output && $output['verificato'])
return $output['Password'];
else if ($output && !$output['verificato'])
return -1;
else
return FALSE;
};
function get_film() {
/* connessione al server */
$conn=mysql_connect(dbhost, dbuser, dbpwd)
or die("Connessione al server MySQL fallita!");
mysql_select_db(dbname);
$query="SELECT voti FROM Film WHERE voti>=1 ORDER BY voti DESC";
$result=mysql_query($query, $conn)
or die("Query fallita!" . mysql_error());
$i=2;
$voti=0;
while($row=mysql_fetch_array($result))
$film[]=$row[0];
for(;$film[$i]==$film[$i-1];$i++){}
for($z=0;$z<count($film);$z++)
{
$voti=$voti+$film[$z];
}
if($film[0]>$voti/2)
return -1;
else
return $i;
};
function set_film($film,$i) {
if($film[0]>$film[1])
{
return 0;
}else if($film[1]>$film[2])
{
return 1;
}
else
{
$n=rand(0,$i-1);
return $n;
}
}
function id_to_user($id)
{
$conn=mysql_connect(dbhost, dbuser, dbpwd)
or die("Connessione al server MySQL fallita!");
mysql_select_db(dbname);
$query="SELECT Username FROM Utenti WHERE id_utente='$id'";
$result=mysql_query($query, $conn)
or die("Query fallita!" . mysql_error());
$user=mysql_fetch_assoc($result);
return $user['Username'];
}
function user_to_id($user)
{
$conn=mysql_connect(dbhost, dbuser, dbpwd)
or die("Connessione al server MySQL fallita!");
mysql_select_db(dbname);
$query="SELECT id_utente FROM Utenti WHERE Username='$user'";
$result=mysql_query($query, $conn)
or die("Query fallita!" . mysql_error());
$id=mysql_fetch_assoc($result);
return $id['id_utente'];
}
?>