Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added cat generation

  • Loading branch information...
commit 88267cfdb76371a331a9b210cebdb9eaf08bacfc 1 parent 89a4bfc
@DerWaldschrat authored
View
17 User/login.php
@@ -13,10 +13,10 @@
$db = db();
$oldPw = $userIn->passwort;
$userIn->passwort = hashme($userIn->passwort, $userIn->nickname);
- $st = $db->prepare("SELECT userid, email, vorname, nachname, passwort, profile, rights FROM " . USER . " WHERE nickname = ?");
+ $st = $db->prepare("SELECT userid, email, vorname, nachname, passwort, profile, cat, rights FROM " . USER . " WHERE nickname = ?");
$st->bind_param("s", $userIn->nickname);
$user = new stdClass();
- $st->bind_result($user->userid, $user->email, $user->vorname, $user->nachname, $user->passwort, $user->profile, $user->rights);
+ $st->bind_result($user->userid, $user->email, $user->vorname, $user->nachname, $user->passwort, $user->profile, $user->cat, $user->rights);
if ($st->execute()) {
$st->store_result();
if ($st->num_rows === 1) {
@@ -24,8 +24,19 @@
if ($user->passwort === $userIn->passwort) {
$user->nickname = $userIn->nickname;
$st->close();
+
+ // Create new cat
+ require IN . "random" . PHP_EX;
+ $cat = randomString(12);
+ $st = $db->prepare("UPDATE " . USER . " SET cat = ? WHERE nickname = ?");
+ $st->bind_param("ss", $cat, $user->nickname);
+ if (exQuery($st)) {
+ $user->cat = $cat;
+ }
+
+
$_SESSTION["user"] = array();
- $toSet = array("userid", "email", "vorname", "nachname", "profile", "rights");
+ $toSet = array("userid", "email", "vorname", "nachname", "profile", "cat", "rights");
foreach($toSet as $field) {
$_SESSION["user"][$field] = $user->$field;
}
View
4 design/index.php
@@ -22,10 +22,6 @@
require IN . "coreconfig" . PHP_EX;
require IN . "User/fetchData" . PHP_EX;
$user = new stdClass();
- $toSet = array("userid", "email", "vorname", "nachname", "loggedin");
- foreach($toSet as $field) {
- $user->$field = $_SESSION["user"][$field];
- }
$user = (object)$_SESSION["user"];
fetchUserData($user);
echo "window.__User = " . json_encode($user).";";
View
4 design/index.production.php
@@ -33,10 +33,6 @@
require IN . "coreconfig" . PHP_EX;
require IN . "User/fetchData" . PHP_EX;
$user = new stdClass();
- $toSet = array("userid", "email", "vorname", "nachname", "loggedin");
- foreach($toSet as $field) {
- $user->$field = $_SESSION["user"][$field];
- }
$user = (object)$_SESSION["user"];
fetchUserData($user);
echo "window.__User = " . json_encode($user).";";
View
14 random.php
@@ -0,0 +1,14 @@
+<?php
+function randomString($length = 8)
+{
+ $signs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ $result = "";
+ for ($i = 0; $i < $length; $i++) {
+ $result .= substr(str_shuffle($signs), 0, 1);
+ }
+ return $result;
+}
+
+
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.