-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_info.php
More file actions
32 lines (27 loc) · 819 Bytes
/
user_info.php
File metadata and controls
32 lines (27 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
//POST DATA
$token = $_POST['token'];
$tguser = (INT)$_POST['user']; //Telegram User ID
//Variables
$config = include('config.php');
$hosttoken = $config['token'];
$db_host = $config['db_host'];
$db_name = $config['db_name'];
$db_user = $config['db_user'];
$db_password = $config['db_password'];
//Database
$db = new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset=utf8', $db_user, $db_password);
//Check POST Data
if ($token = null or $tguser =null){
die("NOT_CORRECT_POST_DATA");
}
//check token
if($token != $hosttoken){
die("AUTH_FAILED");
}
//Get User info
$UserInfo = $db->prepare("SELECT rightanswer, wronganswer FROM user WHERE user = :user");
$UserInfo->bindParam(':user',$tguser,PDO::PARAM_INT);
$UserInfo->execute();
$Object = $UserInfo->fetchObject();
echo JSON_Encode($Object);