Skip to content

Commit

Permalink
add username
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiMGF2 committed Feb 23, 2023
1 parent d50a1ea commit fa0ad88
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtYWhkaTIwMDMiLCJhY2Nlc3MiOiJzdWRvIiwiZXhwIjoxNjc3MjcyMDE1fQ.lYBx64KS7QwPD8H_DWcA5o0F57UVmIWsqbfL1OoOKr8';//api توکن
$ip_port = 'http://91.107.185.91:8880'; // آدرس آیپی همراه با پورت
?>
165 changes: 165 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
@font-face {
font-family: 'Vazir-Bold';
src: url('../fonts/Vazir-Bold.eot');
src: local('☺'), url('../fonts/Vazir-Bold.woff2') format('woff'), url('../fonts/Vazir-Bold.ttf') format('truetype'), url('../fonts/Vazir-Bold.svg') format('svg');
}

* {
box-sizing: border-box;
margin: 0;
padding: 0

}

body,
button,
input {
font-family: Vazir-Bold
}

body {
background-color: #434955
}

.page-get {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10%

}

.img-get {
width: 50%;
padding: 20px
}

.img-get img {
width: 80%;
height: 55%
}


.form-get {
display: flex;
padding: 20px;
width: 50%;
justify-content: center;
align-items: center;
flex-direction: column
}

.form-get h2 {
color: #fff;
margin-bottom: 40px;
font-size: 18px
}

input {
background-color: #2D3748;
border-radius: 6px;
border: 1px solid #c8ccd0;
padding: 10px 3px;
width: 600px;
color: #fff
}

input:focus {
background-color: #58616f;
outline: 0
}

label {
color: #fff;
font-size: 15px;
margin-left: 10px
}

input[type="submit"] {
display: block;
margin: 20px auto 0 auto;
width: 50%;
background-color: #618ce9;
border: 0;
cursor: pointer
}
@media (max-width:600px){
.img-get{
display: none
}
.form-get{
margin-top: 25%;
width: 100%;
}
input{
width: 221px;
}
}
@media (min-width:601px) AND (max-width:990px){
.img-get{
display: none
}
.form-get{
width: 100%;
}
input{
width: 500px;
}
}
@media (min-width:991px) AND (max-width:1496px){
.form-get{
width: 100%;
}

}


/* page info */
.title{
margin-top: 2%;
margin-bottom: 30px;
color: #ded9d9;
text-align: center;
}
.box{
display: flex;
justify-content: center;
background-color: #cccccc;
flex-direction: column;
box-shadow: 0 0 3px 1px #c1c1c1;
max-width: 560px;
margin: 0 auto;
padding: 1rem;
border-radius: 10px;
}
.list{
display: flex;
justify-content: space-between;
width: 100%;
margin: 10px 0;
background-image: linear-gradient(to right,#315a71,#0072b4);
color: #fff;
padding: 10px 10px;
border-radius: 6px;
}
.status .value{
padding: 3px 15px;
border-radius:4px;
}
.status span{
font-size: 13px;
font-weight: 400;
}
.btndiv{
display: flex;
justify-content: center;
}
.btn{
text-align: center;
text-decoration: none;
color: #fff;
margin: 20px 0;
padding: 7px 20px;
background-color: #618ce9;
border-radius: 7px;
}
Binary file added fonts/Vazir-Bold.eot
Binary file not shown.
Binary file added fonts/Vazir-Bold.ttf
Binary file not shown.
Binary file added fonts/Vazir-Bold.woff
Binary file not shown.
Binary file added fonts/Vazir-Bold.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions img/Segment-pana.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Service Information</title>
<link rel="stylesheet" href="./css/style.css">
</head>

<body>
<div class="page-get">
<div class="img-get">
<img src="./img/Segment-pana.svg" alt="img">
</div>
<div class="form-get">
<h2>پنل نمایش اطلاعات سرویس</h2>
<form action="user.php" method="get" enctype="multipart/form-data">
<input type="text" name="usernames" id="username">
<label for="username">: نام کاربری</label>
<input type="submit" value="نمایش اطلاعات سرویس">
</form>
</div>
</div>
</body>

</html>
176 changes: 176 additions & 0 deletions user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?php
include('config.php');
//username get
$usernameac = $_GET['usernames'];
$url = $ip_port.'/api/user/'.$usernameac;
$header_value = 'Bearer ';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Authorization: ' . $header_value . $token));

$output = curl_exec($ch);
curl_close($ch);
$Data = json_decode($output, true);


//username
$username = $Data['username'];


//status
$status = $Data['status'];
switch ($status) {
case 'active':
$color_active = "#47bf2f";
$text_status = "فعال";
break;
case 'limited':
$color_active = "#bf2e2e";
$text_status = "پایان حجم";
break;

default:
$color_active = "#828282";
$text_status = "نامشخص";
break;
}



//TOTAL TRAFFIC
$dataLimit = $Data['data_limit'];
$LastTraffic = round($dataLimit / 1073741824, 2) . "GB";
if ($LastTraffic < 1) {
$LastTraffic = round($dataLimit / 1073741824, 2) * 1000 . "MB";
}
if ($LastTraffic == 0) {
$LastTraffic = "نامحدود";
$RemainingVolume = "نامحدود";
}

//used_traffic
$usedTraffic = $Data['used_traffic'];
$usedTrafficGb = round($usedTraffic / 1073741824, 2) . "GB";
if (round($usedTraffic / 1073741824, 2) < 1) {
$usedTrafficGb = round($usedTraffic / 1073741824, 2) * 1000 . "MB";
}
if (round($usedTraffic / 1073741824, 2) == 0) {
$usedTrafficGb = "مصرف نشده";
}



// remaining volume
if (round($dataLimit / 1073741824, 2) != 0) {
$min = round($dataLimit / 1073741824, 2) - round($usedTraffic / 1073741824, 2);
$RemainingVolume = $min . "GB";
if ($min < 1) {
$RemainingVolume = $min * 1000 . "MB";
}
if (round($dataLimit / 1073741824, 2) - round($usedTraffic / 1073741824, 2)< 1 ) {
$RemainingVolume = "نامشخص";
}}


//expire config
$expire = $Data['expire'];
$timestamp = $expire;
$expirationDate = date('Y/m/d', $timestamp);
$date_time_obj = new DateTime($expirationDate);
if ($date_time_obj->format('Y/m/d') == '1970/01/01') {
$expirationDate = "نامحدود";
}

//remaining time
$currentTime = time();
$timeDiff = $expire - $currentTime;

if ($timeDiff > 0) {
$day = floor($timeDiff / 86400) . " Day";
} else {
$day = "نامحدود";
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>خروجی اطلاعات</title>
<link rel="stylesheet" href="./css/style.css">
</head>

<body>
<h3 class="title"><span><?php echo $username; ?></span> نمایش اطلاعات کاربر</h3>
<div class="box">
<div class="list username">
<div class="value">
<h4><?php echo $username; ?></h4>
</div>
<div class="user">
<h4>: نام کاربری</h4>
</div>
</div>
<div class="list status">
<div style="background-color:<?php echo $color_active; ?>" class="value">
<h4><span><?php echo $text_status; ?></span></h4>
</div>
<div class="statusl">
<h4>: وضعیت سرویس </h4>
</div>
</div>
<div class="list total">
<div class="value">
<h4><?php echo $LastTraffic; ?></h4>
</div>
<div class="user">
<h4>:حجم کل سرویس</h4>
</div>
</div>
<div class="list usedTrafficGbs">
<div class="value">
<h4><?php echo $usedTrafficGb; ?></h4>
</div>
<div class="usedTrafficGb">
<h4>:حجم مصرف شده سرویس</h4>
</div>
</div>
<div class="list RemainingVolumes">
<div class="value">
<h4><?php echo $RemainingVolume; ?></h4>
</div>
<div class="RemainingVolume">
<h4>:حجم باقی مانده سرویس</h4>
</div>
</div>
<div class="list expirationDate">
<div class="value">
<h4><?php echo $expirationDate; ?></h4>
</div>
<div class="expirationDate">
<h4>:تاریخ پایان سرویس </h4>
</div>
</div>
<div class="list day">
<div class="value">
<h4><?php echo $day; ?></h4>
</div>
<div class="day">
<h4>:روزهای باقی مانده تا پایان سرویس </h4>
</div>
</div>
</div>
<div class="btndiv">
<a href="./index.html" class="btn">بازگشت به صفحه اصلی</a>

</div>
</body>

</html>

0 comments on commit fa0ad88

Please sign in to comment.