prepare("select * from vpnuser where vuser = '".$username."'");
$data->execute();
$row = $data->fetch(PDO::FETCH_ASSOC);
if (!empty($row)){
$hyid = "1";
$speed = "1024";
$group = "BY";
$months = "+1 month";
$day = 30;
$price = 100;
$package = "월정제 Basic(30일)";
if($days == "1month") {
$day = 30;
$months = "+1 month";
if($plan == "basic") {
$price = 100;
$package = "월정제 Basic(30일)";
$hyid = "1";
$speed = "1024";
} else if($plan == "premium") {
$price = 200;
$package = "월정제 Premium(30일)";
$hyid = "1";
$speed = "2048";
} else if($plan == "vip") {
$price = 400;
$package = "월정제 VIP(30일)";
$hyid = "1";
$speed = "4096";
}
} else if($days == "12month") {
$day = 365;
$months = "+1 year";
if($plan == "basic") {
$price = 600;
$package = "월정제 Basic(선납1년)";
$hyid = "1";
$speed = "1024";
} else if($plan == "premium") {
$package = "월정제 Premium(선납1년)";
$price = 1200;
$hyid = "1";
$speed = "2048";
} else if($plan == "vip") {
$price = 2400;
$package = "월정제 VIP(선납1년)";
$hyid = "1";
$speed = "4096";
}
}
$data = $db->prepare("INSERT INTO prddbh (paymethod, bh, vpnus, spname, groups, sday, sjg, ddtype, ddtime, ddip, oldhyid, oldlastdate) VALUES ('"
.$type."', '"
.date("Ymd").mt_rand(1000,9999)."', '"
.$username."', '"
.$package."', 'BY', '"
.$day."', '"
.$price."', 'PC', '"
.date("Y-m-d H:i:s")."', '"
.$ip."', '"
.$row['hyid']."', '"
.$row['lastdate']."' )");
$data->execute();
$bb='
지불방법:'.$type.'
회원id:'.$username.'
변경전 만료일자:'.$row['lastdate'].'
변경된 만료일자:'.$row['lastdate'].'
지불시간:'.date("Y-m-d H:i:s").'
지불금액:'.$price.'
날짜 :'.$day.'
IP :'.$ip.'
' ;
$url = 'https://sc.ftqq.com/SCU22070T797d6f740bb68d2275f3fb86efdd106e5d7efbf03a7df.send?text='.urlencode($bb);
$r=get_url_contents_and_final_url($url);
if($row['groups'] == 'LL') {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
} else {
if (date("Y-m-d H:i:s", strtotime($row['lastdate'])) <= date("Y-m-d H:i:s" )) {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
} else {
if($hyid == 2 | $hyid == 3) {
if($row['hyid'] == 2 | $row['hyid'] == 3) {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months, strtotime($row['lastdate'])))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
} else {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
$newData = $db->prepare("select * from vpnuser where vuser='".$username."'");
$newData->execute();
$new = $newData->fetch(PDO::FETCH_ASSOC);
$now = time(); // or your date as well
$expire = strtotime($row['lastdate']);
$datediff = $expire - $now;
$days = round($datediff / (60 * 60 * 24));
$money = 0;
if($row['hyid'] == 4 )
$money = ($days / 30) * 32;
else if($row['hyid'] == 5)
$money = ($days / 30) * 64;
$plusDays = round($money / (16 / 30));
$plusStr = "+1 day";
if($plusDays > 1) {
$plusStr = "+".$plusDays." days";
}
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($plusStr, strtotime($new['lastdate'])))
."' where vuser='".$username."'");
$data->execute();
}
} else if($hyid == 4) {
if($row['hyid'] == 4) {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months, strtotime($row['lastdate'])))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
} else {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
$newData = $db->prepare("select * from vpnuser where vuser='".$username."'");
$newData->execute();
$new = $newData->fetch(PDO::FETCH_ASSOC);
$now = time(); // or your date as well
$expire = strtotime($row['lastdate']);
$datediff = $expire - $now;
$days = round($datediff / (60 * 60 * 24));
$money = 0.0;
if($row['hyid'] == 2 | $row['hyid'] == 3 ) {
$money = ($days / 30) * 16;
} else if($row['hyid'] == 5) {
$money = ($days / 30) * 64;
}
$plusDays = round($money / (32 / 30));
$plusStr = "+1 day";
if($plusDays > 1) {
$plusStr = "+".$plusDays." days";
}
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($plusStr, strtotime($new['lastdate'])))
."' where vuser='".$username."'");
$data->execute();
}
} else if($hyid == 5) {
if($row['hyid'] == 5) {
$data = $db->prepare("update vpnuser set lastdate = '" . date("Y-m-d H:i:s", strtotime($months, strtotime($row['lastdate'])))
. "', hyid = '" . $hyid
. "', groups = '" . $group
. "', updk = '" . $speed
. "', downdk = '" . $speed
. "', flow = 0 where vuser='" . $username . "'");
$data->execute();
} else {
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($months))
."', hyid = '".$hyid
."', groups = '".$group
."', updk = '".$speed
."', downdk = '".$speed
."', flow = 0 where vuser='".$username."'");
$data->execute();
$newData = $db->prepare("select * from vpnuser where vuser='".$username."'");
$newData->execute();
$new = $newData->fetch(PDO::FETCH_ASSOC);
$now = time(); // or your date as well
$expire = strtotime($row['lastdate']);
$datediff = $expire - $now;
$days = round($datediff / (60 * 60 * 24));
$money = 0.0;
if($row['hyid'] == 4)
$money = ($days / 30) * 32;
else if($row['hyid'] == 2 | $row['hyid'] == 3)
$money = ($days / 30) * 16;
$plusDays = round($money / (64 / 30));
$plusStr = "+1 day";
if($plusDays > 1) {
$plusStr = "+".$plusDays." days";
}
$data = $db->prepare("update vpnuser set lastdate = '".date("Y-m-d H:i:s", strtotime($plusStr, strtotime($new['lastdate'])))
."' where vuser='".$username."'");
$data->execute();
}
}
}
}
if($data->execute()) {
echo json_encode([
"status" => 200,
"message" => "Success",
"data" => $row
]);
return;
}
} else {
echo json_encode([
"status" => 401,
"message" => "User doesn't exist",
]);
return;
}
function get_url_contents_and_final_url(&$url)
{
do
{
$context = stream_context_create(
array(
"http" => array(
"follow_location" => false,
),
)
);
$result = file_get_contents($url, false, $context);
$pattern = "/^Location:\s*(.*)$/i";
$location_headers = preg_grep($pattern, $http_response_header);
if (!empty($location_headers) &&
preg_match($pattern, array_values($location_headers)[0], $matches))
{
$url = $matches[1];
$repeat = true;
}
else
{
$repeat = false;
}
}
while ($repeat);
return $result;
}
?>