(php)25.WordPress访问统计

本文最后更新于(2023-3-5 19:41:03),链接可能失效,内容可能难以复现。请注意甄别。
© Sunplace,2023 根据网上的灵感自己做了一个,省得伸手。 实现功能:
  • 真实的独立访客统计(UV)
  • 刷新页面不增加
  • 用户登录不增加(目前用户为网站管理员)is_user_logged_in()
  • 直接访问不增加(直接在浏览器输入本站地址)$_SERVER['HTTP_REFERER']==''()
数据库建表(建表语句):
# 举例用表,有wordpress数据库前缀"wp_"
# wp_addsettings结构有些复杂,如果只需要一个表来保存UV的值可以更简单
# 我的数据表另有其用
CREATE TABLE `wp_addsettings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`opname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`opval` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

# 插入初始值
INSERT INTO `wp_addsettings` VALUES (1, 'uniquevisitor', '0');
页面代码(PHP),在模板的footer.php中加入:
<?php
//将一个数字从低到高每隔三位加一个逗号
function numformat($num){
$num=strrev($num);
$num=chunk_split($num,3,',');
$num=strrev($num);
$num=ltrim($num,',');
return $num;
}

//使用session来记录访问数
session_start();
if(!is_user_logged_in()&&$_SERVER['HTTP_REFERER']!=''&&!isset($_SESSION['uv'])){
$_SESSION['uv']= 0;
$uv++;
$wpdb->update($wpdb->prefix.'addsettings',array('opval'=>$uv),array('opname'=>'uniquevisitor'));
}
echo '访客数(UV):'.numformat($uv);
?>

Markdown CSS测试

本文最后更新于(2023-3-9 11:33:34),链接可能失效,内容可能难以复现。请注意甄别。
[MD]
内容引用 https://dillinger.io/ 本站调用 github-markdown-css,highlight.js,katex 由 Visual Studio Code 创作

Dillinger

1. The Last Markdown Editor, Ever

Build Status Dillinger is a cloud-enabled, mobile-ready, offline-storage compatible, AngularJS-powered HTML5 Markdown editor.
  • Type some Markdown on the left
  • See HTML in the right
  • ✨Magic ✨

2. Features

  • Import a HTML file and watch it magically convert to Markdown
  • Drag and drop images (requires your Dropbox account be linked)
  • Import and save files from GitHub, Dropbox, Google Drive and One Drive
  • Drag and drop markdown and HTML files into Dillinger
  • Export documents as Markdown, HTML and PDF
Markdown is a lightweight markup language based on the formatting conventions that people naturally use in email. As John Gruber writes on the Markdown site
The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.
This text you see here is *actually- written in Markdown! To get a feel for Markdown’s syntax, type some text into the left window and watch the results in the right.

3. Tech

Dillinger uses a number of open source projects to work properly: And of course Dillinger itself is open source with a public repository on GitHub.

4. Installation

Dillinger requires Node.js v10+ to run. Install the dependencies and devDependencies and start the server.1
cd dillinger
npm i
node app
For production environments…
npm install --production
NODE_ENV=production node app

5. Plugins

Dillinger is currently extended with the following plugins. Instructions on how to use them in your own application are linked below.
Plugin README
Dropbox plugins/dropbox/README.md
GitHub plugins/github/README.md
Google Drive plugins/googledrive/README.md
OneDrive plugins/onedrive/README.md
Medium plugins/medium/README.md
Google Analytics plugins/googleanalytics/README.md

6. Development

Want to contribute? Great! Dillinger uses Gulp + Webpack for fast developing. Make a change in your file and instantaneously see your updates! Open your favorite Terminal and run these commands. First Tab:
node app
Second Tab:
gulp  watch
(optional) Third:
karma test

6.1. Building for source

For production release:
gulp build --prod
Generating pre-built zip archives for distribution:
gulp build dist --prod

7. Docker

Dillinger is very easy to install and deploy in a Docker container. By default, the Docker will expose port 8080, so change this within the Dockerfile if necessary. When ready, simply use the Dockerfile to build the image.
cd dillinger
docker build -t <youruser>/dillinger:${package.json.version} .
This will create the dillinger image and pull in the necessary dependencies. Be sure to swap out ${package.json.version} with the actual version of Dillinger. Once done, run the Docker image and map the port to whatever you wish on your host. In this example, we simply map port 8000 of the host to port 8080 of the Docker (or whatever port was exposed in the Dockerfile):
docker run -d -p 8000:8080 --restart=always --cap-add=SYS_ADMIN --name=dillinger <youruser>/dillinger:${package.json.version}
Note: --capt-add=SYS-ADMIN is required for PDF rendering.
Verify the deployment by navigating to your server address in your preferred browser.
127.0.0.1:8000

8. License

MIT Free Software, Hell Yeah!

公式2

贝塞尔曲线公式:
$$J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}$$

Jα(x)=m=0(1)mm!Γ(m+α+1)(x2)2m+αJ_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}

脚注

  1. 高亮代码需要引入Hightlight.js。↩︎
  2. 公式支持需要引入Katex的CSS样式文件。↩︎

群晖搭建内网穿透访问web

本文最后更新于(2024-2-24 21:46:52),链接可能失效,内容可能难以复现。请注意甄别。
准备工作
  1. cloudflare账户
  2. 接管到cloudflare的域名(设置NS服务器)
  3. 需要绑定付款信息(本文选择免费计划,但依旧需要绑定VISA或者PayPal)
  4. NAS需要开启SSH
  5. NAS需要配置好web服务,可以通过内网访问IP地址测试网站是否可用
1.登录cloudflare官网 2.打开Zero Trust 3.找到Access-Tunnels 4.点击Create a tunnel 5.给你的通道取一个名称Tunnel name(本例设置为web) 6.Choose your environment选择Docker,复制下面$开头的命令 7.然后Next 8.在Subdomain填一个二级域名,例子为web 9. 因为我们需要访问web服务,所以Service选择HTTP 127.0.0.1 nas访问的端口一般为5000,如果要访问nas而不是web,则选择HTTP 127.0.0.1:5000 10.群辉安装docker 11. SSH登录群辉,sudo -i运行第6步的命令 12. 访问web.kkii.org进行测试

记录一次数据库被黑

本文最后更新于(2020-6-1 13:36:11),链接可能失效,内容可能难以复现。请注意甄别。
© Sunplace,2020 5月29日,当我打开本地数据库的时候,除一个数据库没有问题外,其余的数据库内的表已经被清空,只有一张warning表和里面的内容。另外新建了一个please_read_me_vvv的数据库。
mysql> use please_read_me_vvv
Database changed
mysql> show tables;
+------------------------------+
| Tables_in_please_read_me_vvv |
+------------------------------+
| warning |
+------------------------------+
1 row in set (0.01 sec)

mysql> select * from warning;
+----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+--------------------------------+
| id | warning | Bitcoin_Address | Email |
+----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+--------------------------------+
| 1 | To recover your lost Database and avoid leaking it: Send us 0.03 Bitcoin (BTC) to our Bitcoin address 1GkZpdfQdUQasnt12P9pSnx8sohm4NgqNQ and contact us by Email with your Server IP or Domain name and a Proof of Payment. If you are unsure if we have your data, contact us and we will send you a proof. Your Database is downloaded and backed up on our servers. Backups that we have right now: bbs, co_cms, oa, wordpress. If we dont receive your payment in the next 5 Days, we will make your database public or use them otherwise. | 1GkZpdfQdUQasnt12P9pSnx8sohm4NgqNQ | [email protected] |
+----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+--------------------------------+
1 row in set (0.00 sec)
不过,相对“重要”的数据库没有受到影响。 事发之后,如何做?
  1. 打开mysql数据库的user表,只保留host为localhost的记录。
    update user set host='localhost' where user = 'root';
    delete from user where user != 'root';
    flush privileges;
  2. 查看自已是否打开了mysql的binlog。(引用)