16 Star 115 Fork 23

Hamm/Svg Badge Tool

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
juejin.php 3.83 KB
Copy Edit Raw Blame History
<?php
require_once('common.php');
if (empty($_GET['user']) || empty($_GET['type'])) {
header('Location: https://gitee.com/hamm/svg_badge_tool');
die;
}
$user = trim($_GET['user'] ?? '475426363282808');
$type = trim($_GET['type'] ?? 'fans');
$key = '掘金';
$value = '';
switch ($type) {
case 'fans':
$url = "https://juejin.cn/user/" . $user;
$html = httpGetFull($url);
$html = str_replace(PHP_EOL, '', $html);
$key = '粉丝';
$value = "查询失败";
if(preg_match('/follower_count:(.*?),/',$html,$match)){
$value = "JueJin-".$match[1];
}
break;
default:
}
?>
<?php
$len_key = 11 * mb_strlen($key);
if (preg_match('/[a-zA-Z]/', $key)) {
$len_key = 7 * strlen($key);
}
$len_value = 11 * mb_strlen($value);
if (preg_match('/[a-zA-Z.+-_#*\/@]/', $value)) {
$len_value = 7 * strlen($value);
}
$radius = $_GET['radius'] ?? 3;
$icon_length = 0;
if (!empty($_GET['title'])) {
$key = htmlspecialchars($_GET['title']);
}
$titleBg = '#007fff';
if (!empty($_GET['bg'])) {
$titleBg = '#' . htmlspecialchars($_GET['bg']);
}
$backColor = '#404550';
$backColor = !empty($_GET['color']) ? "#" . $_GET['color'] : $backColor;
$len_total = $len_key + $len_value + 11 * 2;
?>
<!-- This is build by svg tool , see more here : https://gitee.com/hamm/svg_badge_tool-->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="<?php echo $icon_length / 10 + $len_total; ?>" height="20">
<style>
.opencollective-svg {
cursor: pointer;
}
</style>
<?php if ($urlForSvg) { ?>
<a xlink:href="<?php echo $urlForSvg; ?>" class="opencollective-svg" target="_blank">
<?php } ?>
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
<stop offset="1" stop-opacity=".1" />
</linearGradient>
<clipPath id="a">
<rect width="<?php echo $icon_length / 10 + $len_total; ?>" height="20" rx="<?php echo $radius; ?>"
fill="#fff" />
</clipPath>
<g clip-path="url(#a)">
<path fill="<?php echo $titleBg; ?>" d="M0 0h<?php echo $icon_length / 10 + $len_key + 11; ?>v20H0z" />
<path fill="<?php echo $backColor; ?>"
d="M<?php echo $icon_length / 10 + $len_key + 11; ?> 0h<?php echo $icon_length / 10 + $len_value + 11; ?>v20H<?php echo $icon_length / 10 + $len_key + 11; ?>z" />
<path fill="url(#b)" d="M0 0h<?php echo $icon_length / 10 + $len_total; ?>v20H0z" />
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="110"
x="<?php echo $icon_length; ?>">
<text x="<?php echo $icon_length + $len_key * 5 + 55; ?>" y="150" fill="#010101" fill-opacity=".3"
transform="scale(.1)" textLength="<?php echo $len_key * 10; ?>">
<?php echo $key; ?>
</text>
<text x="<?php echo $icon_length + $len_key * 5 + 55; ?>" y="140" transform="scale(.1)"
textLength="<?php echo $len_key * 10; ?>">
<?php echo $key; ?>
</text>
<text x="<?php echo $icon_length + $len_value * 5 + 110 * 1.5 + $len_key * 10; ?>" y="150" fill="#010101"
fill-opacity=".3" transform="scale(.1)" textLength="<?php echo $len_value * 10; ?>">
<?php echo $value; ?>
</text>
<text x="<?php echo $icon_length + $len_value * 5 + 110 * 1.5 + $len_key * 10; ?>" y="140"
transform="scale(.1)" textLength="<?php echo $len_value * 10; ?>">
<?php echo $value; ?>
</text>
<animateMotion from="0, -50" to="0, 0" dur="0.3s" fill="freeze" />
</g>
<?php if ($urlForSvg) { ?>
</a>
<?php } ?>
</svg>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/hamm/svg_badge_tool.git
git@gitee.com:hamm/svg_badge_tool.git
hamm
svg_badge_tool
Svg Badge Tool
master

Search