-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.php
7 lines (7 loc) · 18.3 KB
/
index.php
1
2
3
4
5
6
7
<?php
/*=================
IDA FAUCET SCRIPT
https://idatoken.org
version 0.2
=================*/
error_reporting(0);$version=0.2;$theme[0]=':root{--c1: #FFF;--c2: #000;--c3: #FFF;--c4: #000;--c5: #000;--c6: #FFF}';$theme[1]=':root{--c1: #003;--c2: #333;--c3: #EEE;--c4: #000;--c5: #FFF;--c6: #003}';$theme[2]=':root{--c1: #555;--c2: #000;--c3: #ccc;--c4: #06F;--c5: #FFF;--c6: #333}';$theme[3]=':root{--c1: #EEE;--c2: #cf6;--c3: #00C;--c4: #f77;--c5: #ff6;--c6: #066}';$theme[4]=':root{--c1: #fce;--c2: #f39;--c3: #222;--c4: #f6f;--c5: #f39;--c6: #303}';$theme[5]=':root{--c1: #fcc;--c2: #f60;--c3: #400;--c4: #f00;--c5: #f00;--c6: #100}';$theme[6]=':root{--c1: #ccc;--c2: #666;--c3: #cfc;--c4: #444;--c5: #444;--c6: #cfc}';$theme[7]=':root{--c1: #000;--c2: #CCC;--c3: #111;--c4: #FFF;--c5: #CCC;--c6: #111}';require_once('./settings.php');if(file_exists('./install.php'))exit('<h1>IDA FAUCET</h1><h2><a href="./install.php">Go to the installation</a></h2><h3>If your installation was done with success, remove the <em>install.php</em> file.</h3>');if(empty($ida_name)||empty($ida_reward)||empty($ida_delay)||empty($ida_maxclaims)||empty($api_ida)||empty($api_gr)||empty($api_grp)||empty($db_server)||empty($db_name)||empty($db_user)||empty($db_pass))exit('<h1>IDA FAUCET</h1><h2>Please reinstall your script</h2><h3>It seems your <em>settings.php</em> file is not filled correctly.</h3>');require_once('./api-class.php');$db=new mysqli($db_server,$db_user,$db_pass,$db_name);if($db->connect_error)exit('<h1>'.$ida_name.'</h1><h3>ERROR : MySQL Server is unreachable...</h3><br>Error : '.mysqli_connect_error());if($db->query('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = "'.$db_name.'" AND (table_name = "idafaucet_users" or table_name = "idafaucet_stats")')->fetch_row()[0]!=2)exit('<h1>'.$ida_name.'</h1><h3>ERROR : MySQL required tables did not exist.</h3><br>It should need a reinstallation.');$s=$db->query('select ida_balance, ida_api_limit, ida_api_serverlimit,ida_api_paycredits from idafaucet_stats where day="'.date('Y-m-d').'"');if($s->num_rows==0){$s=$db->query('select count(*),COALESCE(sum(claims),0) from idafaucet_users where claims!=0')->fetch_row();$db->query('update idafaucet_users set claims=0,token=NULL,shortener=NULL');$db->query('insert into idafaucet_stats (day,claims,users) values ("'.date('Y-m-d').'","0","0")');$db->query('update idafaucet_stats set claims="'.$s[1].'",users="'.$s[0].'" where day="'.date('Y-m-d',strtotime('yesterday')).'" ');$s=array(-1,0,0);}else{$s=$s->fetch_row();}if(isset($_GET['ref'])&&ctype_alnum($_GET['ref'])){setcookie('ref',$_GET['ref'],time()+84000);}session_start();if(isset($_POST['pass'])){if(sha1($_POST['pass'])!=$ida_pass){sleep(10);}else{$_SESSION['isAdmin']=1;}}if(isset($_POST['theme'])&&ctype_digit($_POST['theme'])&&isset($_SESSION['isAdmin'])){$f=file('./style.css');$f[0]=$theme[$_POST['theme']]."\n";file_put_contents('./style.css',implode($f));header('location:?admin');exit();}if(isset($_POST['ip'])&&ctype_alnum(str_replace([':','.'],'',$_POST['ip']))&&ctype_digit($_POST['time'])&&isset($_SESSION['isAdmin'])){$db->query('update idafaucet_users set banned="'.(time()+(86400*$_POST['time'])).'" where ip="'.$_POST['ip'].'" ');$urb=$db->affected_rows;}if(isset($_POST['uip'])&&ctype_alnum(str_replace([':','.'],'',$_POST['uip']))&&isset($_SESSION['isAdmin'])){$db->query('update idafaucet_users set banned="0" where ip="'.$_POST['uip'].'" ');$uru=$db->affected_rows;}if(!empty($_SERVER['QUERY_STRING'])&&$_SERVER['QUERY_STRING']=='logout'&&isset($_SESSION['isAdmin'])){$_SESSION=array();if(ini_get("session.use_cookies")){$params=session_get_cookie_params();setcookie(session_name(),'',time()-42000,$params["path"],$params["domain"],$params["secure"],$params["httponly"]);}session_destroy();header('location: ?admin');exit();}if(isset($_POST['ida_address'])){$_POST['ida_address']=trim($_POST['ida_address']);if(!empty($api_iphub)){$ch=curl_init();curl_setopt_array($ch,[CURLOPT_URL=>'http://v2.api.iphub.info/ip/'.$_SERVER['REMOTE_ADDR'],CURLOPT_RETURNTRANSFER=>true,CURLOPT_HTTPHEADER=>['X-Key: '.$api_iphub]]);$o=json_decode(curl_exec($ch),1);curl_close($ch);if(isset($o['block'])&&$o['block']==1)$v=1;}if(!ctype_alnum($_POST['ida_address'])){$e=1;}elseif(isset($v)){header('location: ?vpn');exit();}else{$api=new ida($api_ida,1);$ca=$api->call(['action'=>'isValid','address'=>$_POST['ida_address']]);if($ca['valid']!==true){$e=(strlen($ca['message'])>5)?$ca['message']:1;if($ca['code']==21||$ca['code']==22||$ca['code']==24)$e='No more Energy on the Faucet.... Sorry ! Come back later !';}else{$u=$db->query('select ip from idafaucet_users where address="'.$_POST['ida_address'].'"')->fetch_row();if(empty($u[0])){if(isset($_COOKIE['ref'])&&ctype_alnum($_COOKIE['ref'])&&$_COOKIE['ref']!=$_POST['ida_address']){$api2=new ida($api_ida,0);$rf=$api2->call(['action'=>'isValid','address'=>$_COOKIE['ref']]);}$db->query('insert into idafaucet_users (ip,address,ref) values ("'.$_SERVER['REMOTE_ADDR'].'","'.$_POST['ida_address'].'","'.((isset($_COOKIE['ref'])&&ctype_alnum($_COOKIE['ref'])&&$rf['valid']===true)?$_COOKIE['ref']:NULL).'")');}elseif($u[0]!=$_SERVER['REMOTE_ADDR']){$db->query('update idafaucet_users set ip="'.$_SERVER['REMOTE_ADDR'].'" where address="'.$_POST['ida_address'].'"');}$ti=$db->query('select address from idafaucet_users where lastclaim>"'.(time()-$ban_delay).'" and ip="'.$_SERVER['REMOTE_ADDR'].'"');if($ti->num_rows>1)$db->query('update idafaucet_users set banned="'.time().'" where ip="'.$_SERVER['REMOTE_ADDR'].'" ');$_SESSION['address']=$_POST['ida_address'];$_SESSION['token']=substr(sha1(uniqid('',true)),0,25);}}}if(isset($_SESSION['address'])){if($db->query('select ip from idafaucet_users where address="'.$_SESSION['address'].'"')->fetch_row()[0]!=$_SERVER['REMOTE_ADDR']){$_SESSION=array();if(ini_get("session.use_cookies")){$params=session_get_cookie_params();setcookie(session_name(),'',time()-42000,$params["path"],$params["domain"],$params["secure"],$params["httponly"]);}session_destroy();header('location: ./');exit();}}if(isset($_POST['sc'])){$v=curl_init();curl_setopt($v,CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");curl_setopt($v,CURLOPT_POST,true);curl_setopt($v,CURLOPT_POSTFIELDS,http_build_query(array('secret'=>$api_grp,'response'=>$_POST['g-recaptcha-response'],'remoteip'=>$_SERVER['REMOTE_ADDR'])));curl_setopt($v,CURLOPT_RETURNTRANSFER,true);$vr=json_decode(curl_exec($v),1);curl_close($v);if($vr['success']===true){$u=$db->query('select shortener,claims,banned,ref,address from idafaucet_users where address="'.$_SESSION['address'].'"')->fetch_row();if($u[1]>=$ida_maxclaims){$e=1;}elseif($_POST['sc']!=$_SESSION['token']){$e=1;}elseif(!empty($u[0])){$e=1;}elseif($u[2]>(time()-$ban_time)){$e=1;}else{$_SESSION['token']=substr(sha1(uniqid('',true)),0,25);if(isset($shorteners[$u[1]])&&!empty(($shorteners[$u[1]]))){$t=substr(md5(uniqid('',true)),0,20);$l=json_decode(file_get_contents($shorteners[$u[1]].urlencode($ida_url.'?claim='.$t)))->{"shortenedUrl"};if(empty($l)){$e=1;}else{$db->query('update idafaucet_users set token="'.$t.'",shortener="'.$l.'" where address="'.$_SESSION['address'].'"');header('location: '.$l);exit();}}else{$api=new ida($api_ida,1);$pr=$api->call(["action"=>"mpay","address"=>$u[4],"amount"=>($ida_reward*10**6)]);if($pr['result']===true&&$ida_ref!=0&&!empty($u[3])&&($ida_reward*($ida_ref/100))>=0.0001){$api2=new ida($api_ida,0);$pr2=$api2->call(["action"=>"mpay","address"=>$u[3],"amount"=>($ida_reward*($ida_ref/100))*10**6]);if($pr2['result']===true)$db->query('update idafaucet_stats set ida_balance="'.$pr['balanceFloat'].'",ida_api_limit="'.(100-$pr['serverLimit']).'",ida_api_serverlimit="'.(100-$pr['serverLimit']).'",ida_api_paycredits="'.$pr['payLeft'].'" where day="'.date('Y-m-d').'"');}if($pr['result']===true&&$pr2['result']!==true)$db->query('update idafaucet_stats set ida_balance="'.$pr['balanceFloat'].'",ida_api_limit="'.(100-$pr['serverLimit']).'",ida_api_serverlimit="'.(100-$pr['serverLimit']).'",ida_api_paycredits="'.$pr['payLeft'].'" where day="'.date('Y-m-d').'"');if($pr['result']===true)$db->query('update idafaucet_users set claims=claims+1,token=NULL,shortener=NULL,lastclaim="'.time().'" where address="'.$_SESSION['address'].'"');if($pr['result']===true&&!isset($pr['txid']))$done='<b class="alert-ok">Claim done ! Your balance contain '.number_format($pr['mpayBalance'],4).' IDA ! You need only '.number_format(0.1-$pr['mpayBalance'],4).' more IDA to get paid to your wallet !</b>';elseif($pr['result']===true&&isset($pr['txid']))$done='<b class="alert-ok">Your payment was sent to your wallet.<br>Transaction : '.$pr['txid'].'</b>';elseif($pr['result']!==true&&($pr['code']==21||$pr['code']==22||$pr['code']==24))$done='<b class="alert-error">No more Energy on the Faucet.... Sorry ! Come back later !</b>';else $done='<b class="alert-error">Something goes wrong.<br>API Error : '.$pr['message'].'</b>';}}$_SESSION['token']=substr(sha1(uniqid('',true)),0,25);}else{$e=1;$_SESSION['token']=substr(sha1(uniqid('',true)),0,25);}}if(isset($_SESSION['address'])&&isset($_GET['claim'])&&ctype_alnum($_GET['claim'])){$u=$db->query('select shortener,claims,banned,ref,address from idafaucet_users where token="'.$_GET['claim'].'" and address="'.$_SESSION['address'].'" and claims<"'.$ida_maxclaims.'" and banned<"'.(time()-$ban_time).'" ')->fetch_row();if(!empty($u[4])){$api=new ida($api_ida,1);$pr=$api->call(["action"=>"mpay","address"=>$u[4],"amount"=>($ida_reward*10**6)]);if($pr['result']===true&&$ida_ref!=0&&!empty($u[3])&&($ida_reward*($ida_ref/100))>=0.0001){$api2=new ida($api_ida,0);$pr2=$api2->call(["action"=>"mpay","address"=>$u[3],"amount"=>($ida_reward*($ida_ref/100))*10**6]);if($pr2['result']===true)$db->query('update idafaucet_stats set ida_balance="'.$pr['balanceFloat'].'",ida_api_limit="'.(100-$pr['serverLimit']).'",ida_api_serverlimit="'.(100-$pr['serverLimit']).'",ida_api_paycredits="'.$pr['payLeft'].'" where day="'.date('Y-m-d').'"');}if($pr['result']===true&&$pr2['result']!==true)$db->query('update idafaucet_stats set ida_balance="'.$pr['balanceFloat'].'",ida_api_limit="'.(100-$pr['serverLimit']).'",ida_api_serverlimit="'.(100-$pr['serverLimit']).'",ida_api_paycredits="'.$pr['payLeft'].'" where day="'.date('Y-m-d').'"');if($pr['result']===true)$db->query('update idafaucet_users set claims=claims+1,token=NULL,shortener=NULL,lastclaim="'.time().'" where address="'.$_SESSION['address'].'"');if($pr['result']===true&&!isset($pr['txid']))$done='<b class="alert-ok">Claim done ! Your balance contain '.number_format($pr['mpayBalance'],4).' IDA ! You need only '.number_format(0.1-$pr['mpayBalance'],4).' more IDA to get paid to your wallet !</b>';elseif($pr['result']===true&&isset($pr['txid']))$done='<b class="alert-ok">Your payment was sent to your wallet.<br>Transaction : '.$pr['txid'].'</b>';elseif($pr['result']!==true&&($pr['code']==21||$pr['code']==22||$pr['code']==24))$done='<b class="alert-error">No more Energy on the Faucet.... Sorry ! Come back later !</b>';else $done='<b class="alert-error">Something goes wrong.<br>API Error : '.$pr['message'].'</b>';}else{$e=1;}}echo '<html><head><title>'.$ida_name.'</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="https://fonts.googleapis.com/css?family=Exo:400,400i,700|Lexend+Zetta&display=swap" rel="stylesheet"><link rel="stylesheet" type="text/css" href="style.css?'.time().'"><script src="https://www.google.com/recaptcha/api.js" async defer></script></head><body><div id="main"><h1><a href="./">'.strtoupper($ida_name).'</a></h1><div id="headerstats">Faucet Balance : '.(($s[0]<0)?'???':$s[0]).' IDA<br>API/Server Energy left : '.min($s[1],$s[2],$s[3]).'%<br>Reward : '.$ida_reward.' IDA — Timer : '.$ida_delay.' minute(s)</div><br><br>'.(!empty($header_banners)?$header_banners.'<br><br>':'').'<br>';if(!empty($_SERVER['QUERY_STRING'])&&$_SERVER['QUERY_STRING']=='stats'){$tc=$db->query('select sum(claims) from idafaucet_stats')->fetch_row()[0];$tu=$db->query('select count(*) from idafaucet_users')->fetch_row()[0];$ds=$db->query('select day from idafaucet_stats order by day asc limit 1')->fetch_row()[0];$sa=$db->query('select count(*),sum(claims) from idafaucet_users where claims!=0')->fetch_row();$ta='<tr><td>'.date('Y-m-d').'</td><td>'.$sa[0].'</td><td>'.(empty($sa[1])?0:$sa[1]).'</td></tr>';$so=$db->query('select users,claims,day from idafaucet_stats where day!="'.date('Y-m-d').'" order by day desc limit 30 ');while($o=$so->fetch_row())$ta.='<tr><td>'.$o[2].'</td><td>'.$o[0].'</td><td>'.$o[1].'</td></tr>';echo '<h2>Statistics</h2><b class="alert-info">This faucet was used already '.($tc+$sa[1]).' times by '.$tu.' different user(s) since the start !<br>'.$ida_name.' is online since '.$ds.'.</b><br><br><table style="width:100%"><thead><tr><td>DAY</td><td>Active Users</td><td>Claims</td></tr></thead><tbody>'.$ta.'</tbody></table>';}elseif(!empty($_SERVER['QUERY_STRING'])&&$_SERVER['QUERY_STRING']=='admin'){if(!isset($_SESSION['isAdmin'])){echo '<h2>Admin Area</h2><form method="POST"><input type="password" name="pass" placeholder="Your Password"><input type="Submit" value="Enter in Admin Area!"></form>';}else{echo '<h2>Admin <a href="?logout">❎</a></h2>';if(!function_exists('file')||!function_exists('file_put_contents')||!function_exists('fopen')||!is_writable('./style.css'))echo '<h3>Color theme</h3><b>MAY NOT WORK (style.css is protected)</b><br>';else echo '<h3>Color theme</h3>';echo 'Choose from the following : <form method="POST"><select name="theme"><option value="0">Choose</option><<option value="1">Default</option><option value="2">Alternative</option><option value="3">Fancy</option><option value="4">Girly</option><option value="5">Bloody</option><option value="6">Brighty</option><option value="7">Darky</option></select><input type="Submit" value="Change!"></form><h3>Ban user</h3>Ban one IPv4 or IPv6 from claiming : <form method="POST"><input type="text" name="ip" placeholder="IP to ban"><input type="number" name="time" placeholder="Time in days"><input type="Submit" value="Ban!"></form>';if(isset($urb))echo '<b class="alert-info">'.$urb.' address banned !</b><br>';echo '<h3>Unban user</h3>Unban one IPv4 or IPv6 : <form method="POST"><input type="text" name="uip" placeholder="IP to unban"><input type="Submit" value="Unban!"></form>';if(isset($uru))echo '<b class="alert-info">'.$uru.' address unbanned !</b><br>';$cv=file_get_contents('https://raw.githubusercontent.com/idatoken/ida-faucet/master/lastversion');if(!$cv)echo '<br><b>SCRIPT VERSION '.$version.' - <a href="https://github.com/idatoken/ida-faucet" target="_blank">Check for updates</a></b>';elseif($cv!=$version)echo '<br><b class="alert-error"><a href="https://github.com/idatoken/ida-faucet" target="_blank">NEW VERSION AVAILABLE ! Please Update ASAP</a></b>';else echo '<br><b>SCRIPT VERSION '.$version.' [No update available]</b>';}}elseif(!empty($_SERVER['QUERY_STRING'])&&$_SERVER['QUERY_STRING']=='vpn'){echo '<h2>Unauthorized</h2><b class="alert-info">Ho noo, you are using a VPN / Proxy or an unauthorized IP ! Sorry, you can not claim from this IP !</b><br>';}elseif(!isset($_SESSION['address'])){if(isset($e))echo '<b class="alert-error">'.(($e!=1)?'IDA API : '.$e:'ERROR : Your Address seems invalid... Please try again.').'</b><br>';echo '<form method="POST"><input type="text" name="ida_address" placeholder="Your IDA / TRON Address" required><button type="submit">Start Fauceting!</button></form><br><br><h4>IDA or TRON address ?</h4>It is the same ! You can but there is no reason to use distinct addresses to store/use TRON and IDA Token.<br>You are better to use the same address to hold all of your TRX & TRON tokens, it will be easy.<br>You do not have any TRON or IDA address yet? No problem, you can create one for free by using a wallet from bellow to handle this.<h4>IDA Wallet</h4>You can get a free wallet for your laptop or mobile. The best choices are : <a href="https://www.tronlink.org/" target="_blank" rel="nofollow">TronLink</a> and <a href="https://www.tronwallet.me/" target="_blank" rel="nofollow">TronWallet</a>.';}else{$u=$db->query('select ip,claims,lastclaim,token,banned,shortener from idafaucet_users where address="'.$_SESSION['address'].'"')->fetch_row();if($ida_ref!=0)$ref='Share your referral link and earn '.$ida_ref.'% of all of your referral\'s claims !<br><small><b>'.$ida_url.'?ref='.$_SESSION['address'].'</b></small><hr>';else $ref='';echo '<h2>Faucet</h2><div class="box">'.$ref.'You can still make '.($ida_maxclaims-$u[1]).' claim(s) for today !</div>';if($u[4]>(time()-$ban_time)){echo '<b class="alert-error">Sorry. This account is banned because you claimed from multiple addresses. You will be unbanned on '.date('Y-m-d H:i:s',(time()+$ban_time)).'.</b><br>';}elseif($u[1]>=$ida_maxclaims){if(isset($done))echo $done.'<br><br>You reached the claims limit.';else echo '<b class="alert-info">Sorry. You reached the claims limit. You will be able to claim again in '.number_format((strtotime('tomorrow')-time())/3600,1).' hour(s).</b><br>';}elseif(isset($done)){echo $done.'<br><br><a href="./">Claim again</a>';}else{echo '<br>Hi !<br>This Faucet is working with a balance if your claims value does not reach 0.1 IDA...<br>At 0.1 IDA or more, the payment is sent directly to your wallet !<br>ENJOY 😁<br><br>';if($u[2]>time()-($ida_delay*60)){echo '<b class="alert-info">You will be able to claim again in '.ceil((($u[2]+($ida_delay*60))-time())/60).' minute(s). <a href="./">🔄</a></b><br>';}elseif(!empty($u[5])){if(isset($e))echo '<b class="alert-error">Something goes wrong during your claim.</b><br>';echo '<b>Please, visit this shortener to validate your claim : <a href="'.$u[5].'">Claim Shortener</a></b>';}else{if(isset($e))echo '<b class="alert-error">Something goes wrong during your claim. Please retry.</b><br>';echo '<form method="POST"><input type="hidden" name="sc" value="'.$_SESSION['token'].'"><div style="margin:auto;width:300px;" class="g-recaptcha" data-sitekey="'.$api_gr.'"></div><br><input type="submit" value="Claim now"></form>';}}echo '<br>';}echo '<br><br>';if(!empty($footer_banners))echo $footer_banners.'<br><br>';echo $popunder.'<hr>© <a href="'.$ida_url.'">'.$ida_name.'</a> - <a href="?stats">Statistics</a> - <a href="?admin">Admin</a><br>'; ?>Made by <a href="https://idatoken.org"target="_blank"><b>IDA TOKEN</b></a> with <a href="https://github.com/idatoken/ida-faucet"target="_blank">GitHub Faucet Script</a><?php //YOU CAN NOT REMOVE THE COPYRIGHT in ABOVE LINE FROM THE MIT License even if you modify/customize/edit the script -- Remember : this script is free to use... Let's people known this faucet script and IDA TOKEN to help the community grow ?>