Clouldon Blog
    • 版块
    • 最新
    • 用户
    • 友链
    • 注册
    • 登录

    MoeCounterRe

    已定时 已固定 已锁定 已移动 IE地球
    6 帖子 1 发布者 648 浏览
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 四折光曲四 离线
      四折光曲
      最后由 编辑

      Link Preview Image
      Build software better, together

      GitHub is where people build software. More than 225 million people use GitHub to discover, fork, and contribute to over 800 million projects.

      favicon

      GitHub (github.com)

      四折光曲四 1 条回复 最后回复 回复 引用
      • 四折光曲四 离线
        四折光曲 @四折光曲
        最后由 编辑

        📦 开箱即用的 MoeCounterRe

        MoeCounterRe 是一款基于 PHP 开发的轻量级、高度可定制的萌系访问计数器。它支持多种显示模式和输出格式,能够轻松集成到个人博客、GitHub 项目或其他网页中。

        Moe-counter

        这是一个基于 PHP 和 SQLite3 开发的轻量级个性化访问计数器(类似 Moe-Counter)。它支持多种输出模式,并能通过 SVG 嵌入图片,非常适合用于 GitHub 个人主页或博客。

        🚀 项目介绍

        • 轻量高效:使用 SQLite 数据库,无需配置繁琐的 MySQL,开箱即用。

        • 多主题支持:支持通过图片前缀切换不同的数字主题。

        • 三种输出模式:

        • xml (SVG):最推荐模式,将图片转为 Base64 嵌入 SVG,可直接在 GitHub <img> 标签中使用。

        • string:直接输出纯文本数字,方便 API 调用。

        • html:输出标准的 HTML <img> 标签组。

        • 性能优化:内置单例模式连接数据库,并支持 ETag 浏览器缓存控制。

        🛠️ 使用方法

        1. 部署

        将代码上传至服务器,确保 PHP 环境已开启 pdo_sqlite 和 sqlite3 扩展。
        确保目录具有写权限,以便生成 Counter.db 数据库文件。

        2. 参数说明

        通过 URL Query 参数进行配置:

        • name: 计数器名称(如:index, github_profile),默认为 default。
        • theme: 主题前缀(需对应 img/ 目录下的文件名),默认为 rule34_。
        • min_len: 最小显示位数,不足则补 0。
        • out_mode: 输出格式,可选 xml, string, html。

        3. 调用示例

        在 GitHub Readme 中使用 (推荐)

        ![Moe-counter](https://love4z.cn/moec/?name=github&theme=rule34_&min_len=7)
        
        

        直接作为接口获取数字

        curl "https://love4z.cn/moec/?name=github&out_mode=string"
        
        

        📂 文件结构

        • index.php: 程序入口,负责业务逻辑与配置。
        • lib.php: 核心库,包含数据库操作、安全过滤及渲染逻辑。
        • img/: 图片目录,存放不同主题的数字图片(命名规则:前缀{0-9}.gif)。
        • Counter.db: 自动生成的 SQLite 数据库文件。

        ⚠️ 安全说明

        项目已内置 safeInput 函数,通过正则表达式 /[^a-zA-Z0-9_\-]/ 强制过滤所有输入参数,有效防止 路径穿越 和 SQL 注入 风险。

        📄 开源协议

        本项目遵循 MIT 协议。欢迎自由使用与二次开发。

        !项目地址:https://github.com/Raven777777/MoeCounterRe!<

        四折光曲四 1 条回复 最后回复 回复 引用
        • 四折光曲四 离线
          四折光曲 @四折光曲
          最后由 四折光曲 编辑

          Flarum 使用

          在自定义页脚添加:

          <script>(function(n,c){document.head.insertAdjacentHTML('beforeend',`<style>#app{display:flex!important;flex-direction:column!important;min-height:100vh!important;padding-bottom:0!important}.m-f{margin-top:auto;display:flex;flex-direction:column;align-items:center;padding:20px 0;gap:8px}.m-f a{display:flex;justify-content:center;width:100%;transition:.3s;filter:drop-shadow(0 8px 12px rgba(0,0,0,.1));cursor:pointer}.m-f a:hover{transform:scale(1.05)}.m-f img{width:min(400px,85%)}</style>`);const r=async()=>{const a=document.getElementById('app');if(a&&!a.querySelector('.m-f')){a.insertAdjacentHTML('beforeend',`<div class="m-f"><a href="https://love4z.cn/moec/" target="_blank"></a><span style="font-size:12px;color:#999;letter-spacing:1px"><span style="color:${c};font-weight:bold">MoeCounter</span></span></div>`);const e=a.lastChild.querySelector('a');try{const t=await fetch(`https://love4z.cn/moec/?name=${n}`);if(t.ok)e.innerHTML=await t.text()}catch(t){console.error('L 404',t)}}};new MutationObserver(r).observe(document.body,{childList:1,subtree:1});r()})('2233','#ffb6c1');</script>
          

          最末端的 2233 是自定义计数器名称,请自行替换
          也可以替换成自己部署的
          https://love4z.cn/moec

          顺便解决了NT Firefox Nightly Gif动画静止的问题

          四折光曲四 1 条回复 最后回复 回复 引用
          • 四折光曲四 离线
            四折光曲 @四折光曲
            最后由 四折光曲 编辑

            NODBB 使用

            在自定义脚本添加:

            !function(){let e=document,t=e.documentElement,s=e.body;t.style.height='100%',Object.assign(s.style,{minHeight:'100%',display:'flex',flexDirection:'column',margin:'0'});let o=e.createElement('div');o.style.cssText='display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px 0;width:100%;gap:10px;margin-top:auto;',o.innerHTML='<a href="https://love4z.cn/moec/" target="_blank" style="display:block;transition:transform .3s;line-height:0" onmouseover="this.style.transform=\'scale(1.1)\'" onmouseout="this.style.transform=\'scale(1)\'"><img src="https://love4z.cn/moec/?name=clouldon&out_mode=xml" style="display:block;max-width:400px;height:auto;filter:drop-shadow(0 8px 12px rgba(0,0,0,.1))"></a><span style="font-size:12px;color:#ffb6c1;font-weight:700;letter-spacing:1px">MoeCounter</span>';let n=()=>{(e.querySelector('footer')||s).appendChild(o)};'loading'===e.readyState?e.addEventListener('DOMContentLoaded',n):n()}();
            
            四折光曲四 1 条回复 最后回复 回复 引用
            • 四折光曲四 离线
              四折光曲 @四折光曲
              最后由 四折光曲 编辑

              和AI斗智斗勇,其乐无穷也,额 火狐你崛起吧

              1 条回复 最后回复 回复 引用
              • 四折光曲四 离线
                四折光曲
                最后由 编辑

                对元素njs项目进行了rust重构,不再需要nodejs或php,占用更低性能更好

                1 条回复 最后回复 回复 引用

                你好!看起来您对这段对话很感兴趣,但您还没有一个账号。

                厌倦了每次访问都刷到同样的帖子?您注册账号后,您每次返回时都能精准定位到您上次浏览的位置,并可选择接收新回复通知(通过邮件或推送通知)。您还能收藏书签、为帖子顶,向社区成员表达您的欣赏。

                有了你的建议,这篇帖子会更精彩哦 💗

                注册 登录
                • 第一个帖子
                  最后一个帖子