session_start(); include_once "classes/DBConnector.class.php"; function validateLatin($string) { $result = false; if (preg_match("/^[\\w\\d\\s.,-]*\$/", $string)) { $result = true; } return $result; } $eskiSifre = $_POST["passChangeEskiSifre"]; $yeniSifre = $_POST["passChangeYeniSifre"]; $userName = $_SESSION["user_name"]; $myDBConnector = new DBConnector(); $dbARY = $myDBConnector->infos(); if (validateLatin($yeniSifre)) { $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]); if ($connecion->connect_error) { echo json_encode(utf8_encode("CONNECT_ERR")); } else { $query = "SELECT * FROM users WHERE userName='******'"; $results = $connection->query($query); $curResult = $results->fetch_assoc(); if ($eskiSifre !== $curResult["userPass"]) { echo json_encode(utf8_encode("SIFRE_HATALI")); } else { $query = "UPDATE users SET userPass='******' WHERE userName='******'"; if ($connection->query($query) === TRUE) { echo json_encode(utf8_encode("OK")); } else { echo json_encode(utf8_encode("QUERY_ERR"));
include_once 'classes/DBConnector.class.php'; function validateLatin($string) { $result = false; if (preg_match("/^[\\w\\d\\s.,-]*\$/", $string)) { $result = true; } return $result; } $email = htmlspecialchars($_POST["email_signup"]); $userName = htmlspecialchars(str_replace(" ", "_", $_POST["nick_signup"])); $password = htmlspecialchars($_POST["password_signup"]); $myDBConnector = new DBConnector(); $dbARY = $myDBConnector->infos(); if (validateLatin($userName)) { if (validateLatin($password)) { $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]); if ($connection->connect_error) { echo "CONNECT_ERR"; } else { /*database'e bağlandık */ $query1 = "SELECT * FROM users WHERE userName=\"" . $userName . "\""; $query2 = "SELECT * FROM users WHERE userEmail=\"" . $email . "\""; $result1 = $connection->query($query1); $result2 = $connection->query($query2); if ($result1->num_rows == 0) { if ($result2->num_rows == 0) { $connection->set_charset("utf8"); $activationCode = md5(uniqid(rand(), true)); $query3 = "INSERT INTO users(activation,activationCode,userEmail,userName,userPass) VALUES (\"NO\",\"" . $activationCode . "\",\"" . $email . "\",\"" . $userName . "\",\"" . $password . "\")"; if ($connection->query($query3) === TRUE) {