diff --git a/confirm.php b/confirm.php index 4238ddc..10dd675 100644 --- a/confirm.php +++ b/confirm.php @@ -10,6 +10,7 @@ $mastodon_user = $explode[0]; $mastodon_server = $explode[1]; $mastodon_link = "https://".$explode[1]."/@".$explode[0]; + $mastodon_special_link = $mastodon_user."_at_".$mastodon_server; if(isset($_POST['verify_twitter'])) { @@ -29,16 +30,44 @@ else { break; } } - preg_match("(
.+?".$mastodon_link.".+?Twittodon.com)is", $site_source_code, $phrase); + preg_match("(
.+?".$mastodon_special_link.".+?Twittodon.com)is", $site_source_code, $phrase); if(!empty($phrase[0])) { - $update = "UPDATE connections SET twitter_verified='1' WHERE twitter_login='".$twitter."' AND mastodon_login='".$mastodon."'"; + $today = date("Y-m-d"); + $update = "UPDATE connections SET twitter_verified='1', date='".$today."' WHERE twitter_login='".$twitter."' AND mastodon_login='".$mastodon."'"; mysqli_query($mysqli, $update) or die('ERROR TD02'); } else { - $twitter_verified_error = true; + $nitter_link = "https://nitter.it/".$twitter; + + $curl = curl_init($nitter_link); + curl_setopt($curl, CURLOPT_URL, $nitter_link); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36'); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + curl_setopt($curl, CURLOPT_HEADER, 0); + + $site_source_code = curl_exec($curl); + for($i=1; $i<=5; $i++) + { + if($site_source_code == "") { $site_source_code=curl_exec($curl); } + else { break; } + } + + preg_match("(
.+?".$mastodon_special_link.".+?Twittodon.com)is", $site_source_code, $phrase); + + if(!empty($phrase[0])) + { + $today = date("Y-m-d"); + $update = "UPDATE connections SET twitter_verified='1', date='".$today."' WHERE twitter_login='".$twitter."' AND mastodon_login='".$mastodon."'"; + mysqli_query($mysqli, $update) or die('ERROR TD02'); + } + else + { + $twitter_verified_error = true; + } } } @@ -359,9 +388,9 @@ echo ""; echo ""; echo ""; - echo "
"; + echo "
"; echo ""; - echo ""; + echo ""; echo "
"; echo ""; echo "
"; @@ -503,4 +532,4 @@ - \ No newline at end of file +