-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·67 lines (56 loc) · 1.21 KB
/
functions.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
<?php
function login_team($t, $p, $db){
$s1 = $db->prepare("SELECT * FROM teams WHERE name=?");
$s1 -> bind_param('s', $t);
if($s1->execute()){
$team=$s1->get_result()->fetch_assoc();
$s1->close();
if(password_verify($p, $team['password'])){
$_SESSION['team_id'] = $team['id'];
$_SESSION['team_name'] = $team['name'];
$_SESSION['loggedin']=true;
header("Location: /");
}
else{
echo "Wrong username/password";
die();
}
}
}
function compare_files($file1, $file2){
$f1 = fopen($file1, 'r');
$f2 = fopen($file2, 'r');
$output=array();
$counter = 0;
echo 'line number: your solution - correct solution <br>';
$correct=true;
while(1){
$counter ++;
if($counter > 10000){
echo '<h3> Answer too long, drink one shot extra! </h3>';
$correct = false;
break;
}
$a = fgets($f1);
$b = fgets($f2);
$ea = feof($f1);
$eb = feof($f2);
if(($eb)){
if($counter < 2){
echo 'No output';
$correct = false;
}
break;
}
else{
echo $counter.': '.$a.' - '.$b.'<br>';
if($a != $b){
return false;
}
}
}
if($correct){
return true;
}
}
?>