Skip to content

Commit

Permalink
add country number for registration whitelist
Browse files Browse the repository at this point in the history
country number
  • Loading branch information
ibnux authored Jan 14, 2021
2 parents 6d3c102 + ebb3969 commit e97e931
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
5 changes: 4 additions & 1 deletion config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@
$msg_sms_text = "Your Tinfoil Password: {{pin}}\n\nIgnore if you dont request password";

// Google drive download url
$drive_url = 'https://docs.google.com/uc?export=download&id=';
$drive_url = 'https://docs.google.com/uc?export=download&id=';

// allowed phone number for auth
$phone_country = ['62','08'];
47 changes: 27 additions & 20 deletions function.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,43 @@ function getDatabase($createTable = false){
}

function require_auth() {
global $msg_pass_send,$msg_login_info,$msg_sms_text;
global $msg_pass_send,$msg_login_info,$msg_sms_text,$phone_country ;
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$pesan = $msg_login_info;
$is_not_authenticated = true;
if(!empty($_SERVER['PHP_AUTH_USER'])){
$phone = alphanumeric($_SERVER['PHP_AUTH_USER']);
$pathUser = "./data/user/".md5($phone).".user";
if(empty($_SERVER['PHP_AUTH_PW'])){
if(file_exists($pathUser)){
$pin = file_get_contents($pathUser);
}else{
$pin = rand(1000,9999);
file_put_contents($pathUser,$pin);
}
$pesan = $msg_pass_send;
sendSMS($phone,str_replace("{{pin}}",$pin,$msg_sms_text));
}else{
if(file_exists($pathUser)){
$pin = file_get_contents($pathUser);
if($pin!=$_SERVER['PHP_AUTH_PW']){
if(strlen($phone)>5){
$cncode = substr($phone,0,2);
if(count($phone_country)==0 || in_array($cncode,$phone_country)){
$pathUser = "./data/user/".md5($phone).".user";
if(empty($_SERVER['PHP_AUTH_PW'])){
if(file_exists($pathUser)){
$pin = file_get_contents($pathUser);
}else{
$pin = rand(1000,9999);
file_put_contents($pathUser,$pin);
}
$pesan = $msg_pass_send;
sendSMS($phone,str_replace("{{pin}}",$pin,$msg_sms_text));
}else{
$is_not_authenticated = false;
if(file_exists($pathUser)){
$pin = file_get_contents($pathUser);
if($pin!=$_SERVER['PHP_AUTH_PW']){
$pesan = $msg_pass_send;
sendSMS($phone,str_replace("{{pin}}",$pin,$msg_sms_text));
}else{
$is_not_authenticated = false;
}
}else{
$pin = rand(1000,9999);
file_put_contents($pathUser,$pin);
$pesan = $msg_pass_send;
sendSMS($phone,str_replace("{{pin}}",$pin,$msg_sms_text));
}
}
}else{
$pin = rand(1000,9999);
file_put_contents($pathUser,$pin);
$pesan = $msg_pass_send;
sendSMS($phone,str_replace("{{pin}}",$pin,$msg_sms_text));
$pesan = "Only for Phone number with prefix ". implode(",",$phone_country);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions import/drive2db.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
echo $pageToken;

$list = listFiles($idfolder, $pageToken);

$allowed_ext = ['xci','nsp','nsz'];
foreach ($list['files'] as $item) {
if (!$db->has('t_games_url', ['url' => $item['id']])) {
if ($item['fileExtension'] == 'nsz' || $item['fileExtension'] == 'xci') {
if (in_array($item['fileExtension'],$allowed_ext)) {
if ($item['parents'][0] == $idfolder && !empty($item['name'])) {
$gameid = getGameID($item['name']);
$games = $db->get("t_games", ["name",'size'], ['titleid' => $gameid]);
Expand Down

0 comments on commit e97e931

Please sign in to comment.