From 6281abdc5ec06f4d835c08200efb1800594ed9db Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Jun 2024 23:34:56 +0800 Subject: [PATCH] init --- add_tweet.php | 44 ++++++++++++++++++++ add_twitter_tag.php | 19 +++++++++ coinmarketcap.php | 86 +++++++++++++++++++++++++++++++++++++++ complete_request.php | 17 ++++++++ connection.php | 19 +++++++++ dexscreener.php | 40 ++++++++++++++++++ get_approved_users.php | 18 ++++++++ get_is_joined.php | 10 +++++ get_leaderboard.php | 16 ++++++++ get_requests.php | 16 ++++++++ get_token_price.php | 13 ++++++ get_tokens.php | 36 ++++++++++++++++ get_tweets.php | 17 ++++++++ get_twitter_username.php | 13 ++++++ participate.php | 24 +++++++++++ register_twitter_user.php | 26 ++++++++++++ set_leaderboard_item.php | 21 ++++++++++ set_tweet_token.php | 21 ++++++++++ test.php | 11 +++++ twitter_callback.php | 3 ++ 20 files changed, 470 insertions(+) create mode 100644 add_tweet.php create mode 100644 add_twitter_tag.php create mode 100644 coinmarketcap.php create mode 100644 complete_request.php create mode 100755 connection.php create mode 100644 dexscreener.php create mode 100644 get_approved_users.php create mode 100644 get_is_joined.php create mode 100644 get_leaderboard.php create mode 100644 get_requests.php create mode 100644 get_token_price.php create mode 100644 get_tokens.php create mode 100644 get_tweets.php create mode 100644 get_twitter_username.php create mode 100644 participate.php create mode 100644 register_twitter_user.php create mode 100644 set_leaderboard_item.php create mode 100644 set_tweet_token.php create mode 100644 test.php create mode 100644 twitter_callback.php diff --git a/add_tweet.php b/add_tweet.php new file mode 100644 index 0000000..35dbed0 --- /dev/null +++ b/add_tweet.php @@ -0,0 +1,44 @@ + 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 + + } +} + +?> \ No newline at end of file diff --git a/add_twitter_tag.php b/add_twitter_tag.php new file mode 100644 index 0000000..6692604 --- /dev/null +++ b/add_twitter_tag.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/coinmarketcap.php b/coinmarketcap.php new file mode 100644 index 0000000..6a0554c --- /dev/null +++ b/coinmarketcap.php @@ -0,0 +1,86 @@ + $highestPair["volume"]["h24"] &&($pairSymbolLow == $tokenSymbolLow || $pairSymbolLow == "$".$tokenSymbolLow)){ + // echo "New High" . $pair["baseToken"]["symbol"]; + $highestPair =$pair; + } + } + echo json_encode($highestPair); + return $highestPair["priceUsd"]; + } + +function sGetTokenPrice($tokenSymbol){ + $apiKey = '8faf016d-9cbd-40b3-889d-a45354621601'; + + // Replace with the token symbol you want to fetch (e.g., BTC, ETH, ADA) + + // CoinMarketCap API endpoint + $endpoint = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest'; + + // Parameters for the API request + $params = [ + 'symbol' => $tokenSymbol, + 'convert' => 'USD' + ]; + + // Initialize cURL session + $ch = curl_init(); + + // Set cURL options + curl_setopt($ch, CURLOPT_URL, $endpoint . '?' . http_build_query($params)); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'X-CMC_PRO_API_KEY: ' . $apiKey, + 'Accept: application/json' + ]); + + // Execute cURL session + $response = curl_exec($ch); + + // Check for cURL errors + if(curl_errno($ch)) { + echo 'Error:' . curl_error($ch); + } + + // Close cURL session + curl_close($ch); + + // Decode JSON response + $data = json_decode($response, true); + + // Check if data was retrieved successfully + if(isset($data['data'][$tokenSymbol]['quote']['USD']['price'])) { + $priceUSD = $data['data'][$tokenSymbol]['quote']['USD']['price']; + return $priceUSD; + } else { + return -1; + } +} diff --git a/complete_request.php b/complete_request.php new file mode 100644 index 0000000..51db0b8 --- /dev/null +++ b/complete_request.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/connection.php b/connection.php new file mode 100755 index 0000000..7da9e83 --- /dev/null +++ b/connection.php @@ -0,0 +1,19 @@ + error); + + return $conn; + } + + function CloseCon($conn) + { + $conn -> close(); + } + +?> \ No newline at end of file diff --git a/dexscreener.php b/dexscreener.php new file mode 100644 index 0000000..403440f --- /dev/null +++ b/dexscreener.php @@ -0,0 +1,40 @@ + $highestPair["volume"]["h24"]){ + $highestPair =$pair; + } + } + + echo json_encode($highestPair); + + // Return null if no pair found + return null; +} +?> diff --git a/get_approved_users.php b/get_approved_users.php new file mode 100644 index 0000000..23077b9 --- /dev/null +++ b/get_approved_users.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/get_is_joined.php b/get_is_joined.php new file mode 100644 index 0000000..0374581 --- /dev/null +++ b/get_is_joined.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/get_leaderboard.php b/get_leaderboard.php new file mode 100644 index 0000000..0ce233c --- /dev/null +++ b/get_leaderboard.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/get_requests.php b/get_requests.php new file mode 100644 index 0000000..8796065 --- /dev/null +++ b/get_requests.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/get_token_price.php b/get_token_price.php new file mode 100644 index 0000000..c33e985 --- /dev/null +++ b/get_token_price.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/get_tokens.php b/get_tokens.php new file mode 100644 index 0000000..294c931 --- /dev/null +++ b/get_tokens.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/get_tweets.php b/get_tweets.php new file mode 100644 index 0000000..d8fe317 --- /dev/null +++ b/get_tweets.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/get_twitter_username.php b/get_twitter_username.php new file mode 100644 index 0000000..8c9b5b4 --- /dev/null +++ b/get_twitter_username.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/participate.php b/participate.php new file mode 100644 index 0000000..085889d --- /dev/null +++ b/participate.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/register_twitter_user.php b/register_twitter_user.php new file mode 100644 index 0000000..583a123 --- /dev/null +++ b/register_twitter_user.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/set_leaderboard_item.php b/set_leaderboard_item.php new file mode 100644 index 0000000..66743a1 --- /dev/null +++ b/set_leaderboard_item.php @@ -0,0 +1,21 @@ + 0){ + //insert + $setQuery ="UPDATE Leaderboard SET points=$points WHERE username='$username'"; +} + +if(mysqli_query($conn, $setQuery)){ + echo "0"; +} + +?> \ No newline at end of file diff --git a/set_tweet_token.php b/set_tweet_token.php new file mode 100644 index 0000000..c523cad --- /dev/null +++ b/set_tweet_token.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/test.php b/test.php new file mode 100644 index 0000000..cc5a017 --- /dev/null +++ b/test.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/twitter_callback.php b/twitter_callback.php new file mode 100644 index 0000000..5d98b33 --- /dev/null +++ b/twitter_callback.php @@ -0,0 +1,3 @@ + \ No newline at end of file