一个小网管 发布的文章

  • 先说一下我写注释的逻辑:从入口文件开始按程序的执行过程进行分析、注释、学习。
  • 我的typecho源代码是1.2.0版本,入口文件是index.php
// 源文件/index.php
 1 <?php
 2 /**
 3 * Typecho Blog Platform
 4 *
 5 * @copyright  Copyright (c) 2008 Typecho team (http://www.typecho.org)
 6 * @license    GNU General Public License 2.0
 7 * @version    $Id: index.php 1153 2009-07-02 10:53:22Z magike.net $
 8 */
 9 
10 /** 载入配置支持 */
11 if (!defined('__TYPECHO_ROOT_DIR__') && !@include_once 'config.inc.php') {
12     file_exists('./install.php') ? header('Location: install.php') : print('Missing Config File');
13     exit;
14 }
  • 这里开始注释上面的代码
  • 第1行:PHP标记:<?php 代码段 ?>
  • 第2~8行:多行注释,第9行是空行为了让代码可读性更好,第10行是注释。
  • 第11行:是if控制语句:!是取反,defined('__TYPECHO_ROOT_DIR__')是判断'__TYPECHO_ROOT_DIR__'是否已定义,已定义返回true,未定义返回false。 && 是并且的意思。@是抑制程序报错、屏蔽程序错误信息,include_once 'config.inc.php'是包含并运行文件'config.inc.php'中的代码,如果已经包含过则不再包含并返回true。
  • 第一次运行时肯定是没有定义'__TYPECHO_ROOT_DIR__'并且没有包含'config.inc.php'的,两个表达式都做了取反操作,就变成了 (true && true) 所以会执行第12行到第14行代码。
  • 第12行:是一个三元表达式,file_exists('./install.php')判断文件'./install.php'是否存在,存在返回true不存在返回false。我这里文件'./install.php'是存在的所以会执行header('Location: install.php')跳转到install.php页面。如果文件'./install.php'不存在就会执行print('Missing Config File')在页面上显示Missing Config File
  • 第13行:退出并不再执行后面的代码。

本章到此结束,下一章开始分析install.php页面。

  • 基础知识在各种学习网站和PHP官方手册(本站拷贝了一份官方的HTML手册点此打开)上均有,自行抽时间学阅读一遍即可,不管懂不懂不要花太多时间去研究。
  • 读完之后去练习写程序或者看源代码,不会写或看不懂的代码再搜索或者看基础知识部分。
  • 我没有什么可写的程序,看完基础知识就开始看源代码,并给代码写注释。
  • 别人的代码有看不懂的地方再搜索和查询基础知识部分,都找不到就发帖请教大佬。
  • 我的学习方法就是这样了,毕竟是自学,慢慢研究即可。
  • 下一篇文章开始给代码写注释。
  • 就从本站的源代码开始吧,写完之后看情况再决定下一步怎么做。

项目详情如下

OpenWrt-Docker

GitHub Stars
GitHub Forks
Docker Stars
Docker Pulls

本项目旨在构建适用于树莓派 1~4 、适用于 armv6/armv7/armv8(aarch64)/x86_64(amd64) 平台设备的 OpenWrt 镜像 (每日更新)。

Github: https://github.com/SuLingGG/OpenWrt-Docker

DockerHub: https://hub.docker.com/r/sulinggg/openwrt

支持设备及镜像版本

本项目基于 immortalwrt: openwrt-18.06-k5.4,每日上午 8 点编译 OpenWrt 镜像,镜像构建完成后将同时推送到 DockerHub 和 阿里云镜像仓库 (上海) 。

对于国内用户,为提高镜像拉取体验,可以考虑拉取存放于阿里云镜像仓库的镜像,镜像名称及标签如下表所示:

OpenWrt 标准镜像

OpenWrt 标准镜像为集成常用软件包的 Docker 镜像,镜像自带软件包可满足大多数情景下的使用需求。

支持设备/平台DockerHub阿里云镜像仓库 (上海)
树莓派 1Bsulinggg/openwrt:rpi1registry.cn-shanghai.aliyuncs.com/suling/openwrt:rpi1
树莓派 2Bsulinggg/openwrt:rpi2registry.cn-shanghai.aliyuncs.com/suling/openwrt:rpi2
树莓派 3B / 3B+sulinggg/openwrt:rpi3registry.cn-shanghai.aliyuncs.com/suling/openwrt:rpi3
树莓派 4Bsulinggg/openwrt:rpi4registry.cn-shanghai.aliyuncs.com/suling/openwrt:rpi4
armv7sulinggg/openwrt:armv7registry.cn-shanghai.aliyuncs.com/suling/openwrt:armv7
arm8/aarch64sulinggg/openwrt:armv8registry.cn-shanghai.aliyuncs.com/suling/openwrt:armv8
x86_64/amd64sulinggg/openwrt:x86_64registry.cn-shanghai.aliyuncs.com/suling/openwrt:x86_64

OpenWrt-Mini 镜像

OpenWrt-Mni 镜像为几乎未添加额外软件包的 Docker 镜像,你可以自行通过 opkg 安装你需要的软件包。

支持设备/平台DockerHub阿里云镜像仓库 (上海)
树莓派 1Bsulinggg/openwrt-mini:rpi1registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:rpi1
树莓派 2Bsulinggg/openwrt-mini:rpi2registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:rpi2
树莓派 3B / 3B+sulinggg/openwrt-mini:rpi3registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:rpi3
树莓派 4Bsulinggg/openwrt-mini:rpi4registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:rpi4
armv7sulinggg/openwrt-mini:armv7registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:armv7
arm8/aarch64sulinggg/openwrt-mini:armv8registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:armv8
x86_64/amd64sulinggg/openwrt-mini:x86_64registry.cn-shanghai.aliyuncs.com/suling/openwrt-mini:x86_64

注意事项

  • 其中,树莓派 2B 镜像同时适用于 2B/3B/3B+/4B 。
  • 若拉取镜像时不加任何标签,则将使用 latest 标签拉取镜像,latest 指向的镜像与树莓派 2B 镜像实际上为同一镜像。
  • 镜像中软件包的集成情况基本上与 SuLingGG/OpenWrt-Rpi 项目中相同,但在 SuLingGG/OpenWrt-Rpi 项目的基础上,去掉了一些与无线/内核特性强相关的软件包。
  • 由于 Docker 容器与宿主机共享内核,所以 Docker 容器的内核特性与宿主机当前的内核特性相同。
  • 本项目固件支持 opkg 安装软件包,软件源内有 7000+ 个软件包可供选择。
  • (对于高级用户) 某些软件包可能依赖一些特定的内核特性,所以我不保证 opkg 软件源中的所有软件包都可以正常使用。且因为上文所述原因,在 OpenWrt 中安装 kmod 是无效的,如果有需求,请提前在宿主机中提前载入相应的内核模块,例如:
modprobe ip6_udp_tunnel
modprobe ip6table_nat
modprobe pppoe
modprobe tun
modprobe udp_tunnel
modprobe xt_TPROXY

镜像详细使用方法请参考博客文章:

「在 Docker 中运行 OpenWrt 旁路网关」

https://mlapp.cn/376.html

鸣谢

P3TERX/Actions-OpenWrt (本项目基于此项目):

https://github.com/P3TERX/Actions-OpenWrt

OpenWrt Source Repository:

https://github.com/openwrt/openwrt/

Lean's OpenWrt source:

https://github.com/coolsnowwolf/lede

CTCGFW's Team:

https://github.com/project-openwrt