-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f11cb0
commit f8be5ee
Showing
6 changed files
with
94 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ function init() { | |
} | ||
|
||
return init(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
<?php | ||
//POST DATA | ||
$tguser = (INT)$_POST['user']; | ||
$token = $_POST['token']; | ||
$tguser = (INT)$_POST['user']; //Telegram User ID | ||
$token = $_POST['token']; | ||
|
||
//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']; | ||
$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']; | ||
|
||
if ($token = null or $tguser =null){ | ||
echo("Not correct POST Data") | ||
die; | ||
} | ||
|
||
//Check Token | ||
if (!$token = $hosttoken){ | ||
echo("Auth Fail"); | ||
die("Auth Fail"); | ||
} | ||
|
||
//Database | ||
//Database Connection | ||
$db = new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset=utf8', $db_user, $db_password); | ||
|
||
//get data | ||
$qalist = $db->prepare("SELECT user, list, now, next FROM qalist WHERE user = :user"); | ||
$qalist->bindParam(':user',$tguser, PDO::PARAM_INT); | ||
$qalist->execute(); | ||
$obj = $qalist->fetchObject(); | ||
//get user question queue data | ||
$QuesrionQueueList = $db->prepare("SELECT user, list, now, next FROM qalist WHERE user = :user"); | ||
$QuesrionQueueList->bindParam(':user',$tguser, PDO::PARAM_INT); | ||
$QuesrionQueueList->execute(); | ||
$Object = $QuesrionQueueList->fetchObject(); | ||
|
||
$userquestion = $obj->now; | ||
$qa = JSON_Decode($obj->list); | ||
$qnumber = $qa[$userquestion] + 0; | ||
$UserQuestionID = $Object->now; | ||
$UserQuestionQueue = JSON_Decode($Object->list); | ||
$QuestionID = $UserQuestionQueue[$UserQuestionID] + 0; | ||
|
||
$qalist1 = $db->prepare("SELECT id, question, author, answers FROM question WHERE id = :id"); | ||
$qalist1->bindParam(':id',$qnumber, PDO::PARAM_INT); | ||
$qalist1->execute(); | ||
$obj2 = $qalist1->fetchObject(); | ||
$tempArr = JSON_Decode($obj2->answers); | ||
$obj2->answers = $tempArr; | ||
echo JSON_Encode($obj2); | ||
$QuestionList = $db->prepare("SELECT id, question, author, answers FROM question WHERE id = :id"); | ||
$QuestionList->bindParam(':id',$QuestionID, PDO::PARAM_INT); | ||
$QuestionList->execute(); | ||
$Object2 = $QuestionList->fetchObject(); | ||
$TempArray = JSON_Decode($Object2->answers); | ||
$Object2->answers = $TempArray; | ||
echo JSON_Encode($Object2); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters