Example #1
0
        //redirect_to("http://wszechwiedzacy.com/ranking");
    }
} else {
    if ($logged) {
        $nick = $_SESSION['username'];
        // same as above // fix repeating?
        $ranking_position = array_search($nick, $top_scorers);
    } else {
        //redirect_to("http://wszechwiedzacy.pl/ranking");
    }
}
// end of if/else session is logged in
// make the user object that holds all information that is stored in database
$user_exists = User::user_exists($nick);
if ($user_exists) {
    $current_user = User::find_user($nick);
    $last = strtotime($current_user->last_activity);
} else {
    $current_user = false;
}
// function displays last activity in polish
$wynik = getDiff($last);
$display_status = "nieaktywny";
if (time() - $last < 600) {
    $display_status = "aktywny";
}
$sex = "ukryty";
// if sex was chosen
if ($current_user->sex != 0) {
    $current_user->sex == 1 ? $sex = "kobieta" : ($sex = "mężczyzna");
}
Example #2
0
<?php

require_once "initialize.php";
$json_arr = array("username" => "none", "msg" => "none");
if (isset($_POST)) {
    global $database;
    $username = trim($db->escape_value($_POST['username']));
    // finds user and stores values as object
    $cu = User::find_user($username);
    isset($_POST['wiek']) && $_POST['wiek'] != "undefined" ? $wiek = 1 : ($wiek = 0);
    isset($_POST['sex']) && $_POST['sex'] != "undefined" ? $sex = trim($db->escape_value($_POST['sex'])) : ($sex = 0);
    isset($_POST['city']) && $_POST['city'] != "" ? $city = trim($db->escape_value($_POST['city'])) : ($city = "");
    isset($_POST['degree']) && $_POST['degree'] != "wybierz" ? $degree = trim($db->escape_value($_POST['degree'])) : ($degree = "");
    isset($_POST['newsletter']) && $_POST['newsletter'] != "undefined" ? $newsletter = 1 : ($newsletter = 0);
    if ($_POST['old_pass'] != "") {
        $old_pass = trim($db->escape_value($_POST['old_pass']));
        $oph = sha1($old_pass);
    }
    $_POST['new_pass'] != "" ? $new_pass = trim($db->escape_value($_POST['new_pass'])) : false;
    $_POST['new_pass2'] != "" ? $new_pass2 = trim($db->escape_value($_POST['new_pass2'])) : false;
    /**
     *	check if old pass is not the same as new, new pass and new pass2 match and if old pass is same as in db
     */
    if ($old_pass == $new_pass && $old_pass != "") {
        $json_arr['msg'] = "old equals new";
    } elseif ($new_pass != $new_pass2) {
        $json_arr['msg'] = "sprawdź czy dobrze przepisałeś nowe hasło";
    } elseif ($oph != $cu->hashed_password) {
        $json_arr['msg'] = "wrong old password";
    } else {
        $json_arr['msg'] = "correct";