Fix per les cookies que no funcionen
diff --git a/php/change_password.php b/php/change_password.php
index 6f13127..1585a41 100644
--- a/php/change_password.php
+++ b/php/change_password.php
@@ -4,17 +4,16 @@
// Check if confirmation is the same
if ($_POST['password'] != $_POST['confirmation']) {
- header("Location: ../main.php?wrongconfirmation=1");
- die();
+ die("<script>window.location.href = '../main.php?wrongconfirmation=1'</script>");
} else {
// Execute query to change password
$update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid'];
- if(!$result = query($update_password)) header("Location: ../main.php?errordb=1");
+ if(!$result = query($update_password)) die("<script>window.location.href = '../main.php?errordb=1'</script>");
// Save 'password' to cookies
setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/");
// Go back to main page
- header("Location: ../main.php?successpassword=1");
+ die("<script>window.location.href = '../main.php?successpassword=1'</script>");
}
?>
diff --git a/php/login.php b/php/login.php
index 9fcdc39..fb8f923 100644
--- a/php/login.php
+++ b/php/login.php
@@ -7,8 +7,7 @@
if (isset($_POST['user'])) $user = $_POST['user'];
else if (isset($_COOKIE['user'])) $user = $_COOKIE['user'];
else {
- header("Location: ../index.php");
- die();
+ die("<script>window.location.href = '../index.php'</script>");
}
// Check if password is correct
@@ -26,8 +25,7 @@
setcookie('user', '', -1, "/");
setcookie('password', '', -1, "/");
- header("Location: ../index.php?wrongpassword=1");
- die();
+ die("<script>window.location.href = '../index.php?wrongpassword=1'</script>");
}
// Save variables as cookies
@@ -35,6 +33,8 @@
if ($real_password != "") setcookie('password', md5($password), time() + (86400 * 10), "/");
else setcookie('password', '', -1, "/");
+ echo "<script>window.location.href = '../main.php?user=$user&password=$password'; </script>";
+
// Success, proceed to main page
- header("Location: ../main.php");
+ // die("<script>window.location.href = '../main.php?user='.$user.'&password='.$password</script>");
?>
diff --git a/php/utils.php b/php/utils.php
index 6ac2e7e..edd53fa 100644
--- a/php/utils.php
+++ b/php/utils.php
@@ -10,6 +10,19 @@
$noms = explode(" ", $this->nomcomplet);
return $noms[0];
}
+
+ public function nomcurs() {
+ if ($this->curs == 1) return "1er";
+ if ($this->curs == 2) return "2on";
+ if ($this->curs == 3) return "3er";
+ if ($this->curs == 4) return "4rt";
+ }
+
+ public function nomgrau() {
+ if ($this->grau == 0) return "MAT";
+ if ($this->grau == 1) return "EST";
+ if ($this->grau == 2) return "MAMME";
+ }
}
function query($query) {
@@ -41,23 +54,23 @@
while ($row = $result->fetch_row()) {
if ($getAsObjects) {
$user = new User();
- $user->id = $row[0];
+ $user->id = (int)$row[0];
$user->nomcomplet = $row[1];
- $user->curs = $row[2];
- $user->grau = $row[3];
- $user->quimata = $row[4];
- $user->requested = $row[5];
- $user->mort = $row[6];
+ $user->curs = (int)$row[2];
+ $user->grau = (int)$row[3];
+ $user->quimata = (int)$row[4];
+ $user->requested = (int)$row[5];
+ $user->mort = (int)$row[6];
$user->md5password = $row[7];
} else {
$user = [];
- $user["id"] = $row[0];
+ $user["id"] = (int)$row[0];
$user["nomcomplet"] = $row[1];
- $user["curs"] = $row[2];
- $user["grau"] = $row[3];
- $user["quimata"] = $row[4];
- $user["requested"] = $row[5];
- $user["mort"] = $row[6];
+ $user["curs"] = (int)$row[2];
+ $user["grau"] = (int)$row[3];
+ $user["quimata"] = (int)$row[4];
+ $user["requested"] = (int)$row[5];
+ $user["mort"] = (int)$row[6];
$user["md5password"] = $row[7];
}