Store in GIT
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require("../../inc/connect.php");
|
||||
require("../session.php");
|
||||
|
||||
$session = $_GET['session'];
|
||||
$device = $_GET['device'];
|
||||
|
||||
if($session == "")
|
||||
{
|
||||
JError("no session");
|
||||
}
|
||||
if($device == "")
|
||||
{
|
||||
JError("no device");
|
||||
}
|
||||
if(strlen($device) != 6)
|
||||
{
|
||||
JError("device id invalid");
|
||||
}
|
||||
|
||||
//check session
|
||||
verify_session($mysqli, $session);
|
||||
|
||||
//verify device
|
||||
$sql = "SELECT `id` FROM `device` WHERE `dev_id`='" . $device . "' AND `user`=0";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
JError("device id invalid");
|
||||
}
|
||||
|
||||
//get email address and username
|
||||
$sql = "SELECT `username`, `email` FROM `user` WHERE `id`=$user";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
$result = $query->fetch_assoc();
|
||||
$email = $result['email'];
|
||||
$username = $result['username'];
|
||||
|
||||
$code = $email . "~" . $device . "~";
|
||||
$code .= RandomString(96 - strlen($code));
|
||||
$code = str_rot13($code);
|
||||
|
||||
$sql = "UPDATE `user` SET `code`='$code' WHERE `id`=$user";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
$msg = "Hello " . $username . ",\n\n";
|
||||
$msg .= "Please verify your new device by clicking the link below.\n";
|
||||
$msg .= "<a href='http://lipa.kvewijk.nl/manage/php/session/verify.php?code=" . urlencode($code) . "'>Verify</a>";
|
||||
|
||||
sendMail($email, "Verify Device", $msg);
|
||||
|
||||
JSuccess("true");
|
||||
?>
|
||||
Reference in New Issue
Block a user