forked from hctilg/crawat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
295 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
font-family: "Poppins", sans-serif; | ||
} | ||
body { | ||
background-color: #eff3ff; | ||
} | ||
.wrapper { | ||
position: absolute; | ||
-webkit-transform: translateX(-50%); | ||
-ms-transform: translateX(-50%); | ||
transform: translateX(-50%); | ||
top: 20px; | ||
left: 50%; | ||
} | ||
.text-center { | ||
text-align: center; | ||
font-weight: 600; | ||
} | ||
.container { | ||
width: 330px; | ||
position: relative; | ||
} | ||
#card { | ||
width: 100%; | ||
padding: 20px; | ||
border-radius: 10px; | ||
-webkit-box-shadow: 0 20px 30px rgba(0, 0, 0, 0.15); | ||
box-shadow: 0 20px 30px rgba(0, 0, 0, 0.15); | ||
position: relative; | ||
} | ||
#card img { | ||
display: block; | ||
width: 250px; | ||
max-height: 250px; | ||
position: relative; | ||
margin: 20px auto 10px auto; | ||
font-size: 18px; | ||
aspect-ratio: 150/180; | ||
} | ||
.hp { | ||
width: 80px; | ||
text-align: center; | ||
margin-left: auto; | ||
padding: 5px 0; | ||
border-radius: 40px; | ||
background-color: #ffffff; | ||
font-weight: 400; | ||
} | ||
|
||
.types { | ||
display: -webkit-box; | ||
display: -ms-flexbox; | ||
display: flex; | ||
-ms-flex-pack: distribute; | ||
justify-content: space-around; | ||
margin: 15px 0 25px 0; | ||
} | ||
.hp span, | ||
.types span { | ||
font-size: 10px; | ||
letter-spacing: 0.4px; | ||
font-weight: 600; | ||
} | ||
.types span { | ||
padding: 5px 20px; | ||
border-radius: 20px; | ||
color: #ffffff; | ||
} | ||
span:hover { | ||
opacity: 0.4; | ||
} | ||
.stats { | ||
display: -webkit-box; | ||
display: -ms-flexbox; | ||
display: flex; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
-webkit-box-pack: justify; | ||
-ms-flex-pack: justify; | ||
justify-content: space-between; | ||
text-align: center; | ||
font-size: 15px; | ||
} | ||
.stats p { | ||
color: #404060; | ||
} | ||
#next { | ||
display: block; | ||
padding: 12px 40px; | ||
font-size: 16px; | ||
position: relative; | ||
margin: 30px auto; | ||
background-color: #101010; | ||
color: white; | ||
border: none; | ||
border-radius: 50px; | ||
} | ||
#next:hover { | ||
background-color: #726f6f; | ||
} | ||
a { | ||
position: relative; | ||
display: block; | ||
background-color: #0190ff; | ||
text-align: center; | ||
text-decoration: none; | ||
padding: 15px 0; | ||
border-radius: 5px; | ||
color: #ffffff; | ||
} | ||
a:hover { | ||
background-color: #0059b3; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const card = document.getElementById("card"); | ||
const type = document.getElementById("type"); | ||
const providerName = document.getElementById("provider-name"); | ||
const update = document.getElementById("update"); | ||
const connect = document.getElementById("connect"); | ||
const next = document.getElementById("next"); | ||
|
||
// change card style | ||
let styleCard = (color) => { | ||
card.style.background = `radial-gradient(circle at 50% 0%, ${color} 36%, white 36%)`; | ||
card.querySelectorAll(".types span").forEach((item) => { | ||
item.style.backgroundColor = color; | ||
}); | ||
}; | ||
styleCard("#adcbe0"); | ||
|
||
|
||
fetch('feed.php?type=mtproto') | ||
.then(response => response.json()) | ||
.then(init) | ||
.catch(error =>providerName.innerHTML = "Server Error"); | ||
|
||
let pointer = 0; | ||
function init(data){ | ||
if(data.ok === false) | ||
{ | ||
providerName.innerHTML = "Server Error" | ||
return; | ||
} | ||
type.innerHTML = data.result[pointer].type; | ||
providerName.innerHTML = data.result[pointer].provider + " #"+data.result[pointer].priority; | ||
update.innerHTML = Math.ceil((data.response_time - data.result[pointer].time)/60) + " minute ago"; | ||
connect.href = decodeURIComponent(data.result[pointer].data); | ||
|
||
next.addEventListener("click", () => { | ||
pointer++; | ||
if(pointer === data.result.length) | ||
pointer = 0; | ||
type.innerHTML = data.result[pointer].type; | ||
providerName.innerHTML = data.result[pointer].provider + " #"+data.result[pointer].priority; | ||
update.innerHTML = Math.ceil((data.response_time - data.result[pointer].time)/60) + " minute ago"; | ||
connect.href = data.result[pointer].data; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
return [ | ||
'mtproto'=>[ | ||
'cache_time' => 600, | ||
'channels' => [ | ||
'ProxyMTProto','TelMTProto' | ||
] | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
$config = include 'config.php'; | ||
$feed_file = 'feed.json.php'; | ||
|
||
|
||
|
||
function set_data($name,$data){ | ||
file_put_contents($name,'<?php exit(); ?>'.json_encode($data)); | ||
} | ||
|
||
function get_data($name){ | ||
if(is_file($name)) | ||
return json_decode(str_replace('<?php exit(); ?>','',file_get_contents($name)),true); | ||
else{ | ||
file_put_contents($name,'<?php exit(); ?>{}'); | ||
return []; | ||
} | ||
|
||
} | ||
|
||
function mtproto_update(){ | ||
global $config; | ||
$list = []; | ||
$config['mtproto']['channels'] = str_replace('@','',$config['mtproto']['channels']); // remove @ if exist in channel username | ||
foreach($config['mtproto']['channels'] as $channelUsername){ | ||
preg_match_all('#(?<=href=")https:\/\/t(?:elegram)?\.me\/proxy\?server[^"]+#i',file_get_contents('https://t.me/s/'.$channelUsername),$data); | ||
$proxies = array_unique(array_reverse($data[0])); | ||
foreach($proxies as $key => $val){ | ||
$parts = parse_url($val); | ||
parse_str($parts['query'], $query); | ||
$list[] = [ | ||
'type'=>'MTProto', | ||
'time'=>time(), | ||
'provider'=>$channelUsername, | ||
'priority'=>$key, | ||
'data'=> str_replace('&','&',str_replace('https://t.me/','tg://',$val)) | ||
]; | ||
} | ||
} | ||
usort($list,function($a,$b){ | ||
return $a['priority']-$b['priority']; | ||
}); | ||
return $list; | ||
} | ||
|
||
$response = []; | ||
header('Access-Control-Allow-Origin: *'); | ||
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); | ||
header('Access-Control-Allow-Headers: Content-Type'); | ||
header('Content-Type: application/json'); | ||
|
||
if(!isset($_GET['type'])){ | ||
$response['ok'] = false; | ||
$response['message'] = "Invalid parameters."; | ||
|
||
}elseif($_GET['type'] == 'mtproto'){ | ||
|
||
$data = get_data($feed_file); | ||
|
||
if(count($data) == 0){ | ||
$data = mtproto_update(); | ||
set_data($feed_file,$data); | ||
} | ||
|
||
if((time()-end($data)['time']) > $config['mtproto']['cache_time']){ | ||
$data = mtproto_update(); | ||
set_data($feed_file,$data); | ||
$cache = false; | ||
}else{ | ||
$data = get_data($feed_file); | ||
$cache = true; | ||
} | ||
|
||
mtproto_update(); | ||
$response['ok'] = true; | ||
$response['cache'] = $cache; | ||
$response['response_time'] = time(); | ||
$response['result'] = $data; | ||
} | ||
echo json_encode($response); | ||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Crawat</title> | ||
<link rel="icon" href="assets/img/tie.ico" type="image/x-icon" /> | ||
<link rel="stylesheet" href="assets/css/style.css"> | ||
<script src="assets/js/script.js" defer></script> | ||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<div class="container"> | ||
<div id="card"> | ||
<p class="hp"> | ||
<span id="info" onclick="window.open('https://github.com/sepsoh/crawat')">Crawat v1.0</span> | ||
</p> | ||
<img src="assets/img/telegram.png" alt="none"> | ||
<h2 id="provider-name" class="text-center"> | ||
... | ||
</h2> | ||
<div class="types"></div> | ||
<div class="stats"> | ||
<div> | ||
<h3>Update</h3> | ||
<p id="update">...</p> | ||
</div> | ||
<div> | ||
<h3>Type</h3> | ||
<p id="type">...</p> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<br> | ||
</div> | ||
<a id="connect">Connect</a> | ||
<button id="next">Next</button> | ||
</div> | ||
</body> | ||
</html> |