PagerMaid_Browser/index.php
2021-08-02 17:58:47 +08:00

228 lines
17 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$per_page = 10;
$show_ua = @preg_replace('/[^10]/', '', $_GET['ua']) ?: '0';
$filter = @preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['filter']);
if(isset($_GET['p'])){
$page = @preg_replace('/[^0-9]/', '', $_GET['p']);
$search = @preg_replace('/[^-a-zA-Z0-9 ]/', '', $_COOKIE['search']);
}else{
$page = 1;
if(isset($_POST['search'])){
$search = @preg_replace('/[^-a-zA-Z0-9 ]/', '', $_POST['search']);
setcookie('search', $search, time() + (86400 * 30), "/");
}else{
$search = NULL;
setcookie('search', '', time() -3600 , "/");
}
}
//Testing
$json = json_decode(implode(" ", file('list.json')), TRUE);
$plugins = array();
foreach($json as $source => $sourceData){
foreach($sourceData['rx_plugins'] as $pluginId => $plugin){
$plugin['id'] = $pluginId;
$plugin['source'] = explode('@', $source, 2)[0];
$plugin['source_name'] = $sourceData['name'];
$plugin['rx_category'] = $sourceData['rx_category'];
if($plugin['min_bot_version'] == '0.0.0'){ $plugin['min_bot_version'] = ''; }
if($plugin['max_bot_version'] == '0.0.0'){ $plugin['max_bot_version'] = ''; }
if($plugin['min_bot_version'] === $plugin['max_bot_version']){
if(!empty($plugin['max_bot_version'])){
array_unshift($plugin['requirements'], 'Bot==' . $plugin['max_bot_version']);
} else
if(!empty($plugin['max_bot_version'])){
array_unshift($plugin['requirements'], 'Bot==' . $plugin['max_bot_version']);
}
} else {
if(!empty($plugin['max_bot_version'])){
array_unshift($plugin['requirements'], 'Bot<=' . $plugin['max_bot_version']);
}
if(!empty($plugin['min_bot_version'])){
array_unshift($plugin['requirements'], 'Bot>=' . $plugin['min_bot_version']);
}
}
if(!empty($plugin['min_python_version'])){
array_unshift($plugin['requirements'], 'Python>=' . implode('.', $plugin['min_python_version']));
}
if($plugin['hidden'] || $plugin['disabled']){ continue; }
if($plugin['rx_category'] == '未认证' && $show_ua !== "1"){ continue; }
if(count($plugin['author']) == 0){ continue; } # ghost entries
foreach($plugin['tags'] as $index => $this_tag){$plugin['tags'][$index] = strtolower($this_tag);}
if($filter && !in_array(strtolower($filter), $plugin['tags'])){ continue; }
if($search){
$matched = FALSE;
if(stripos(strtolower($plugin['id']), strtolower($search)) !== false){ $matched = TRUE; } else
if(stripos(strtolower($plugin['description']), strtolower($search)) !== false){ $matched = TRUE; } else
if(in_array(strtolower($search), $plugin['tags'])){ $matched = TRUE; } else {
foreach($plugin['author'] as $author) {
if(stripos(strtolower($author), strtolower($search)) !== false){ $matched = TRUE; break; }
}
foreach($plugin['requirements'] as $req) {
if(stripos(strtolower($req), strtolower($search)) !== false){ $matched = TRUE; break; }
}
}
if(!$matched){ continue; }
}
array_push($plugins, $plugin);
}
}
function byName($a,$b){ return ($a['id'] <= $b['id']) ? -1 : 1;}
usort($plugins, "byName");
$plugin_chunks = array_chunk($plugins, $per_page);
?>
<html>
<head>
<title>PagerMaid - Modify - 插件列表</title>
<link href="https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@1,300&family=Roboto:wght@500&family=Space+Mono&display=swap" rel="stylesheet">
<script src="assets/jquery-3.5.1.slim.min.js"></script>
<link rel="stylesheet" type="text/css" href="assets/style.mini.css?<?php print(microtime(TRUE)); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content='🔅 Xtao-Labs - 组织下开源程序 PagerMaid-Modify 的插件索引平台 正在逐渐完善中,欢迎加入我们' name='description'>
<meta content="PagerMaid - Modify - 插件列表" property="og:site_name" />
<meta content="https://index.xtaolabs.com" property="og:url" />
<meta content="website" property="og:type" />
<meta content="PagerMaid - Modify - 插件列表" property="og:title" />
<meta content="🔅 Xtao-Labs - 组织下开源程序 PagerMaid-Modify 的插件索引平台 正在逐渐完善中,欢迎加入我们" property="og:description" />
<meta content="https://i.dawnlab.me/935e6963d55e70640770f00b60f9704c.png" property="og:image" />
<meta content="1200" property="og:image:width" />
<meta content="630" property="og:image:height" />
<meta content="summary_large_image" property="twitter:card" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BKXDZR95KP"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BKXDZR95KP');
<?php if($search){print('gtag("event", "page_view", {page_path: "/?search=' . $search . '&ua='. $show_ua . '&p=' . $page . '&filter=' . $filter . '"});');} ?>
</script>
<!-- End Global site tag (gtag.js) - Google Analytics -->
</head>
<body model="">
<div class="nav top">
<a id="logo" href="?">PagerMaid-Modify<t>PagerMaid Telegram utility daemon - Plugin list</t></a>
<a class="nav-link" href="https://xtaolabs.com">安装</a>
<a class="nav-link" href="https://wiki.xtaolabs.com">Wiki</a>
<a class="nav-link" href="https://t.me/joinchat/Ver2ddjF4rwcPF9B">TG 群组</a>
<a class="nav-link" href="https://github.com/Xtao-Labs/PagerMaid-Modify">Github</a>
</div>
<div class="search">
<form id="search" method="post" action="?filter=<?php print($filter);?>&ua=<?php print($show_ua);?>&cb=<?php print(intval(microtime(TRUE))); ?>">
<svg class="icon" viewBox="0 0 20 20">
<path d="M12.323,2.398c-0.741-0.312-1.523-0.472-2.319-0.472c-2.394,0-4.544,1.423-5.476,3.625C3.907,7.013,3.896,8.629,4.49,10.102c0.528,1.304,1.494,2.333,2.72,2.99L5.467,17.33c-0.113,0.273,0.018,0.59,0.292,0.703c0.068,0.027,0.137,0.041,0.206,0.041c0.211,0,0.412-0.127,0.498-0.334l1.74-4.23c0.583,0.186,1.18,0.309,1.795,0.309c2.394,0,4.544-1.424,5.478-3.629C16.755,7.173,15.342,3.68,12.323,2.398z M14.488,9.77c-0.769,1.807-2.529,2.975-4.49,2.975c-0.651,0-1.291-0.131-1.897-0.387c-0.002-0.004-0.002-0.004-0.002-0.004c-0.003,0-0.003,0-0.003,0s0,0,0,0c-1.195-0.508-2.121-1.452-2.607-2.656c-0.489-1.205-0.477-2.53,0.03-3.727c0.764-1.805,2.525-2.969,4.487-2.969c0.651,0,1.292,0.129,1.898,0.386C14.374,4.438,15.533,7.3,14.488,9.77z"></path>
</svg>
<input type="text" name="search" placeholder="搜索插件仓库中 <?php if($filter){print('分类为 ' . $filter . ' 的 ');}?><?php print(count($plugins));?> 个插件" value="<?php print($search);?>" />
<button class="submit">
<svg class="icon" viewBox="0 0 20 20">
<path d="M14.989,9.491L6.071,0.537C5.78,0.246,5.308,0.244,5.017,0.535c-0.294,0.29-0.294,0.763-0.003,1.054l8.394,8.428L5.014,18.41c-0.291,0.291-0.291,0.763,0,1.054c0.146,0.146,0.335,0.218,0.527,0.218c0.19,0,0.382-0.073,0.527-0.218l8.918-8.919C15.277,10.254,15.277,9.784,14.989,9.491z"></path>
</svg>
</button>
</form>
</div>
<?php if ($show_ua == "1"){ ?>
<div class="ua-warning">未经过认证的插件可能存在安全或者稳定性风险<br>造成的任何问题请自负</div>
<?php } ?>
<div class="filters">
<box <?php if($show_ua === '1'){?>href="?filter=<?php print($filter);?>&ua=0"<?php }else{?>show-model="uadisclaim"<?php } ?>><svg class="icon" viewBox="0 0 20 20">
<?php if($show_ua === '1'){ ?>
<path fill-rule="evenodd" d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm10.03 4.97a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"></path>
<?php }else{ ?>
<path fill-rule="evenodd" d="M14 1H2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/>
<?php } ?>
</svg>包含未认证插件</box>
</div>
<div class="list">
<div class="model" model="uadisclaim">
<h><svg class="icon" viewBox="0 0 20 23">
<path d="M18.344,16.174l-7.98-12.856c-0.172-0.288-0.586-0.288-0.758,0L1.627,16.217c0.339-0.543-0.603,0.668,0.384,0.682h15.991C18.893,16.891,18.167,15.961,18.344,16.174 M2.789,16.008l7.196-11.6l7.224,11.6H2.789z M10.455,7.552v3.561c0,0.244-0.199,0.445-0.443,0.445s-0.443-0.201-0.443-0.445V7.552c0-0.245,0.199-0.445,0.443-0.445S10.455,7.307,10.455,7.552M10.012,12.439c-0.733,0-1.33,0.6-1.33,1.336s0.597,1.336,1.33,1.336c0.734,0,1.33-0.6,1.33-1.336S10.746,12.439,10.012,12.439M10.012,14.221c-0.244,0-0.443-0.199-0.443-0.445c0-0.244,0.199-0.445,0.443-0.445s0.443,0.201,0.443,0.445C10.455,14.021,10.256,14.221,10.012,14.221"></path></svg>警告:您必须自行承担使用风险!</h>
<t>未经认证的插件由第三方作者提供尚未进行安全性检查或稳定性测试。Xtao-labs 不对此类未认证插件造成的任何问题负责。</t>
<f><button hide-model="true">取消</button><button class="right red" href="?filter=<?php print($filter);?>&ua=1">我已了解并且接受使用风险</button></f>
</div>
<?php if(!isset($plugin_chunks[$page - 1])){ ?>
<div>
<t><center>出错了呜呜呜 ~ 没有找到插件呢 ~</center></t>
</div>
<?php }else{ foreach($plugin_chunks[$page - 1] as $plugin){ ?>
<div>
<h><?php print($plugin['id']);?><tag class="approval<?php if($plugin['rx_category'] == '已认证'){?> active<?php } ?>"><?php print(ucwords($plugin['rx_category']));?></tag> <tag class="approval">v<?php print($plugin['version']);?></tag><?php foreach($plugin['author'] as $tag){?><tag>@<?php print($tag); ?></tag><?php }?></h>
<t><i><?php print(nl2br(htmlentities($plugin['description'])));?></i></t>
<?php if(!empty($plugin['end_user_data_statement'])) { ?>
<t><svg class="icon" viewBox="0 0 20 20">
<path d="M10,6.978c-1.666,0-3.022,1.356-3.022,3.022S8.334,13.022,10,13.022s3.022-1.356,3.022-3.022S11.666,6.978,10,6.978M10,12.267c-1.25,0-2.267-1.017-2.267-2.267c0-1.25,1.016-2.267,2.267-2.267c1.251,0,2.267,1.016,2.267,2.267C12.267,11.25,11.251,12.267,10,12.267 M18.391,9.733l-1.624-1.639C14.966,6.279,12.563,5.278,10,5.278S5.034,6.279,3.234,8.094L1.609,9.733c-0.146,0.147-0.146,0.386,0,0.533l1.625,1.639c1.8,1.815,4.203,2.816,6.766,2.816s4.966-1.001,6.767-2.816l1.624-1.639C18.536,10.119,18.536,9.881,18.391,9.733 M16.229,11.373c-1.656,1.672-3.868,2.594-6.229,2.594s-4.573-0.922-6.23-2.594L2.41,10l1.36-1.374C5.427,6.955,7.639,6.033,10,6.033s4.573,0.922,6.229,2.593L17.59,10L16.229,11.373z"></path> </svg><?php print($plugin['end_user_data_statement']);?></t>
<?php } ?>
<?php if(count($plugin['permissions']) > 0) { ?>
<t><svg class="icon" viewBox="0 0 20 20">
<path d="M12.546,4.6h-5.2C4.398,4.6,2,7.022,2,10c0,2.978,2.398,5.4,5.346,5.4h5.2C15.552,15.4,18,12.978,18,10C18,7.022,15.552,4.6,12.546,4.6 M12.546,14.6h-5.2C4.838,14.6,2.8,12.536,2.8,10s2.038-4.6,4.546-4.6h5.2c2.522,0,4.654,2.106,4.654,4.6S15.068,14.6,12.546,14.6 M12.562,6.2C10.488,6.2,8.8,7.904,8.8,10c0,2.096,1.688,3.8,3.763,3.8c2.115,0,3.838-1.706,3.838-3.8C16.4,7.904,14.678,6.2,12.562,6.2 M12.562,13C10.93,13,9.6,11.654,9.6,10c0-1.654,1.33-3,2.962-3C14.21,7,15.6,8.374,15.6,10S14.208,13,12.562,13"></path></svg><b>需要权限</b><l><?php print(implode(' ', $plugin['permissions']));?></l></t>
<?php } ?>
<?php if(count($plugin['requirements']) > 0) { ?>
<t><svg class="icon" viewBox="0 0 20 23">
<path d="M18.344,16.174l-7.98-12.856c-0.172-0.288-0.586-0.288-0.758,0L1.627,16.217c0.339-0.543-0.603,0.668,0.384,0.682h15.991C18.893,16.891,18.167,15.961,18.344,16.174 M2.789,16.008l7.196-11.6l7.224,11.6H2.789z M10.455,7.552v3.561c0,0.244-0.199,0.445-0.443,0.445s-0.443-0.201-0.443-0.445V7.552c0-0.245,0.199-0.445,0.443-0.445S10.455,7.307,10.455,7.552M10.012,12.439c-0.733,0-1.33,0.6-1.33,1.336s0.597,1.336,1.33,1.336c0.734,0,1.33-0.6,1.33-1.336S10.746,12.439,10.012,12.439M10.012,14.221c-0.244,0-0.443-0.199-0.443-0.445c0-0.244,0.199-0.445,0.443-0.445s0.443,0.201,0.443,0.445C10.455,14.021,10.256,14.221,10.012,14.221"></path></svg><b>Bot 版本和额外依赖包需求</b><l><?php print(implode('</l><l>', $plugin['requirements']));?></l></t>
<?php } ?>
<t><svg class="icon" viewBox="0 0 16 19">
<path fill-rule="evenodd" d="M0 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6zm13 .25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zM2.25 8a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5A.25.25 0 0 0 3 8.75v-.5A.25.25 0 0 0 2.75 8h-.5zM4 8.25A.25.25 0 0 1 4.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 4 8.75v-.5zM6.25 8a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5A.25.25 0 0 0 7 8.75v-.5A.25.25 0 0 0 6.75 8h-.5zM8 8.25A.25.25 0 0 1 8.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 8 8.75v-.5zM13.25 8a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5a.25.25 0 0 0 .25-.25v-.5a.25.25 0 0 0-.25-.25h-.5zm0 2a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5a.25.25 0 0 0 .25-.25v-.5a.25.25 0 0 0-.25-.25h-.5zm-3-2a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25v-.5a.25.25 0 0 0-.25-.25h-1.5zm.75 2.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zM11.25 6a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5a.25.25 0 0 0 .25-.25v-.5a.25.25 0 0 0-.25-.25h-.5zM9 6.25A.25.25 0 0 1 9.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 9 6.75v-.5zM7.25 6a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h.5A.25.25 0 0 0 8 6.75v-.5A.25.25 0 0 0 7.75 6h-.5zM5 6.25A.25.25 0 0 1 5.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 5 6.75v-.5zM2.25 6a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h1.5A.25.25 0 0 0 4 6.75v-.5A.25.25 0 0 0 3.75 6h-1.5zM2 10.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zM4.25 10a.25.25 0 0 0-.25.25v.5c0 .138.112.25.25.25h5.5a.25.25 0 0 0 .25-.25v-.5a.25.25 0 0 0-.25-.25h-5.5z"></path>
</svg><b>安装命令</b><l>-apt install <?php print($plugin['id']); ?></l></t>
<f><?php sort($plugin['tags']);foreach($plugin['tags'] as $tag){?><tag href="?filter=<?php print($tag); ?>"><?php print($tag); ?></tag><?php }?><a class="src-link" href="https://github.com/Xtao-Labs/PagerMaid_Plugins/blob/master/<?php print($plugin['id']);?>.py">查看源代码</a></f>
</div>
<?php }} ?>
</div>
<div class="nav bottom">
<a class="left <?php if($page <= 1){?>hidden<?php }?>" href="?p=<?php print($page - 1);?>&filter=<?php print($filter);?>&ua=<?php print($show_ua);?>">
<svg class="icon" viewBox="0 0 20 20">
<path d="M18.271,9.212H3.615l4.184-4.184c0.306-0.306,0.306-0.801,0-1.107c-0.306-0.306-0.801-0.306-1.107,0
L1.21,9.403C1.194,9.417,1.174,9.421,1.158,9.437c-0.181,0.181-0.242,0.425-0.209,0.66c0.005,0.038,0.012,0.071,0.022,0.109
c0.028,0.098,0.075,0.188,0.142,0.271c0.021,0.026,0.021,0.061,0.045,0.085c0.015,0.016,0.034,0.02,0.05,0.033l5.484,5.483
c0.306,0.307,0.801,0.307,1.107,0c0.306-0.305,0.306-0.801,0-1.105l-4.184-4.185h14.656c0.436,0,0.788-0.353,0.788-0.788
S18.707,9.212,18.271,9.212z"></path>
</svg>
上一页
</a>
<?php if(count($plugin_chunks) >= 1){?>
<page>第 <?php print($page);?> 页,共 <?php print(count($plugin_chunks)); ?> 页</page>
<?php } ?>
<a class="right <?php if(count($plugin_chunks) <= $page){?>hidden<?php }?>" href="?p=<?php print($page + 1);?>&filter=<?php print($filter);?>&ua=<?php print($show_ua);?>">
下一页
<svg class="icon" viewBox="0 0 20 20">
<path d="M1.729,9.212h14.656l-4.184-4.184c-0.307-0.306-0.307-0.801,0-1.107c0.305-0.306,0.801-0.306,1.106,0
l5.481,5.482c0.018,0.014,0.037,0.019,0.053,0.034c0.181,0.181,0.242,0.425,0.209,0.66c-0.004,0.038-0.012,0.071-0.021,0.109
c-0.028,0.098-0.075,0.188-0.143,0.271c-0.021,0.026-0.021,0.061-0.045,0.085c-0.015,0.016-0.034,0.02-0.051,0.033l-5.483,5.483
c-0.306,0.307-0.802,0.307-1.106,0c-0.307-0.305-0.307-0.801,0-1.105l4.184-4.185H1.729c-0.436,0-0.788-0.353-0.788-0.788
S1.293,9.212,1.729,9.212z"></path>
</svg>
</a>
</div>
<a href="https://github.com/Xtao-Labs/PagerMaid_Browser"><img style="position: absolute; top: 0; right: 0; border: 0;" src="assets/forkme_right_darkblue_121621.png" class="attachment-full size-full" alt="Fork me on GitHub"></a>
<script>
$(document).ready(function(){
$('[href]').click(function(){
$(this).addClass('loading');
window.location.href = $(this).attr('href');
});
$('.submit').click(function(){ $('#search').submit();});
$('[show-model]').click(function(){
$('body').attr('model', $(this).attr('show-model'));
});
$('[hide-model]').click(function(){
$('body').attr('model', '');
});
});
</script>
<!-- Cloudflare Web Analytics -->
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "1beede96dcdb4946b2907c52fa615151"}'></script>
<!-- End Cloudflare Web Analytics -->
</body>
</html>