44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
include('connection.php');
|
|
include('coinmarketcap.php');
|
|
|
|
$conn = OpenCon();
|
|
|
|
$tweetId = $_GET['tweet_id'];
|
|
$authorId = $_GET['author_id'];
|
|
$createdAt = $_GET['created_at'];
|
|
|
|
$text = $_GET['text'];
|
|
$tokenCode= $_GET['token_code'];
|
|
$tokenName=$_GET['token_name'];
|
|
|
|
$namecheckSql = "SELECT id FROM Tweets WHERE id=$tweetId";
|
|
$namecheckQuery = mysqli_query($conn, $namecheckSql);
|
|
|
|
if(mysqli_num_rows($namecheckQuery) > 0){
|
|
|
|
|
|
die("5");
|
|
//die("This post already exists");
|
|
}
|
|
$tokenPrice = GetTokenPrice(str_replace(" ", "",$tokenCode));
|
|
// die("Price : $tokenPrice.$tokenCode");
|
|
$insertQuery = "INSERT INTO Tweets (id,created_at,author,text,tokenCode, tokenName, price_at_creation) VALUES($tweetId,STR_TO_DATE('$createdAt', '%m/%d/%Y %r'), $authorId, '$text','$tokenCode','$tokenName', $tokenPrice)";
|
|
//die($insertQuery);
|
|
if(mysqli_query($conn, $insertQuery)){
|
|
echo "1";
|
|
}else{
|
|
echo "-1";
|
|
}
|
|
|
|
if($tokenCode != "unknown"){
|
|
$tokenCheckSql = "SELECT long_name FROM Tokens WHERE code='$tokenCode'";
|
|
$tokenCheckQuery = mysqli_query($conn, $tokenCheckSql);
|
|
|
|
if(mysqli_num_rows($tokenCheckQuery) <= 0){
|
|
//add new token
|
|
|
|
}
|
|
}
|
|
|
|
?>
|