-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.php
More file actions
114 lines (102 loc) · 2.87 KB
/
util.php
File metadata and controls
114 lines (102 loc) · 2.87 KB
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
<?php
function connectionbase()
{
$ini_array = parse_ini_file("config.ini");
$servername = $ini_array['servername'];
$username= $ini_array['username'];
$password = $ini_array['password'];
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $conn;
}
function checkConnection()
{
$conn = connectionbase();
$sql = "SELECT id FROM membre_ where id='".$_SESSION["id"]."' and pass='".$_SESSION["pass"]."'";
$result = $conn->query($sql);
$res = false;
if ($result->num_rows == 1) {
// output data of each row
while($row = $result->fetch_assoc()) {
$res=true;
}
}
$result->close();
$conn->close();
return $res;
}
function ecritEntete( $script ='' )
{
echo '<!DOCTYPE html>';
echo '<html>'."\n"."\n";
echo ' <head>'."\n";
echo ' <meta charset="utf-8" />'."\n";
echo ' <meta name="viewport" content="width=device-width, user-scalable=no"/>'."\n";
echo ' <link rel="stylesheet" media="(min-width: 768px)" href="km.css"/>'."\n";
echo ' <script src="jquery-3.3.1.js"></script>' ."\n";
echo ' <link rel="stylesheet" media="(max-width: 767px)" href="km2.css"/>'."\n";
echo ' <title>Saisie des km</title>'."\n";
echo '<script type="text/javascript">
function handleClick(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("resultat").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "gethint.php?q=c", true);
xmlhttp.send();
}'."\n";
echo $script."\n";
echo '</script>'."\n";
echo' </head>'."\n";
echo' <body>'."\n";
}
function ecritHeaderMenu() {
echo '
<header>
<h1>Marau</h1>
<h2>Kilometre...</h2>
</header>
<nav>
<ul>
<li><a href="#">Accueil</a></li>
<li><a href="#">Saisie</a>
<ul>
<li><a href="insert_sortie.php">Sortie</a></li>
<li><a href="insert_velo.php">Vélo</a></li>
</ul>
</li>
<li><a href="#">Affichage</a>
<ul>
<li><a href="aff_sortie.php">Sortie</a></li>
<li><a href="aff_velo.php">Vélo</a></li>
<li><a href="aff_stat.php">Statistic</a></li>
</ul>
</li>
<li>
<a href="profile.php">Membre</a>
<ul>';
if( checkConnection() ){
echo '
<li><a href="deconnect.php">Deconnection</a></li>';
}else{
echo '
<li><a href="connexion.php">Login</a></li>
<li><a href="insert_user.php">Create User</a></li>';
}
echo '
</ul>
</li>
</ul>
</nav>
';
}
function ecritFin()
{
echo '</body></html>';
}
?>