Skip to content
Snippets Groups Projects
Commit a2eea3da authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

Fixing mysql injection attacks

parent 8339ebc2
No related branches found
No related tags found
No related merge requests found
<?php <?php
require_once($_SERVER['DOCUMENT_ROOT']."/api/lib/Database.class.php");
class REST { class REST {
public $_allow = array(); public $_allow = array();
...@@ -103,6 +104,7 @@ ...@@ -103,6 +104,7 @@
}else{ }else{
$data = trim(stripslashes($data)); $data = trim(stripslashes($data));
$data = strip_tags($data); $data = strip_tags($data);
$data = mysqli_real_escape_string(Database::getConnection(), $data);
$clean_input = trim($data); $clean_input = trim($data);
} }
return $clean_input; return $clean_input;
......
...@@ -52,8 +52,7 @@ class API extends REST { ...@@ -52,8 +52,7 @@ class API extends REST {
$st = microtime(true); $st = microtime(true);
if(isset($this->_request['pass'])){ if(isset($this->_request['pass'])){
$cost = (int)$this->_request['cost']; $cost = (int)$this->_request['cost'];
$s = new Signup("", $this->_request['pass'], ""); $hash = password_hash($this->_request['pass'], PASSWORD_BCRYPT);
$hash = $s->hashPassword($cost);
$data = [ $data = [
"hash" => $hash, "hash" => $hash,
"info" => password_get_info($hash), "info" => password_get_info($hash),
......
<?php <?php
require_once $_SERVER['DOCUMENT_ROOT'].'/api/lib/Signup.class.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/api/lib/Signup.class.php';
require_once($_SERVER['DOCUMENT_ROOT']."/api/lib/Database.class.php");
$token = $_GET['token']; $token = mysqli_real_escape_string(Database::getConnection(), $_GET['token']);
try{ try{
if(Signup::verifyAccount($token)){ if(Signup::verifyAccount($token)){
?> ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment