├── README.md ├── abduco └── Makefile ├── adbyby ├── Makefile └── files │ └── usr │ └── bin │ ├── adbyby │ ├── adhook.ini │ ├── data │ ├── clean.ini │ └── user.txt │ ├── doc │ └── hidecss.js │ └── user.action ├── libdvbcsa └── Makefile ├── luci-app-adbyby ├── Makefile └── files │ ├── etc │ ├── config │ │ └── adbyby │ ├── init.d │ │ └── adbyby │ └── uci-defaults │ │ └── luci-adbyby │ └── usr │ └── lib │ └── lua │ └── luci │ ├── controller │ └── adbyby.lua │ └── model │ └── cbi │ └── adbyby.lua ├── luci-app-qosv4 ├── Makefile ├── README.md └── files │ ├── etc │ ├── config │ │ └── qosv4 │ ├── init.d │ │ └── qosv4 │ └── uci-defaults │ │ └── luci-qosv4 │ └── usr │ ├── bin │ └── qosv4 │ └── lib │ └── lua │ └── luci │ ├── controller │ └── qosv4.lua │ ├── i18n │ └── qosv4.zh-cn.lmo │ └── model │ └── cbi │ └── qosv4.lua ├── luci-app-wifidog ├── Makefile ├── README.md └── files │ └── root │ ├── etc │ ├── config │ │ └── wifidog │ ├── init.d │ │ └── wifidog │ ├── lighttpd │ │ └── lighttpd.conf │ ├── php.ini │ └── uci-defaults │ │ └── luci-wifidog │ ├── usr │ └── lib │ │ └── lua │ │ └── luci │ │ ├── controller │ │ └── wifidog.lua │ │ └── model │ │ └── cbi │ │ └── wifidog.lua │ └── www │ └── wifidog │ ├── Slim │ ├── Environment.php │ ├── Exception │ │ ├── Pass.php │ │ └── Stop.php │ ├── Helper │ │ └── Set.php │ ├── Http │ │ ├── Cookies.php │ │ ├── Headers.php │ │ ├── Request.php │ │ ├── Response.php │ │ └── Util.php │ ├── Log.php │ ├── LogWriter.php │ ├── Middleware.php │ ├── Middleware │ │ ├── ContentTypes.php │ │ ├── Flash.php │ │ ├── MethodOverride.php │ │ ├── PrettyExceptions.php │ │ └── SessionCookie.php │ ├── Route.php │ ├── Router.php │ ├── Slim.php │ └── View.php │ ├── assets │ ├── loader.gif │ ├── portal.css │ ├── portal.min.js │ ├── ratchicons.eot │ ├── ratchicons.svg │ ├── ratchicons.ttf │ └── ratchicons.woff │ ├── index.php │ ├── jobs │ ├── simple_html_dom.php │ └── sync.php │ └── templates │ ├── 701.html │ ├── show.php │ └── touch.php ├── radvd ├── Makefile ├── files │ ├── radvd.config │ └── radvd.init └── patches │ └── 100-silent-netlink-config-reload.patch ├── samba-hotplug ├── Makefile └── files │ └── hotplug.sh ├── ufsd-chkntfs-mipseb ├── Makefile └── files │ └── chkntfs └── ufsd-mkntfs-mipseb ├── Makefile └── files └── mkntfs /README.md: -------------------------------------------------------------------------------- 1 | # openwrt-maz1 2 | 3 | Packages for openwrt 4 | 5 | Note: Packages are being moved to https://github.com/openwrt-stuff/openwrt-extra 6 | -------------------------------------------------------------------------------- /abduco/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2015 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=abduco 11 | PKG_VERSION:=0.4 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_URL:=http://www.brain-dump.org/projects/abduco/ 16 | PKG_MD5SUM:=cc1e01b5333e36e01e058476ed3efa96 17 | PKG_MAINTAINER:=maz-1 18 | PKG_LICENSE:=ISC 19 | 20 | PKG_INSTALL:=1 21 | 22 | include $(INCLUDE_DIR)/package.mk 23 | 24 | define Package/abduco/Default 25 | SECTION:=utils 26 | CATEGORY:=Utilities 27 | TITLE:=A session management and attach/detach functionality. 28 | URL:=http://www.brain-dump.org/projects/abduco/ 29 | MAINTAINER:=maz-1 30 | DEPENDS:=+dvtm 31 | endef 32 | 33 | define Package/abduco 34 | $(call Package/abduco/Default) 35 | endef 36 | 37 | define Package/abduco/description 38 | A session management and attach/detach functionality.(to use together with dvtm(1)). 39 | endef 40 | 41 | define Package/abduco/install 42 | $(INSTALL_DIR) $(1)/usr/bin 43 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/bin/abduco 44 | endef 45 | 46 | $(eval $(call BuildPackage,abduco)) 47 | -------------------------------------------------------------------------------- /adbyby/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=adbyby 11 | PKG_VERSION:=2.1.0 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/adbyby 17 | SECTION:=utils 18 | CATEGORY:=Utilities 19 | TITLE:=adbyby. 20 | DEPENDS:=+libc 21 | PKGARCH:=all 22 | MAINTAINER:=maz1 23 | endef 24 | 25 | define Package/adbyby/description 26 | adbyby. 27 | endef 28 | 29 | define Build/Compile 30 | endef 31 | 32 | 33 | define Package/adbyby/install 34 | $(CP) ./files/* $(1) 35 | endef 36 | 37 | $(eval $(call BuildPackage,adbyby)) 38 | -------------------------------------------------------------------------------- /adbyby/files/usr/bin/adbyby: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/adbyby/files/usr/bin/adbyby -------------------------------------------------------------------------------- /adbyby/files/usr/bin/adhook.ini: -------------------------------------------------------------------------------- 1 | [filter] 2 | exename=* 3 | [set] 4 | AutoRun=1 5 | ShowTrayIcon=1 6 | ShowPopupDlg=1 7 | ShowTrayTips=1 8 | ShowAnimation=0 9 | port=80,80871 10 | [info] 11 | id=ar71xx 12 | [update] 13 | rule=video,lazy 14 | [exrule] 15 | rule=http://mwsl-hosts.qiniudn.com/MWSL-adbyby.txt 16 | rule=http://mwsl-hosts.qiniudn.com/MWSL-adbyby2.txt 17 | 18 | [cfg] 19 | listen-address=0.0.0.0:8118 20 | debug=0 21 | enable-remote-http-toggle=0 22 | buffer-limit=4096 23 | keep-alive-timeout=30 24 | socket-timeout=300 25 | log-messages=1 26 | -------------------------------------------------------------------------------- /adbyby/files/usr/bin/data/clean.ini: -------------------------------------------------------------------------------- 1 | //youku 2 | -s%appdata%\Macromedia\Flash Player\#SharedObjects\YOUKU_FSO_PROXY.sol 3 | 4 | //letv 5 | -s%appdata%\Macromedia\Flash Player\#SharedObjects\com.letv.sol 6 | 7 | //iqiyi 8 | -s%appdata%\Macromedia\Flash Player\#SharedObjects\qiyi_statistics.sol 9 | 10 | //chrome YOUKU 11 | -s%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\YOUKU_FSO_PROXY.sol 12 | 13 | //chrome LeTv 14 | -s%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\com.letv.sol 15 | 16 | //chrome iqiyi 17 | -s%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\qiyi_statistics.sol 18 | 19 | //360 youku 20 | -s%USERPROFILE%\AppData\Local\360Chrome\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\YOUKU_FSO_PROXY.sol 21 | 22 | //360 letv 23 | -s%USERPROFILE%\AppData\Local\360Chrome\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\com.letv.sol 24 | 25 | //360 iqiyi 26 | -s%USERPROFILE%\AppData\Local\360Chrome\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\qiyi_statistics.sol 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /adbyby/files/usr/bin/data/user.txt: -------------------------------------------------------------------------------- 1 | ! ------------------------------ ADByby 自定义过滤语法简表--------------------------------- 2 | ! -------------- 规则基于abp规则,并进行了字符替换部分的扩展----------------------------- 3 | ! ABP规则请参考https://adblockplus.org/zh_CN/filters,下面为大致摘要 4 | ! "!" 为行注释符,注释行以该符号起始作为一行注释语义,用于规则描述 5 | ! "*" 为字符通配符,能够匹配0长度或任意长度的字符串,该通配符不能与正则语法混用。 6 | ! "^" 为分隔符,可以是除了字母、数字或者 _ - . % 之外的任何字符。 7 | ! "|" 为管线符号,来表示地址的最前端或最末端 8 | ! "||" 为子域通配符,方便匹配主域名下的所有子域。 9 | ! "~" 为排除标识符,通配符能过滤大多数广告,但同时存在误杀, 可以通过排除标识符修正误杀链接。 10 | ! "##" 为元素选择器标识符,后面跟需要隐藏元素的CSS样式例如 #ad_id .ad_class 11 | !! 元素隐藏暂不支持全局规则和排除规则 12 | !! 字符替换扩展 13 | ! 文本替换选择器标识符,后面跟需要替换的文本数据,格式:$s@模式字符串@替换后的文本@ 14 | ! 支持通配符*和? 15 | ! ------------------------------------------------------------------------------------------- 16 | -------------------------------------------------------------------------------- /adbyby/files/usr/bin/user.action: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libdvbcsa/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2014 nanpuyue 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=libdvbcsa 11 | PKG_VERSION:=1.1.0 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_URL:=http://download.videolan.org/pub/videolan/libdvbcsa/$(PKG_VERSION)/ 16 | #PKG_MD5SUM:=894da0e07a715dd8e44f8b3486093e70 17 | 18 | PKG_MAINTAINER:=maz-1 19 | 20 | PKG_INSTALL:=1 21 | PKG_BUILD_PARALLEL:=1 22 | 23 | include $(INCLUDE_DIR)/package.mk 24 | 25 | define Package/libdvbcsa 26 | SECTION:=libs 27 | CATEGORY:=Libraries 28 | TITLE:=libdvbcsa 29 | URL:=http://www.videolan.org/developers/libdvbcsa.html 30 | MENU:=1 31 | endef 32 | 33 | define Package/libdvbcsa/description 34 | libdvbcsa is a free implementation of the DVB Common Scrambling 35 | Algorithm - DVB/CSA - with encryption and decryption capabilities 36 | endef 37 | 38 | CONFIGURE_ARGS += \ 39 | --prefix=/usr 40 | 41 | define Build/Configure 42 | $(call Build/Configure/Default) 43 | endef 44 | 45 | define Build/InstallDev 46 | $(INSTALL_DIR) $(1)/usr/include 47 | $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ 48 | $(INSTALL_DIR) $(1)/usr/lib 49 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libdvbcsa.{a,so*} $(1)/usr/lib/ 50 | endef 51 | 52 | define Package/libdvbcsa/install 53 | $(INSTALL_DIR) $(1)/usr/lib 54 | $(CP) $(PKG_BUILD_DIR)/src/.libs/libdvbcsa.so* $(1)/usr/lib/ 55 | endef 56 | 57 | $(eval $(call BuildPackage,libdvbcsa)) 58 | -------------------------------------------------------------------------------- /luci-app-adbyby/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=luci-app-adbyby 11 | PKG_VERSION:=1 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/luci-app-adbyby 17 | SECTION:=LuCI 18 | CATEGORY:=LuCI 19 | SUBMENU:=3. Applications 20 | TITLE:=adbyby. 21 | DEPENDS:=+luci +adbyby 22 | PKGARCH:=all 23 | MAINTAINER:=maz1 24 | endef 25 | 26 | define Package/luci-app-adbyby/description 27 | adbyby. 28 | endef 29 | 30 | define Build/Compile 31 | endef 32 | 33 | 34 | define Package/luci-app-adbyby/install 35 | $(CP) ./files/* $(1) 36 | endef 37 | 38 | $(eval $(call BuildPackage,luci-app-adbyby)) 39 | -------------------------------------------------------------------------------- /luci-app-adbyby/files/etc/config/adbyby: -------------------------------------------------------------------------------- 1 | 2 | config adbyby 'config' 3 | option enabled '0' 4 | option path '/usr/bin/adbyby' 5 | -------------------------------------------------------------------------------- /luci-app-adbyby/files/etc/init.d/adbyby: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=99 4 | STOP=99 5 | APP='adbyby' 6 | 7 | start() { 8 | config_load "$APP" 9 | local enabled path 10 | config_get enabled config enabled 11 | config_get path config path '/usr/bin/adbyby' 12 | [ "$enabled" = '1' ] && { 13 | service_start "$path" & sleep 1 14 | iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8118 15 | } 16 | } 17 | 18 | stop() { 19 | iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8118 20 | service_stop /usr/bin/adbyby 21 | } 22 | -------------------------------------------------------------------------------- /luci-app-adbyby/files/etc/uci-defaults/luci-adbyby: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@adbyby[-1] 5 | add ucitrack adbyby 6 | set ucitrack.@adbyby[-1].init=adbyby 7 | commit ucitrack 8 | EOF 9 | 10 | rm -f /tmp/luci-indexcache 11 | exit 0 12 | -------------------------------------------------------------------------------- /luci-app-adbyby/files/usr/lib/lua/luci/controller/adbyby.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.adbyby", package.seeall) 2 | 3 | function index() 4 | 5 | if not nixio.fs.access("/etc/config/adbyby") then 6 | return 7 | end 8 | 9 | local page 10 | page = entry({"admin", "services", "adbyby"}, cbi("adbyby"), _("ADBYBY"), 38) 11 | page.dependent = true 12 | end 13 | -------------------------------------------------------------------------------- /luci-app-adbyby/files/usr/lib/lua/luci/model/cbi/adbyby.lua: -------------------------------------------------------------------------------- 1 | local fs = require "nixio.fs" 2 | local util = require "nixio.util" 3 | 4 | local running=(luci.sys.call("pidof adbyby > /dev/null") == 0) 5 | if running then 6 | m = Map("adbyby", translate("ADBYBY"), translate("ADBYBY is running")) 7 | else 8 | m = Map("adbyby", translate("ADBYBY"), translate("ADBYBY is not running")) 9 | end 10 | 11 | en = m:section(TypedSection, "adbyby", "Basic") 12 | en.anonymous = true 13 | enable = en:option(Flag, "enabled", translate("Enable")) 14 | enable.rmempty = false 15 | path = en:option(Value, "path", translate("Path")) 16 | path.default = "/usr/bin/adbyby" 17 | path.optional = false 18 | 19 | s = m:section(TypedSection, "adbyby", translate("Rules")) 20 | s.anonymous = true 21 | 22 | user = s:tab("editconf_user", translate("User Rules")) 23 | editconf_user = s:taboption("editconf_user", Value, "_editconf_user", "", translate("Comment by #")) 24 | editconf_user.template = "cbi/tvalue" 25 | editconf_user.rows = 20 26 | editconf_user.wrap = "off" 27 | 28 | function editconf_user.cfgvalue(self, section) 29 | return fs.readfile("/usr/bin/data/user.txt") or "" 30 | end 31 | 32 | function editconf_user.write(self, section, value) 33 | if value then 34 | value = value:gsub("\r\n?", "\n") 35 | fs.writefile("/tmp/user.txt", value) 36 | if (luci.sys.call("cmp -s /tmp/user.txt /usr/bin/data/user.txt") == 1) then 37 | fs.writefile("/usr/bin/data/user.txt", value) 38 | end 39 | fs.remove("/tmp/user.txt") 40 | end 41 | end 42 | 43 | return m 44 | -------------------------------------------------------------------------------- /luci-app-qosv4/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=luci-app-qosv4 11 | PKG_VERSION:=1.1f 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/luci-app-qosv4 17 | SECTION:=LuCI 18 | CATEGORY:=LuCI 19 | SUBMENU:=3. Applications 20 | TITLE:=LuCI Support for QoSv4. 21 | DEPENDS:=+tc +iptables-mod-conntrack-extra +iptables-mod-filter +iptables-mod-imq +iptables-mod-ipopt +iptables-mod-imq +iptables-mod-hashlimit +kmod-sched 22 | PKGARCH:=all 23 | MAINTAINER:=qq 3341249 24 | endef 25 | 26 | define Package/luci-app-qosv4/description 27 | An agent script that makes qosv4 configuration simple. 28 | endef 29 | 30 | define Build/Compile 31 | endef 32 | 33 | define Package/luci-app-qosv4/postinst 34 | #!/bin/sh 35 | 36 | [ -n "${IPKG_INSTROOT}" ] || { 37 | ( . /etc/uci-defaults/luci-qosv4 ) && rm -f /etc/uci-defaults/luci-qosv4 38 | chmod 755 /etc/init.d/qosv4 >/dev/null 2>&1 39 | /etc/init.d/qosv4 enable >/dev/null 2>&1 40 | sed -i -e '/qos_scheduler/d' /etc/crontabs/root >/dev/null 2>&1 41 | exit 0 42 | } 43 | endef 44 | 45 | define Package/luci-app-qosv4/install 46 | $(CP) ./files/* $(1) 47 | endef 48 | 49 | $(eval $(call BuildPackage,luci-app-qosv4)) 50 | -------------------------------------------------------------------------------- /luci-app-qosv4/README.md: -------------------------------------------------------------------------------- 1 | luci-app-qosv4 2 | ============== 3 | 4 | 这是应用于openwrt的qos程序,由qq 3341249开发完成,在此上传分享只为方便大家使用与学习 5 | -------------------------------------------------------------------------------- /luci-app-qosv4/files/etc/config/qosv4: -------------------------------------------------------------------------------- 1 | 2 | config 'qos_settings' 3 | option 'UP' '100' 4 | option 'DOWN' '500' 5 | option 'UPLOADR' '2' 6 | option 'DOWNLOADR' '2' 7 | option 'UPLOADR2' '1' 8 | option 'UPLOADC2' '5' 9 | option 'DOWNLOADR2' '1' 10 | option 'DOWNLOADC2' '2' 11 | option 'qos_scheduler' '1' 12 | option 'enable' '0' 13 | 14 | config 'qos_ip' 15 | option 'limit_ip' '192.168.1.5' 16 | option 'UPLOADC' '15' 17 | option 'DOWNLOADC' '15' 18 | option 'ip_prio' '5' 19 | option 'enable' '0' 20 | 21 | config 'qos_nolimit_ip' 22 | option 'nolimit_ip' '192.168.1.1' 23 | option 'nolimit_mac' '00:00:00:00:00' 24 | option 'enable' '0' 25 | 26 | config 'transmission_limit' 27 | option 'downlimit' '100' 28 | option 'uplimit' '100' 29 | option 'enable' '0' 30 | -------------------------------------------------------------------------------- /luci-app-qosv4/files/etc/init.d/qosv4: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=60 4 | 5 | start(){ 6 | /usr/bin/qosv4 start 7 | } 8 | 9 | stop(){ 10 | /usr/bin/qosv4 stop 11 | } 12 | restart(){ 13 | /usr/bin/qosv4 start 14 | } 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /luci-app-qosv4/files/etc/uci-defaults/luci-qosv4: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@qosv4[-1] 5 | add ucitrack qosv4 6 | set ucitrack.@qosv4[-1].init=qosv4 7 | commit ucitrack 8 | EOF 9 | rm -f /tmp/luci-indexcahe 10 | exit 0 11 | -------------------------------------------------------------------------------- /luci-app-qosv4/files/usr/bin/qosv4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-qosv4/files/usr/bin/qosv4 -------------------------------------------------------------------------------- /luci-app-qosv4/files/usr/lib/lua/luci/controller/qosv4.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.qosv4", package.seeall) 2 | 3 | function index() 4 | require("luci.i18n") 5 | luci.i18n.loadc("qosv4") 6 | local fs = luci.fs or nixio.fs 7 | if not fs.access("/etc/config/qosv4") then 8 | return 9 | end 10 | 11 | 12 | local page = entry({"admin", "network", "qosv4"}, cbi("qosv4"), "QOSv4") 13 | page.i18n = "qosv4" 14 | page.dependent = true 15 | 16 | 17 | end 18 | -------------------------------------------------------------------------------- /luci-app-qosv4/files/usr/lib/lua/luci/i18n/qosv4.zh-cn.lmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-qosv4/files/usr/lib/lua/luci/i18n/qosv4.zh-cn.lmo -------------------------------------------------------------------------------- /luci-app-qosv4/files/usr/lib/lua/luci/model/cbi/qosv4.lua: -------------------------------------------------------------------------------- 1 | require("luci.tools.webadmin") 2 | 3 | --[[ 4 | config 'qos_settings' 5 | option 'enable' '0' 6 | option 'UP' '100' 7 | option 'DOWN' '500' 8 | option qos_scheduler 1 9 | 10 | config 'qos_ip' 11 | option 'enable' '0' 12 | option 'limit_ip' '192.168.1.5' 13 | option 'UPLOADR' '2' 14 | option 'DOWNLOADR' '2' 15 | option 'UPLOADC' '15' 16 | option 'DOWNLOADC' '15' 17 | option 'UPLOADR2' '1' 18 | option 'UPLOADC2' '5' 19 | option 'DOWNLOADR2' '1' 20 | option 'DOWNLOADC2' '2' 21 | 22 | config 'qos_nolimit_ip' 23 | option 'enable' '0' 24 | option 'limit_ip' '192.168.1.6' 25 | 26 | ]]-- 27 | 28 | local sys = require "luci.sys" 29 | 30 | m = Map("qosv4", translate("qosv4 title","QOSv4"), 31 | translate("qosv4 title desc","qosv4 title desc")) 32 | 33 | s = m:section(TypedSection, "qos_settings", translate("qos goble setting","qos goble setting")) 34 | s.anonymous = true 35 | s.addremove = false 36 | 37 | enable = s:option(Flag, "enable", translate("qos enable", "qos enable")) 38 | enable.default = false 39 | enable.optional = false 40 | enable.rmempty = false 41 | 42 | qos_scheduler = s:option(Flag, "qos_scheduler", translate("qos scheduler enable", "qos scheduler enable"), 43 | translate("qos scheduler desc","qos scheduler desc")) 44 | qos_scheduler.default = false 45 | qos_scheduler.optional = false 46 | qos_scheduler.rmempty = false 47 | 48 | 49 | DOWN = s:option(Value, "DOWN", translate("DOWN speed","DOWN speed"), 50 | translate("DOWN speed desc","DOWN speed desc")) 51 | DOWN.optional = false 52 | DOWN.rmempty = false 53 | 54 | UP = s:option(Value, "UP", translate("UP speed","UP speed"), 55 | translate("UP speed desc","UP speed desc")) 56 | UP.optional = false 57 | UP.rmempty = false 58 | 59 | DOWNLOADR = s:option(Value, "DOWNLOADR", translate("DOWNLOADR speed","DOWNLOADR speed")) 60 | DOWNLOADR.optional = false 61 | DOWNLOADR.rmempty = false 62 | 63 | UPLOADR = s:option(Value, "UPLOADR", translate("UPLOADR speed","UPLOADR speed")) 64 | UPLOADR.optional = false 65 | UPLOADR.rmempty = false 66 | 67 | DOWNLOADR2 = s:option(Value, "DOWNLOADR2", translate("DOWNLOADR2 speed","DOWNLOADR2 speed")) 68 | DOWNLOADR2.optional = false 69 | DOWNLOADR2.rmempty = false 70 | 71 | UPLOADR2 = s:option(Value, "UPLOADR2", translate("UPLOADR2 speed","UPLOADR2 speed")) 72 | UPLOADR2.optional = false 73 | UPLOADR2.rmempty = false 74 | 75 | DOWNLOADC2 = s:option(Value, "DOWNLOADC2", translate("DOWNLOADC2 speed","DOWNLOADC2 speed")) 76 | DOWNLOADC2.optional = false 77 | DOWNLOADC2.rmempty = false 78 | 79 | UPLOADC2 = s:option(Value, "UPLOADC2", translate("UPLOADC2 speed","UPLOADC2 speed")) 80 | UPLOADC2.optional = false 81 | UPLOADC2.rmempty = false 82 | 83 | 84 | 85 | 86 | 87 | s = m:section(TypedSection, "qos_ip", translate("qos black ip","qos black ip")) 88 | s.template = "cbi/tblsection" 89 | s.anonymous = true 90 | s.addremove = true 91 | 92 | enable = s:option(Flag, "enable", translate("enable", "enable")) 93 | enable.default = false 94 | enable.optional = false 95 | enable.rmempty = false 96 | 97 | 98 | 99 | limit_ip = s:option(Value, "limit_ip", translate("limit_ip","limit_ip")) 100 | limit_ip.rmempty = true 101 | luci.tools.webadmin.cbi_add_knownips(limit_ip) 102 | 103 | 104 | DOWNLOADC = s:option(Value, "DOWNLOADC", translate("DOWNLOADC speed","DOWNLOADC speed")) 105 | DOWNLOADC.optional = false 106 | DOWNLOADC.rmempty = false 107 | 108 | UPLOADC = s:option(Value, "UPLOADC", translate("UPLOADC speed","UPLOADC speed")) 109 | UPLOADC.optional = false 110 | UPLOADC.rmempty = false 111 | 112 | ip_prio = s:option(Value, "ip_prio", translate("ip prio","ip prio"), 113 | translate("ip prio desc"," default 5 ")) 114 | ip_prio.optional = false 115 | ip_prio.rmempty = false 116 | 117 | 118 | s = m:section(TypedSection, "transmission_limit", translate("transmission limit","transmission limit")) 119 | s.template = "cbi/tblsection" 120 | s.anonymous = true 121 | s.addremove = false 122 | 123 | enable = s:option(Flag, "enable", translate("enable", "enable")) 124 | enable.default = false 125 | enable.optional = false 126 | enable.rmempty = false 127 | 128 | downlimit= s:option(Value, "downlimit", translate("downlimit speed","downlimit speed")) 129 | downlimit.optional = false 130 | downlimit.rmempty = false 131 | 132 | uplimit= s:option(Value, "uplimit", translate("uplimit speed","uplimit speed")) 133 | uplimit.optional = false 134 | uplimit.rmempty = false 135 | 136 | 137 | s = m:section(TypedSection, "qos_nolimit_ip", translate("qos white","qos white")) 138 | s.template = "cbi/tblsection" 139 | s.anonymous = true 140 | s.addremove = true 141 | 142 | enable = s:option(Flag, "enable", translate("enable", "enable")) 143 | enable.default = false 144 | enable.optional = false 145 | enable.rmempty = false 146 | 147 | nolimit_mac= s:option(Value, "nolimit_mac", translate("white mac","white mac")) 148 | nolimit_mac.rmempty = true 149 | 150 | nolimit_ip= s:option(Value, "nolimit_ip", translate("white ip","white ip")) 151 | nolimit_ip.rmempty = true 152 | 153 | 154 | sys.net.arptable(function(entry) 155 | nolimit_ip:value(entry["IP address"]) 156 | nolimit_mac:value( 157 | entry["HW address"], 158 | entry["HW address"] .. " (" .. entry["IP address"] .. ")" 159 | ) 160 | end) 161 | 162 | return m 163 | 164 | -------------------------------------------------------------------------------- /luci-app-wifidog/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=luci-app-wifidog 4 | PKG_VERSION=1.0 5 | PKG_RELEASE:=1 6 | 7 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) 8 | 9 | include $(INCLUDE_DIR)/package.mk 10 | 11 | define Package/luci-app-wifidog 12 | SECTION:=luci 13 | CATEGORY:=LuCI 14 | SUBMENU:=3. Applications 15 | DEPENDS:=+wifidog +lighttpd-mod-fastcgi +lighttpd-mod-rewrite +php5-fastcgi +php5-cli +php5-mod-ctype +php5-mod-pdo +php5-mod-pdo-sqlite +php5-mod-session +php5-mod-sqlite3 +php5-mod-tokenizer +zoneinfo-asia +zoneinfo-core 16 | TITLE:=wifidog configuration for LuCI 17 | endef 18 | 19 | define Package/luci-app-wifidog/description 20 | This package contains LuCI configuration pages for wifidog. 21 | endef 22 | 23 | define Build/Prepare 24 | endef 25 | 26 | define Build/Configure 27 | endef 28 | 29 | define Build/Compile 30 | endef 31 | 32 | define Package/luci-app-wifidog/install 33 | $(INSTALL_DIR) $(1)/etc/config 34 | $(INSTALL_DIR) $(1)/etc/lighttpd 35 | $(INSTALL_DIR) $(1)/etc/init.d 36 | $(INSTALL_DIR) $(1)/etc/uci-defaults 37 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi 38 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller 39 | $(INSTALL_DIR) $(1)/www 40 | $(INSTALL_DIR) $(1)/www/wifidog 41 | $(INSTALL_DIR) $(1)/www/wifidog/assets 42 | $(INSTALL_DIR) $(1)/www/wifidog/assets/images 43 | $(INSTALL_DIR) $(1)/www/wifidog/Slim 44 | $(INSTALL_DIR) $(1)/www/wifidog/Slim/Exception 45 | $(INSTALL_DIR) $(1)/www/wifidog/Slim/Helper 46 | $(INSTALL_DIR) $(1)/www/wifidog/Slim/Http 47 | $(INSTALL_DIR) $(1)/www/wifidog/Slim/Middleware 48 | $(INSTALL_DIR) $(1)/www/wifidog/templates 49 | $(INSTALL_CONF) ./files/root/etc/config/wifidog $(1)/etc/config/ 50 | $(INSTALL_CONF) ./files/root/etc/php.ini $(1)/etc/ 51 | $(INSTALL_CONF) ./files/root/etc/lighttpd/lighttpd.conf $(1)/etc/lighttpd/ 52 | $(INSTALL_BIN) ./files/root/etc/init.d/wifidog $(1)/etc/init.d/ 53 | $(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-wifidog $(1)/etc/uci-defaults/ 54 | $(INSTALL_DATA) ./files/root/usr/lib/lua/luci/model/cbi/wifidog.lua $(1)/usr/lib/lua/luci/model/cbi/ 55 | $(INSTALL_DATA) ./files/root/usr/lib/lua/luci/controller/wifidog.lua $(1)/usr/lib/lua/luci/controller/ 56 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/loader.gif $(1)/www/wifidog/assets/ 57 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/portal.css $(1)/www/wifidog/assets/ 58 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/portal.min.js $(1)/www/wifidog/assets/ 59 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/ratchicons.eot $(1)/www/wifidog/assets/ 60 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/ratchicons.svg $(1)/www/wifidog/assets/ 61 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/ratchicons.ttf $(1)/www/wifidog/assets/ 62 | $(INSTALL_DATA) ./files/root/www/wifidog/assets/ratchicons.woff $(1)/www/wifidog/assets/ 63 | $(INSTALL_DATA) ./files/root/www/wifidog/index.php $(1)/www/wifidog/ 64 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Environment.php $(1)/www/wifidog/Slim/ 65 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Exception/Pass.php $(1)/www/wifidog/Slim/Exception/ 66 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Exception/Stop.php $(1)/www/wifidog/Slim/Exception/ 67 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Helper/Set.php $(1)/www/wifidog/Slim/Helper/ 68 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Http/Cookies.php $(1)/www/wifidog/Slim/Http/ 69 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Http/Headers.php $(1)/www/wifidog/Slim/Http/ 70 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Http/Request.php $(1)/www/wifidog/Slim/Http/ 71 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Http/Response.php $(1)/www/wifidog/Slim/Http/ 72 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Http/Util.php $(1)/www/wifidog/Slim/Http/ 73 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Log.php $(1)/www/wifidog/Slim/ 74 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/LogWriter.php $(1)/www/wifidog/Slim/ 75 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware/ContentTypes.php $(1)/www/wifidog/Slim/Middleware/ 76 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware/Flash.php $(1)/www/wifidog/Slim/Middleware/ 77 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware/MethodOverride.php $(1)/www/wifidog/Slim/Middleware/ 78 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware/PrettyExceptions.php $(1)/www/wifidog/Slim/Middleware/ 79 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware/SessionCookie.php $(1)/www/wifidog/Slim/Middleware/ 80 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Middleware.php $(1)/www/wifidog/Slim/ 81 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Route.php $(1)/www/wifidog/Slim/ 82 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Router.php $(1)/www/wifidog/Slim/ 83 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/Slim.php $(1)/www/wifidog/Slim/ 84 | $(INSTALL_DATA) ./files/root/www/wifidog/Slim/View.php $(1)/www/wifidog/Slim/ 85 | $(INSTALL_DATA) ./files/root/www/wifidog/templates/701.html $(1)/www/wifidog/templates/ 86 | $(INSTALL_DATA) ./files/root/www/wifidog/templates/show.php $(1)/www/wifidog/templates/ 87 | $(INSTALL_DATA) ./files/root/www/wifidog/templates/touch.php $(1)/www/wifidog/templates/ 88 | endef 89 | 90 | define Package/luci-app-wifidog/postinst 91 | #!/bin/sh 92 | [ -n "${IPKG_INSTROOT}" ] || { 93 | ( . /etc/uci-defaults/luci-wifidog ) && rm -f /etc/uci-defaults/luci-wifidog 94 | chmod 755 /etc/init.d/wifidog >/dev/null 2>&1 95 | /etc/init.d/wifidog enable >/dev/null 2>&1 96 | exit 0 97 | } 98 | endef 99 | 100 | $(eval $(call BuildPackage,luci-app-wifidog)) 101 | -------------------------------------------------------------------------------- /luci-app-wifidog/README.md: -------------------------------------------------------------------------------- 1 | # luci-app-wifidog 2 | This package contains LuCI configuration pages for wifidog. 3 | 4 | ## Features 5 | 1. Luci configuration page for wifidog 6 | 2. Bulit-in local authentication server with lighttp and php5 7 | 3. Sync with remote server 8 | 9 | ## Install 10 | 1. Git clone this respository in your `package` directory. 11 | 2. `make menuconfig` and select luci-app-wifidog in LUCI category and save. 12 | 3. `make luci-app-wifidog/compile` with a single package. 13 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/etc/config/wifidog: -------------------------------------------------------------------------------- 1 | config settings 'settings' 2 | option gateway_host 'wanluo.tv' 3 | option gateway_hostname '万罗热点' 4 | option gateway_httpport '80' 5 | option gateway_path '/wifidog/' 6 | option gateway_connmax '50' 7 | option wifidog_enable '0' 8 | option offline_enable '0' 9 | option gatewayport '2060' 10 | option check_interval '60' 11 | option client_timeout '5' 12 | option client_time_limit '60' 13 | 14 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/etc/init.d/wifidog: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=65 4 | 5 | EXTRA_COMMANDS="status" 6 | EXTRA_HELP=" status Print the status of the service" 7 | 8 | config_load() 9 | { 10 | wifidog_enable=$(uci get wifidog.settings.wifidog_enable) 11 | offline_enable=$(uci get wifidog.settings.offline_enable) 12 | if [[ "$wifidog_enable" -eq 0 ]]; then 13 | stop 14 | exit 0 15 | else 16 | /usr/bin/wifidog-init stop 17 | sleep 1 18 | 19 | rm -f /etc/wifidog.conf 20 | gateway_interface=$(uci get wifidog.settings.gateway_interface) 21 | gateway_eninterface=$(uci get wifidog.settings.gateway_eninterface) 22 | gateway_host=$(uci get wifidog.settings.gateway_host) 23 | gateway_httpport=$(uci get wifidog.settings.gateway_httpport) 24 | gateway_path=$(uci get wifidog.settings.gateway_path) 25 | gateway_connmax=$(uci get wifidog.settings.gateway_connmax) 26 | ssl_enable=$(uci get wifidog.settings.ssl_enable) 27 | check_interval=$(uci get wifidog.settings.check_interval) 28 | client_timeout=$(uci get wifidog.settings.client_timeout) 29 | sslport=$(uci get wifidog.settings.sslport) 30 | deamo_enable=$(uci get wifidog.settings.deamo_enable) 31 | gatewayport=$(uci get wifidog.settings.gatewayport) 32 | myz_mac=$(uci get wifidog.settings.myz_mac) 33 | bmd_url=$(uci get wifidog.settings.bmd_url) 34 | 35 | echo " 36 | GatewayInterface $gateway_interface 37 | AuthServer { 38 | Hostname $gateway_host 39 | SSLAvailable $ssl_enable 40 | SSLPort $sslport 41 | HTTPPort $gateway_httpport 42 | Path $gateway_path 43 | } 44 | Daemon $deamo_enable 45 | GatewayPort $gatewayport 46 | CheckInterval $check_interval 47 | ClientTimeout $client_timeout 48 | HTTPDMaxConn $gateway_connmax 49 | TrustedMACList $myz_mac 50 | 51 | FirewallRuleSet global { 52 | FirewallRule allow to 61.139.2.69 53 | FirewallRule allow to 8.8.8.8 54 | FirewallRule allow to 114.114.114.114 55 | } 56 | FirewallRuleSet validating-users { 57 | FirewallRule allow to 0.0.0.0/0 58 | } 59 | 60 | FirewallRuleSet known-users { 61 | FirewallRule allow to 0.0.0.0/0 62 | } 63 | 64 | FirewallRuleSet unknown-users { 65 | FirewallRule allow udp port 53 66 | FirewallRule allow tcp port 53 67 | FirewallRule allow udp port 67 68 | FirewallRule allow tcp port 67 69 | } 70 | 71 | FirewallRuleSet locked-users { 72 | FirewallRule block to 0.0.0.0/0 73 | } 74 | " >> /etc/wifidog.conf 75 | fi 76 | } 77 | 78 | start() { 79 | 80 | 81 | config_load 82 | /usr/bin/wifidog-init start 83 | [ "$offline_enable" -eq 1 ] && /etc/init.d/lighttpd start 84 | sleep 2 85 | iptables -t filter -A WiFiDog_br-lan_AuthServers -d $bmd_url -j ACCEPT 86 | iptables -t nat -A WiFiDog_br-lan_AuthServers -d $bmd_url -j ACCEPT 87 | } 88 | 89 | stop() { 90 | if /usr/bin/wifidog-init status 2> /dev/null 91 | then 92 | /usr/bin/wifidog-init stop 93 | fi 94 | sleep 2 95 | /etc/init.d/lighttpd stop 96 | } 97 | 98 | status() { 99 | /usr/bin/wifidog-init status 100 | 101 | } 102 | 103 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/etc/lighttpd/lighttpd.conf: -------------------------------------------------------------------------------- 1 | # lighttpd configuration file 2 | # 3 | ## modules to load 4 | # all other module should only be loaded if really neccesary 5 | # - saves some time 6 | # - saves memory 7 | server.modules = ( 8 | "mod_rewrite", 9 | # "mod_redirect", 10 | # "mod_alias", 11 | # "mod_auth", 12 | # "mod_status", 13 | # "mod_setenv", 14 | "mod_fastcgi", 15 | # "mod_proxy", 16 | # "mod_simple_vhost", 17 | # "mod_cgi", 18 | # "mod_ssi", 19 | # "mod_usertrack", 20 | # "mod_expire", 21 | # "mod_webdav" 22 | ) 23 | 24 | # force use of the "write" backend (closes: #2401) 25 | server.network-backend = "write" 26 | 27 | ## a static document-root, for virtual-hosting take look at the 28 | ## server.virtual-* options 29 | server.document-root = "/www/wifidog/" 30 | 31 | ## where to send error-messages to 32 | #server.errorlog = "/var/log/lighttpd/error.log" 33 | 34 | ## files to check for if .../ is requested 35 | index-file.names = ( "index.html", "default.html", "index.htm", "default.htm", "index.php" ) 36 | 37 | ## mimetype mapping 38 | mimetype.assign = ( 39 | ".pdf" => "application/pdf", 40 | ".class" => "application/octet-stream", 41 | ".pac" => "application/x-ns-proxy-autoconfig", 42 | ".swf" => "application/x-shockwave-flash", 43 | ".wav" => "audio/x-wav", 44 | ".gif" => "image/gif", 45 | ".jpg" => "image/jpeg", 46 | ".jpeg" => "image/jpeg", 47 | ".png" => "image/png", 48 | ".svg" => "image/svg+xml", 49 | ".css" => "text/css", 50 | ".html" => "text/html", 51 | ".htm" => "text/html", 52 | ".js" => "text/javascript", 53 | ".txt" => "text/plain", 54 | ".dtd" => "text/xml", 55 | ".xml" => "text/xml" 56 | ) 57 | 58 | ## Use the "Content-Type" extended attribute to obtain mime type if possible 59 | #mimetypes.use-xattr = "enable" 60 | 61 | ## send a different Server: header 62 | ## be nice and keep it at lighttpd 63 | #server.tag = "lighttpd" 64 | 65 | $HTTP["url"] =~ "\.pdf$" { 66 | server.range-requests = "disable" 67 | } 68 | 69 | ## 70 | # which extensions should not be handle via static-file transfer 71 | # 72 | # .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi 73 | static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) 74 | 75 | ######### Options that are good to be but not neccesary to be changed ####### 76 | 77 | ## bind to port (default: 80) 78 | server.port = 81 79 | 80 | ## bind to localhost (default: all interfaces) 81 | #server.bind = "localhost" 82 | 83 | ## error-handler for status 404 84 | #server.error-handler-404 = "/error-handler.html" 85 | #server.error-handler-404 = "/error-handler.php" 86 | 87 | ## to help the rc.scripts 88 | server.pid-file = "/var/run/lighttpd.pid" 89 | 90 | 91 | ###### virtual hosts 92 | ## 93 | ## If you want name-based virtual hosting add the next three settings and load 94 | ## mod_simple_vhost 95 | ## 96 | ## document-root = 97 | ## virtual-server-root + virtual-server-default-host + virtual-server-docroot or 98 | ## virtual-server-root + http-host + virtual-server-docroot 99 | ## 100 | #simple-vhost.server-root = "/home/weigon/wwwroot/servers/" 101 | #simple-vhost.default-host = "grisu.home.kneschke.de" 102 | #simple-vhost.document-root = "/pages/" 103 | 104 | 105 | ## 106 | ## Format: .html 107 | ## -> ..../status-404.html for 'File not found' 108 | #server.errorfile-prefix = "/www/error-" 109 | 110 | ## virtual directory listings 111 | #server.dir-listing = "enable" 112 | 113 | ## send unhandled HTTP-header headers to error-log 114 | #debug.dump-unknown-headers = "enable" 115 | 116 | ### only root can use these options 117 | # 118 | # chroot() to directory (default: no chroot() ) 119 | #server.chroot = "/" 120 | 121 | ## change uid to (default: don't care) 122 | #server.username = "nobody" 123 | # 124 | server.upload-dirs = ( "/tmp" ) 125 | 126 | ## change uid to (default: don't care) 127 | #server.groupname = "nobody" 128 | 129 | #### compress module 130 | #compress.cache-dir = "/dev/null/" 131 | #compress.filetype = ("text/plain", "text/html") 132 | 133 | #### proxy module 134 | ## read proxy.txt for more info 135 | #proxy.server = ( 136 | # ".php" => ( 137 | # "localhost" => ( 138 | # "host" => "192.168.0.101", 139 | # "port" => 80 140 | # ) 141 | # ) 142 | #) 143 | 144 | #### fastcgi module 145 | ## read fastcgi.txt for more info 146 | fastcgi.server = ( 147 | ".php" => ( 148 | "localhost" => ( 149 | "socket" => "/tmp/php-fastcgi.socket", 150 | "bin-path" => "/usr/bin/php-fcgi", 151 | "min-procs" => 0, 152 | "max-procs" => 5, 153 | "idle-timeout" => 10, 154 | "bin-environment" => ( 155 | "PHP_FCGI_CHILDREN" => "2", 156 | "PHP_FCGI_MAX_REQUESTS" => "1000" 157 | ), 158 | "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), 159 | "broken-scriptfilename" => "enable" 160 | ) 161 | ) 162 | ) 163 | 164 | #### CGI module 165 | ##cgi.assign = ( ".php" => "/usr/bin/php-cgi" ) 166 | 167 | #### SSL engine 168 | #ssl.engine = "enable" 169 | #ssl.pemfile = "server.pem" 170 | 171 | #### status module 172 | #status.status-url = "/server-status" 173 | #status.config-url = "/server-config" 174 | 175 | #### auth module 176 | ## read authentification.txt for more info 177 | #auth.backend = "plain" 178 | #auth.backend.plain.userfile = "lighttpd.user" 179 | #auth.backend.plain.groupfile = "lighttpd.group" 180 | #auth.require = ( 181 | # "/server-status" => ( 182 | # "method" => "digest", 183 | # "realm" => "download archiv", 184 | # "require" => "group=www|user=jan|host=192.168.2.10" 185 | # ), 186 | # "/server-info" => ( 187 | # "method" => "digest", 188 | # "realm" => "download archiv", 189 | # "require" => "group=www|user=jan|host=192.168.2.10" 190 | # ) 191 | #) 192 | 193 | #### url handling modules (rewrite, redirect, access) 194 | url.rewrite = ( "^/assets/.+" => "$0", ".*" => "/index.php" ) 195 | #url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" ) 196 | 197 | #### both rewrite/redirect support back reference to regex conditional using %n 198 | #$HTTP["host"] =~ "^www\.(.*)" { 199 | # url.redirect = ( "^/(.*)" => "http://%1/$1" ) 200 | #} 201 | 202 | #### expire module 203 | #expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes") 204 | 205 | #### ssi 206 | #ssi.extension = ( ".shtml" ) 207 | 208 | #### setenv 209 | #setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" ) 210 | #setenv.add-response-header = ( "X-Secret-Message" => "42" ) 211 | 212 | #### variable usage: 213 | ## variable name without "." is auto prefixed by "var." and becomes "var.bar" 214 | #bar = 1 215 | #var.mystring = "foo" 216 | 217 | ## integer add 218 | #bar += 1 219 | ## string concat, with integer cast as string, result: "www.foo1.com" 220 | #server.name = "www." + mystring + var.bar + ".com" 221 | ## array merge 222 | #index-file.names = (foo + ".php") + index-file.names 223 | #index-file.names += (foo + ".php") 224 | 225 | #### include 226 | #include /etc/lighttpd/lighttpd-inc.conf 227 | ## same as above if you run: "lighttpd -f /etc/lighttpd/lighttpd.conf" 228 | #include "lighttpd-inc.conf" 229 | 230 | #### include_shell 231 | #include_shell "echo var.a=1" 232 | ## the above is same as: 233 | #var.a=1 234 | 235 | #### webdav 236 | #$HTTP["url"] =~ "^/webdav($|/)" { 237 | # webdav.activate = "enable" 238 | # webdav.is-readonly = "enable" 239 | # webdav.sqlite-db-name = "/var/run/lighttpd-webdav-lock.db" 240 | #} 241 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/etc/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | 3 | zend.ze1_compatibility_mode = Off 4 | 5 | ; Language Options 6 | 7 | engine = On 8 | ;short_open_tag = Off 9 | precision = 12 10 | y2k_compliance = On 11 | output_buffering = Off 12 | ;output_handler = 13 | zlib.output_compression = Off 14 | ;zlib.output_compression_level = -1 15 | ;zlib.output_handler = 16 | implicit_flush = Off 17 | unserialize_callback_func = 18 | serialize_precision = 100 19 | 20 | ;open_basedir = 21 | disable_functions = 22 | disable_classes = 23 | 24 | ; Colors for Syntax Highlighting mode. Anything that's acceptable in 25 | ; would work. 26 | ;highlight.string = #DD0000 27 | ;highlight.comment = #FF9900 28 | ;highlight.keyword = #007700 29 | ;highlight.bg = #FFFFFF 30 | ;highlight.default = #0000BB 31 | ;highlight.html = #000000 32 | 33 | ;ignore_user_abort = On 34 | ;realpath_cache_size = 16k 35 | ;realpath_cache_ttl = 120 36 | 37 | ; Miscellaneous 38 | 39 | expose_php = On 40 | 41 | ; Resource Limits 42 | 43 | max_execution_time = 30 ; Maximum execution time of each script, in seconds. 44 | max_input_time = 60 ; Maximum amount of time each script may spend parsing request data. 45 | ;max_input_nesting_level = 64 46 | memory_limit = 8M ; Maximum amount of memory a script may consume. 47 | 48 | ; Error handling and logging 49 | 50 | ; Error Level Constants: 51 | ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 6.0.0) 52 | ; E_ERROR - fatal run-time errors 53 | ; E_RECOVERABLE_ERROR - almost fatal run-time errors 54 | ; E_WARNING - run-time warnings (non-fatal errors) 55 | ; E_PARSE - compile-time parse errors 56 | ; E_NOTICE - run-time notices (these are warnings which often result 57 | ; from a bug in your code, but it's possible that it was 58 | ; intentional (e.g., using an uninitialized variable and 59 | ; relying on the fact it's automatically initialized to an 60 | ; empty string) 61 | ; E_STRICT - run-time notices, enable to have PHP suggest changes 62 | ; to your code which will ensure the best interoperability 63 | ; and forward compatibility of your code 64 | ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup 65 | ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's 66 | ; initial startup 67 | ; E_COMPILE_ERROR - fatal compile-time errors 68 | ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) 69 | ; E_USER_ERROR - user-generated error message 70 | ; E_USER_WARNING - user-generated warning message 71 | ; E_USER_NOTICE - user-generated notice message 72 | ; E_DEPRECATED - warn about code that will not work in future versions 73 | ; of PHP 74 | ; E_USER_DEPRECATED - user-generated deprecation warnings 75 | ; 76 | ; Common Values: 77 | ; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.) 78 | ; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices) 79 | ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) 80 | ; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.) 81 | ; Default Value: E_ALL & ~E_NOTICE 82 | error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT 83 | 84 | display_errors = On 85 | display_startup_errors = Off 86 | log_errors = Off 87 | log_errors_max_len = 1024 88 | ignore_repeated_errors = Off 89 | ignore_repeated_source = Off 90 | report_memleaks = On 91 | ;report_zend_debug = 0 92 | track_errors = Off 93 | ;html_errors = Off 94 | ;docref_root = "/phpmanual/" 95 | ;docref_ext = .html 96 | ;error_prepend_string = "" 97 | ;error_append_string = "" 98 | ; Log errors to specified file. 99 | ;error_log = /var/log/php_errors.log 100 | ; Log errors to syslog. 101 | ;error_log = syslog 102 | 103 | ; Data Handling 104 | 105 | ;arg_separator.output = "&" 106 | ;arg_separator.input = ";&" 107 | variables_order = "EGPCS" 108 | request_order = "GP" 109 | register_globals = Off 110 | register_long_arrays = Off 111 | register_argc_argv = On 112 | auto_globals_jit = On 113 | post_max_size = 8M 114 | ;magic_quotes_gpc = Off 115 | magic_quotes_runtime = Off 116 | magic_quotes_sybase = Off 117 | auto_prepend_file = 118 | auto_append_file = 119 | default_mimetype = "text/html" 120 | ;default_charset = "iso-8859-1" 121 | ;always_populate_raw_post_data = On 122 | 123 | ; Paths and Directories 124 | 125 | ; UNIX: "/path1:/path2" 126 | ;include_path = ".:/php/includes" 127 | ;doc_root = "/root/www" 128 | user_dir = 129 | extension_dir = "/usr/lib/php" 130 | enable_dl = On 131 | cgi.force_redirect = 1 132 | ;cgi.nph = 1 133 | ;cgi.redirect_status_env = ; 134 | cgi.fix_pathinfo=1 135 | ;fastcgi.impersonate = 1; 136 | ;fastcgi.logging = 0 137 | ;cgi.rfc2616_headers = 0 138 | 139 | ; File Uploads 140 | 141 | file_uploads = On 142 | upload_tmp_dir = "/tmp" 143 | upload_max_filesize = 2M 144 | max_file_uploads = 20 145 | 146 | ; Fopen wrappers 147 | 148 | allow_url_fopen = On 149 | allow_url_include = Off 150 | ;from="john@doe.com" 151 | ;user_agent="PHP" 152 | default_socket_timeout = 60 153 | ;auto_detect_line_endings = Off 154 | 155 | ; Dynamic Extensions 156 | 157 | extension=ctype.so 158 | extension=curl.so 159 | ;extension=dom.so 160 | ;extension=exif.so 161 | ;extension=ftp.so 162 | ;extension=gd.so 163 | ;extension=gmp.so 164 | ;extension=hash.so 165 | ;extension=iconv.so 166 | extension=json.so 167 | ;extension=ldap.so 168 | ;extension=mbstring.so 169 | ;extension=mcrypt.so 170 | ;extension=mysql.so 171 | ;extension=openssl.so 172 | ;extension=pcre.so 173 | extension=pdo.so 174 | ;extension=pdo-mysql.so 175 | ;extension=pdo-pgsql.so 176 | extension=pdo_sqlite.so 177 | ;extension=pgsql.so 178 | extension=session.so 179 | ;extension=soap.so 180 | ;extension=sockets.so 181 | ;extension=sqlite.so 182 | ;extension=sqlite3.so 183 | extension=tokenizer.so 184 | ;extension=xml.so 185 | ;extension=xmlreader.so 186 | ;extension=xmlwriter.so 187 | 188 | ; Module Settings 189 | 190 | [APC] 191 | apc.enabled = 1 192 | apc.shm_segments = 1 ;The number of shared memory segments to allocate for the compiler cache. 193 | apc.shm_size = 4M ;The size of each shared memory segment. 194 | 195 | [Date] 196 | date.timezone = 'Asia/Chongqing' 197 | ;date.default_latitude = 31.7667 198 | ;date.default_longitude = 35.2333 199 | ;date.sunrise_zenith = 90.583333 200 | ;date.sunset_zenith = 90.583333 201 | 202 | [filter] 203 | ;filter.default = unsafe_raw 204 | ;filter.default_flags = 205 | 206 | [iconv] 207 | ;iconv.input_encoding = ISO-8859-1 208 | ;iconv.internal_encoding = ISO-8859-1 209 | ;iconv.output_encoding = ISO-8859-1 210 | 211 | [sqlite] 212 | ;sqlite.assoc_case = 0 213 | 214 | [sqlite3] 215 | ;sqlite3.extension_dir = 216 | 217 | [Pdo_mysql] 218 | pdo_mysql.cache_size = 2000 219 | pdo_mysql.default_socket= 220 | 221 | [MySQL] 222 | mysql.allow_local_infile = On 223 | mysql.allow_persistent = On 224 | mysql.cache_size = 2000 225 | mysql.max_persistent = -1 226 | mysql.max_links = -1 227 | mysql.default_port = 228 | mysql.default_socket = 229 | mysql.default_host = 230 | mysql.default_user = 231 | mysql.default_password = 232 | mysql.connect_timeout = 60 233 | mysql.trace_mode = Off 234 | 235 | [PostgresSQL] 236 | pgsql.allow_persistent = On 237 | pgsql.auto_reset_persistent = Off 238 | pgsql.max_persistent = -1 239 | pgsql.max_links = -1 240 | pgsql.ignore_notice = 0 241 | pgsql.log_notice = 0 242 | 243 | [Session] 244 | session.save_handler = files 245 | session.save_path = "/tmp" 246 | session.use_cookies = 1 247 | ;session.cookie_secure = 248 | session.use_only_cookies = 1 249 | session.name = PHPSESSID 250 | session.auto_start = 0 251 | session.cookie_lifetime = 0 252 | session.cookie_path = / 253 | session.cookie_domain = 254 | session.cookie_httponly = 255 | session.serialize_handler = php 256 | session.gc_probability = 1 257 | session.gc_divisor = 100 258 | session.gc_maxlifetime = 1440 259 | session.bug_compat_42 = On 260 | session.bug_compat_warn = On 261 | session.referer_check = 262 | session.entropy_length = 0 263 | ;session.entropy_file = /dev/urandom 264 | session.entropy_file = 265 | ;session.entropy_length = 16 266 | session.cache_limiter = nocache 267 | session.cache_expire = 180 268 | session.use_trans_sid = 0 269 | session.hash_function = 0 270 | session.hash_bits_per_character = 4 271 | url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" 272 | 273 | [mbstring] 274 | ;mbstring.language = Japanese 275 | ;mbstring.internal_encoding = EUC-JP 276 | ;mbstring.http_input = auto 277 | ;mbstring.http_output = SJIS 278 | ;mbstring.encoding_translation = Off 279 | ;mbstring.detect_order = auto 280 | ;mbstring.substitute_character = none; 281 | ;mbstring.func_overload = 0 282 | ;mbstring.strict_detection = Off 283 | ;mbstring.http_output_conv_mimetype= 284 | ;mbstring.script_encoding= 285 | 286 | [gd] 287 | ;gd.jpeg_ignore_warning = 0 288 | 289 | [exif] 290 | ;exif.encode_unicode = ISO-8859-15 291 | ;exif.decode_unicode_motorola = UCS-2BE 292 | ;exif.decode_unicode_intel = UCS-2LE 293 | ;exif.encode_jis = 294 | ;exif.decode_jis_motorola = JIS 295 | ;exif.decode_jis_intel = JIS 296 | 297 | [soap] 298 | soap.wsdl_cache_enabled=1 299 | soap.wsdl_cache_dir="/tmp" 300 | soap.wsdl_cache_ttl=86400 301 | soap.wsdl_cache_limit = 5 302 | 303 | [sysvshm] 304 | ;sysvshm.init_mem = 10000 305 | 306 | [ldap] 307 | ldap.max_links = -1 308 | 309 | [mcrypt] 310 | ;mcrypt.algorithms_dir= 311 | ;mcrypt.modes_dir= 312 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/etc/uci-defaults/luci-wifidog: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@wifidog[-1] 5 | set ucitrack.wifidog="wifidog" 6 | set ucitrack.wifidog.exec='/etc/init.d/wifidog start' 7 | commit ucitrack 8 | EOF 9 | 10 | rm -f /tmp/luci-indexcache 11 | exit 0 12 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/usr/lib/lua/luci/controller/wifidog.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.wifidog", package.seeall) 2 | 3 | 4 | function index() 5 | local fs = require "nixio.fs" 6 | if fs.access("/usr/bin/wifidog") then 7 | entry({"admin", "services","wifidog"}, cbi("wifidog"), "强制门户", 4) 8 | end 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/usr/lib/lua/luci/model/cbi/wifidog.lua: -------------------------------------------------------------------------------- 1 | local sys = require "luci.sys" 2 | local fs = require "nixio.fs" 3 | local uci = require "luci.model.uci".cursor() 4 | local wan_ifname = luci.util.exec("uci get network.wan.ifname") 5 | local lan_ifname = luci.util.exec("uci get network.lan.ifname") 6 | m = Map("wifidog", "强制门户", 7 | translate("强制门户是一种受限制的网络连接,所有客户端的HTTP请求都重定向到指定的站点")) 8 | 9 | if fs.access("/usr/bin/wifidog") then 10 | s = m:section(TypedSection, "settings", "认证站点配置") 11 | s.anonymous = true 12 | s.addremove = false 13 | s:tab("jbsz", translate("基本设置")) 14 | s:tab("bmd", translate("白名单")) 15 | s:tab("gjsz", translate("高级设置")) 16 | 17 | wifidog_enable = s:taboption("jbsz",Flag, "wifidog_enable", 18 | translate("启用认证"), 19 | translate("打开或关闭认证")) 20 | wifidog_enable.rmempty=false 21 | deamo_enable = s:taboption("jbsz",Flag, "deamo_enable", translate("守护进程"),"开启监护认证进程,保证认证进程时时在线") 22 | deamo_enable:depends("wifidog_enable","1") 23 | ssl_enable = s:taboption("gjsz",Flag, "ssl_enable", translate("加密传输"),"启用安全套接层协议传输,提高网络传输安全") 24 | sslport = s:taboption("gjsz",Value,"sslport","SSL传输端口号","默认443") 25 | sslport:depends("ssl_enable","1") 26 | gateway_interface = s:taboption("gjsz",Value,"gateway_interface","内网接口","设置内网接口,默认'br-lan'。") 27 | gateway_interface.default = "br-lan" 28 | gateway_interface:value(wan_ifname,wan_ifname .."" ) 29 | gateway_interface:value(lan_ifname,lan_ifname .. "") 30 | 31 | 32 | for _, e in ipairs(sys.net.devices()) do 33 | if e ~= "lo" then gateway_interface:value(e) end 34 | end 35 | 36 | gateway_host = s:taboption("jbsz",Value,"gateway_host","认证站点地址","域名或者IP") 37 | offline_enable = s:taboption("jbsz", Flag, "offline_enable", translate("启用离线认证"), "本地内建认证服务器") 38 | offline_enable.rmempty = false 39 | gateway_hostname = s:taboption("jbsz",Value,"gateway_hostname","认证站点名称","显示在标题栏上的内容") 40 | gateway_hostname:depends("offline_enable", "1") 41 | gatewayport = s:taboption("gjsz",Value,"gatewayport","认证网关端口号","默认端口号2060") 42 | gateway_httpport = s:taboption("gjsz",Value,"gateway_httpport","HTTP端口号","默认80端口") 43 | gateway_path = s:taboption("gjsz",Value,"gateway_path","认证服务器路径","最后要加/,例如:'/','/wifidog/'") 44 | gateway_connmax = s:taboption("gjsz",Value,"gateway_connmax","最大用户接入数量","以路由器性能而定,默认50") 45 | gateway_connmax.default = "50" 46 | check_interval = s:taboption("gjsz",Value,"check_interval","检查间隔","接入客户端在线检测间隔,默认60秒") 47 | check_interval.default = "60" 48 | client_timeout = s:taboption("gjsz",Value,"client_timeout","客户端超时","接入客户端认证超时,默认5分") 49 | client_timeout.default = "5" 50 | client_time_limit = s:taboption("gjsz",Value,"client_time_limit","客户端限额","接入客户端限制使用时间,默认60分") 51 | client_time_limit.default = "60" 52 | client_time_limit:depends("offline_enable", "1") 53 | --[白名单]-- 54 | bmd_url=s:taboption("bmd",Value,"bmd_url","网站URL白名单","url不认证也能打开,不能带”http://“多个URL请用”,“号隔开。如:“www.baidu.com,www.qq.com”") 55 | myz_mac=s:taboption("bmd",Value,"myz_mac","免认证设备","填入设备的MAC地址,多个设备请用“,”号隔开。如:“11:22:33:44:55:66,aa:bb:cc:dd:ff:00”") 56 | 57 | 58 | else 59 | m.pageaction = false 60 | end 61 | 62 | 63 | return m 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Environment.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Environment 37 | * 38 | * This class creates and returns a key/value array of common 39 | * environment variables for the current HTTP request. 40 | * 41 | * This is a singleton class; derived environment variables will 42 | * be common across multiple Slim applications. 43 | * 44 | * This class matches the Rack (Ruby) specification as closely 45 | * as possible. More information available below. 46 | * 47 | * @package Slim 48 | * @author Josh Lockhart 49 | * @since 1.6.0 50 | */ 51 | class Environment implements \ArrayAccess, \IteratorAggregate 52 | { 53 | /** 54 | * @var array 55 | */ 56 | protected $properties; 57 | 58 | /** 59 | * @var \Slim\Environment 60 | */ 61 | protected static $environment; 62 | 63 | /** 64 | * Get environment instance (singleton) 65 | * 66 | * This creates and/or returns an environment instance (singleton) 67 | * derived from $_SERVER variables. You may override the global server 68 | * variables by using `\Slim\Environment::mock()` instead. 69 | * 70 | * @param bool $refresh Refresh properties using global server variables? 71 | * @return \Slim\Environment 72 | */ 73 | public static function getInstance($refresh = false) 74 | { 75 | if (is_null(self::$environment) || $refresh) { 76 | self::$environment = new self(); 77 | } 78 | 79 | return self::$environment; 80 | } 81 | 82 | /** 83 | * Get mock environment instance 84 | * 85 | * @param array $userSettings 86 | * @return \Slim\Environment 87 | */ 88 | public static function mock($userSettings = array()) 89 | { 90 | $defaults = array( 91 | 'REQUEST_METHOD' => 'GET', 92 | 'SCRIPT_NAME' => '', 93 | 'PATH_INFO' => '', 94 | 'QUERY_STRING' => '', 95 | 'SERVER_NAME' => 'localhost', 96 | 'SERVER_PORT' => 80, 97 | 'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 98 | 'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', 99 | 'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 100 | 'USER_AGENT' => 'Slim Framework', 101 | 'REMOTE_ADDR' => '127.0.0.1', 102 | 'slim.url_scheme' => 'http', 103 | 'slim.input' => '', 104 | 'slim.errors' => @fopen('php://stderr', 'w') 105 | ); 106 | self::$environment = new self(array_merge($defaults, $userSettings)); 107 | 108 | return self::$environment; 109 | } 110 | 111 | /** 112 | * Constructor (private access) 113 | * 114 | * @param array|null $settings If present, these are used instead of global server variables 115 | */ 116 | private function __construct($settings = null) 117 | { 118 | if ($settings) { 119 | $this->properties = $settings; 120 | } else { 121 | $env = array(); 122 | 123 | //The HTTP request method 124 | $env['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD']; 125 | 126 | //The IP 127 | $env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; 128 | 129 | // Server params 130 | $scriptName = $_SERVER['SCRIPT_NAME']; // <-- "/foo/index.php" 131 | $requestUri = $_SERVER['REQUEST_URI']; // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc" 132 | $slice = explode('?', $requestUri, 2); 133 | $queryString = ''; 134 | 135 | if (count($slice) == 2) { 136 | $queryString = $slice[1]; 137 | } 138 | 139 | // fix with lighttpd 140 | // $queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : $queryString; // <-- "test=abc" or "" 141 | 142 | // Physical path 143 | if (strpos($requestUri, $scriptName) !== false) { 144 | $physicalPath = $scriptName; // <-- Without rewriting 145 | } else { 146 | $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting 147 | } 148 | $env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes 149 | 150 | // Virtual path 151 | $env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path 152 | $env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string 153 | $env['PATH_INFO'] = '/' . trim($env['PATH_INFO'], '/'); // <-- Ensure leading slash 154 | 155 | // Query string (without leading "?") 156 | $env['QUERY_STRING'] = $queryString; 157 | 158 | //Name of server host that is running the script 159 | $env['SERVER_NAME'] = $_SERVER['SERVER_NAME']; 160 | 161 | //Number of server port that is running the script 162 | $env['SERVER_PORT'] = $_SERVER['SERVER_PORT']; 163 | 164 | //HTTP request headers (retains HTTP_ prefix to match $_SERVER) 165 | $headers = \Slim\Http\Headers::extract($_SERVER); 166 | foreach ($headers as $key => $value) { 167 | $env[$key] = $value; 168 | } 169 | 170 | //Is the application running under HTTPS or HTTP protocol? 171 | $env['slim.url_scheme'] = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https'; 172 | 173 | //Input stream (readable one time only; not available for multipart/form-data requests) 174 | $rawInput = @file_get_contents('php://input'); 175 | if (!$rawInput) { 176 | $rawInput = ''; 177 | } 178 | $env['slim.input'] = $rawInput; 179 | 180 | //Error stream 181 | $env['slim.errors'] = @fopen('php://stderr', 'w'); 182 | 183 | $this->properties = $env; 184 | } 185 | } 186 | 187 | /** 188 | * Array Access: Offset Exists 189 | */ 190 | public function offsetExists($offset) 191 | { 192 | return isset($this->properties[$offset]); 193 | } 194 | 195 | /** 196 | * Array Access: Offset Get 197 | */ 198 | public function offsetGet($offset) 199 | { 200 | if (isset($this->properties[$offset])) { 201 | return $this->properties[$offset]; 202 | } else { 203 | return null; 204 | } 205 | } 206 | 207 | /** 208 | * Array Access: Offset Set 209 | */ 210 | public function offsetSet($offset, $value) 211 | { 212 | $this->properties[$offset] = $value; 213 | } 214 | 215 | /** 216 | * Array Access: Offset Unset 217 | */ 218 | public function offsetUnset($offset) 219 | { 220 | unset($this->properties[$offset]); 221 | } 222 | 223 | /** 224 | * IteratorAggregate 225 | * 226 | * @return \ArrayIterator 227 | */ 228 | public function getIterator() 229 | { 230 | return new \ArrayIterator($this->properties); 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Exception/Pass.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Exception; 34 | 35 | /** 36 | * Pass Exception 37 | * 38 | * This Exception will cause the Router::dispatch method 39 | * to skip the current matching route and continue to the next 40 | * matching route. If no subsequent routes are found, a 41 | * HTTP 404 Not Found response will be sent to the client. 42 | * 43 | * @package Slim 44 | * @author Josh Lockhart 45 | * @since 1.0.0 46 | */ 47 | class Pass extends \Exception 48 | { 49 | } 50 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Exception/Stop.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Exception; 34 | 35 | /** 36 | * Stop Exception 37 | * 38 | * This Exception is thrown when the Slim application needs to abort 39 | * processing and return control flow to the outer PHP script. 40 | * 41 | * @package Slim 42 | * @author Josh Lockhart 43 | * @since 1.0.0 44 | */ 45 | class Stop extends \Exception 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Helper/Set.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Helper; 34 | 35 | class Set implements \ArrayAccess, \Countable, \IteratorAggregate 36 | { 37 | /** 38 | * Key-value array of arbitrary data 39 | * @var array 40 | */ 41 | protected $data = array(); 42 | 43 | /** 44 | * Constructor 45 | * @param array $items Pre-populate set with this key-value array 46 | */ 47 | public function __construct($items = array()) 48 | { 49 | $this->replace($items); 50 | } 51 | 52 | /** 53 | * Normalize data key 54 | * 55 | * Used to transform data key into the necessary 56 | * key format for this set. Used in subclasses 57 | * like \Slim\Http\Headers. 58 | * 59 | * @param string $key The data key 60 | * @return mixed The transformed/normalized data key 61 | */ 62 | protected function normalizeKey($key) 63 | { 64 | return $key; 65 | } 66 | 67 | /** 68 | * Set data key to value 69 | * @param string $key The data key 70 | * @param mixed $value The data value 71 | */ 72 | public function set($key, $value) 73 | { 74 | $this->data[$this->normalizeKey($key)] = $value; 75 | } 76 | 77 | /** 78 | * Get data value with key 79 | * @param string $key The data key 80 | * @param mixed $default The value to return if data key does not exist 81 | * @return mixed The data value, or the default value 82 | */ 83 | public function get($key, $default = null) 84 | { 85 | if ($this->has($key)) { 86 | $isInvokable = is_object($this->data[$this->normalizeKey($key)]) && method_exists($this->data[$this->normalizeKey($key)], '__invoke'); 87 | 88 | return $isInvokable ? $this->data[$this->normalizeKey($key)]($this) : $this->data[$this->normalizeKey($key)]; 89 | } 90 | 91 | return $default; 92 | } 93 | 94 | /** 95 | * Add data to set 96 | * @param array $items Key-value array of data to append to this set 97 | */ 98 | public function replace($items) 99 | { 100 | foreach ($items as $key => $value) { 101 | $this->set($key, $value); // Ensure keys are normalized 102 | } 103 | } 104 | 105 | /** 106 | * Fetch set data 107 | * @return array This set's key-value data array 108 | */ 109 | public function all() 110 | { 111 | return $this->data; 112 | } 113 | 114 | /** 115 | * Fetch set data keys 116 | * @return array This set's key-value data array keys 117 | */ 118 | public function keys() 119 | { 120 | return array_keys($this->data); 121 | } 122 | 123 | /** 124 | * Does this set contain a key? 125 | * @param string $key The data key 126 | * @return boolean 127 | */ 128 | public function has($key) 129 | { 130 | return array_key_exists($this->normalizeKey($key), $this->data); 131 | } 132 | 133 | /** 134 | * Remove value with key from this set 135 | * @param string $key The data key 136 | */ 137 | public function remove($key) 138 | { 139 | unset($this->data[$this->normalizeKey($key)]); 140 | } 141 | 142 | /** 143 | * Property Overloading 144 | */ 145 | 146 | public function __get($key) 147 | { 148 | return $this->get($key); 149 | } 150 | 151 | public function __set($key, $value) 152 | { 153 | $this->set($key, $value); 154 | } 155 | 156 | public function __isset($key) 157 | { 158 | return $this->has($key); 159 | } 160 | 161 | public function __unset($key) 162 | { 163 | return $this->remove($key); 164 | } 165 | 166 | /** 167 | * Clear all values 168 | */ 169 | public function clear() 170 | { 171 | $this->data = array(); 172 | } 173 | 174 | /** 175 | * Array Access 176 | */ 177 | 178 | public function offsetExists($offset) 179 | { 180 | return $this->has($offset); 181 | } 182 | 183 | public function offsetGet($offset) 184 | { 185 | return $this->get($offset); 186 | } 187 | 188 | public function offsetSet($offset, $value) 189 | { 190 | $this->set($offset, $value); 191 | } 192 | 193 | public function offsetUnset($offset) 194 | { 195 | $this->remove($offset); 196 | } 197 | 198 | /** 199 | * Countable 200 | */ 201 | 202 | public function count() 203 | { 204 | return count($this->data); 205 | } 206 | 207 | /** 208 | * IteratorAggregate 209 | */ 210 | 211 | public function getIterator() 212 | { 213 | return new \ArrayIterator($this->data); 214 | } 215 | 216 | /** 217 | * Ensure a value or object will remain globally unique 218 | * @param string $key The value or object name 219 | * @param Closure The closure that defines the object 220 | * @return mixed 221 | */ 222 | public function singleton($key, $value) 223 | { 224 | $this->set($key, function ($c) use ($value) { 225 | static $object; 226 | 227 | if (null === $object) { 228 | $object = $value($c); 229 | } 230 | 231 | return $object; 232 | }); 233 | } 234 | 235 | /** 236 | * Protect closure from being directly invoked 237 | * @param Closure $callable A closure to keep from being invoked and evaluated 238 | * @return Closure 239 | */ 240 | public function protect(\Closure $callable) 241 | { 242 | return function () use ($callable) { 243 | return $callable; 244 | }; 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Http/Cookies.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Http; 34 | 35 | class Cookies extends \Slim\Helper\Set 36 | { 37 | /** 38 | * Default cookie settings 39 | * @var array 40 | */ 41 | protected $defaults = array( 42 | 'value' => '', 43 | 'domain' => null, 44 | 'path' => null, 45 | 'expires' => null, 46 | 'secure' => false, 47 | 'httponly' => false 48 | ); 49 | 50 | /** 51 | * Set cookie 52 | * 53 | * The second argument may be a single scalar value, in which case 54 | * it will be merged with the default settings and considered the `value` 55 | * of the merged result. 56 | * 57 | * The second argument may also be an array containing any or all of 58 | * the keys shown in the default settings above. This array will be 59 | * merged with the defaults shown above. 60 | * 61 | * @param string $key Cookie name 62 | * @param mixed $value Cookie settings 63 | */ 64 | public function set($key, $value) 65 | { 66 | if (is_array($value)) { 67 | $cookieSettings = array_replace($this->defaults, $value); 68 | } else { 69 | $cookieSettings = array_replace($this->defaults, array('value' => $value)); 70 | } 71 | parent::set($key, $cookieSettings); 72 | } 73 | 74 | /** 75 | * Remove cookie 76 | * 77 | * Unlike \Slim\Helper\Set, this will actually *set* a cookie with 78 | * an expiration date in the past. This expiration date will force 79 | * the client-side cache to remove its cookie with the given name 80 | * and settings. 81 | * 82 | * @param string $key Cookie name 83 | * @param array $settings Optional cookie settings 84 | */ 85 | public function remove($key, $settings = array()) 86 | { 87 | $settings['value'] = ''; 88 | $settings['expires'] = time() - 86400; 89 | $this->set($key, array_replace($this->defaults, $settings)); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Http/Headers.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Http; 34 | 35 | /** 36 | * HTTP Headers 37 | * 38 | * @package Slim 39 | * @author Josh Lockhart 40 | * @since 1.6.0 41 | */ 42 | class Headers extends \Slim\Helper\Set 43 | { 44 | /******************************************************************************** 45 | * Static interface 46 | *******************************************************************************/ 47 | 48 | /** 49 | * Special-case HTTP headers that are otherwise unidentifiable as HTTP headers. 50 | * Typically, HTTP headers in the $_SERVER array will be prefixed with 51 | * `HTTP_` or `X_`. These are not so we list them here for later reference. 52 | * 53 | * @var array 54 | */ 55 | protected static $special = array( 56 | 'CONTENT_TYPE', 57 | 'CONTENT_LENGTH', 58 | 'PHP_AUTH_USER', 59 | 'PHP_AUTH_PW', 60 | 'PHP_AUTH_DIGEST', 61 | 'AUTH_TYPE' 62 | ); 63 | 64 | /** 65 | * Extract HTTP headers from an array of data (e.g. $_SERVER) 66 | * @param array $data 67 | * @return array 68 | */ 69 | public static function extract($data) 70 | { 71 | $results = array(); 72 | foreach ($data as $key => $value) { 73 | $key = strtoupper($key); 74 | if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) { 75 | if ($key === 'HTTP_CONTENT_LENGTH') { 76 | continue; 77 | } 78 | $results[$key] = $value; 79 | } 80 | } 81 | 82 | return $results; 83 | } 84 | 85 | /******************************************************************************** 86 | * Instance interface 87 | *******************************************************************************/ 88 | 89 | /** 90 | * Transform header name into canonical form 91 | * @param string $key 92 | * @return string 93 | */ 94 | protected function normalizeKey($key) 95 | { 96 | $key = strtolower($key); 97 | $key = str_replace(array('-', '_'), ' ', $key); 98 | $key = preg_replace('#^http #', '', $key); 99 | $key = ucwords($key); 100 | $key = str_replace(' ', '-', $key); 101 | 102 | return $key; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Log.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Log 37 | * 38 | * This is the primary logger for a Slim application. You may provide 39 | * a Log Writer in conjunction with this Log to write to various output 40 | * destinations (e.g. a file). This class provides this interface: 41 | * 42 | * debug( mixed $object, array $context ) 43 | * info( mixed $object, array $context ) 44 | * notice( mixed $object, array $context ) 45 | * warning( mixed $object, array $context ) 46 | * error( mixed $object, array $context ) 47 | * critical( mixed $object, array $context ) 48 | * alert( mixed $object, array $context ) 49 | * emergency( mixed $object, array $context ) 50 | * log( mixed $level, mixed $object, array $context ) 51 | * 52 | * This class assumes only that your Log Writer has a public `write()` method 53 | * that accepts any object as its one and only argument. The Log Writer 54 | * class may write or send its argument anywhere: a file, STDERR, 55 | * a remote web API, etc. The possibilities are endless. 56 | * 57 | * @package Slim 58 | * @author Josh Lockhart 59 | * @since 1.0.0 60 | */ 61 | class Log 62 | { 63 | const EMERGENCY = 1; 64 | const ALERT = 2; 65 | const CRITICAL = 3; 66 | const FATAL = 3; //DEPRECATED replace with CRITICAL 67 | const ERROR = 4; 68 | const WARN = 5; 69 | const NOTICE = 6; 70 | const INFO = 7; 71 | const DEBUG = 8; 72 | 73 | /** 74 | * @var array 75 | */ 76 | protected static $levels = array( 77 | self::EMERGENCY => 'EMERGENCY', 78 | self::ALERT => 'ALERT', 79 | self::CRITICAL => 'CRITICAL', 80 | self::ERROR => 'ERROR', 81 | self::WARN => 'WARNING', 82 | self::NOTICE => 'NOTICE', 83 | self::INFO => 'INFO', 84 | self::DEBUG => 'DEBUG' 85 | ); 86 | 87 | /** 88 | * @var mixed 89 | */ 90 | protected $writer; 91 | 92 | /** 93 | * @var bool 94 | */ 95 | protected $enabled; 96 | 97 | /** 98 | * @var int 99 | */ 100 | protected $level; 101 | 102 | /** 103 | * Constructor 104 | * @param mixed $writer 105 | */ 106 | public function __construct($writer) 107 | { 108 | $this->writer = $writer; 109 | $this->enabled = true; 110 | $this->level = self::DEBUG; 111 | } 112 | 113 | /** 114 | * Is logging enabled? 115 | * @return bool 116 | */ 117 | public function getEnabled() 118 | { 119 | return $this->enabled; 120 | } 121 | 122 | /** 123 | * Enable or disable logging 124 | * @param bool $enabled 125 | */ 126 | public function setEnabled($enabled) 127 | { 128 | if ($enabled) { 129 | $this->enabled = true; 130 | } else { 131 | $this->enabled = false; 132 | } 133 | } 134 | 135 | /** 136 | * Set level 137 | * @param int $level 138 | * @throws \InvalidArgumentException If invalid log level specified 139 | */ 140 | public function setLevel($level) 141 | { 142 | if (!isset(self::$levels[$level])) { 143 | throw new \InvalidArgumentException('Invalid log level'); 144 | } 145 | $this->level = $level; 146 | } 147 | 148 | /** 149 | * Get level 150 | * @return int 151 | */ 152 | public function getLevel() 153 | { 154 | return $this->level; 155 | } 156 | 157 | /** 158 | * Set writer 159 | * @param mixed $writer 160 | */ 161 | public function setWriter($writer) 162 | { 163 | $this->writer = $writer; 164 | } 165 | 166 | /** 167 | * Get writer 168 | * @return mixed 169 | */ 170 | public function getWriter() 171 | { 172 | return $this->writer; 173 | } 174 | 175 | /** 176 | * Is logging enabled? 177 | * @return bool 178 | */ 179 | public function isEnabled() 180 | { 181 | return $this->enabled; 182 | } 183 | 184 | /** 185 | * Log debug message 186 | * @param mixed $object 187 | * @param array $context 188 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 189 | */ 190 | public function debug($object, $context = array()) 191 | { 192 | return $this->log(self::DEBUG, $object, $context); 193 | } 194 | 195 | /** 196 | * Log info message 197 | * @param mixed $object 198 | * @param array $context 199 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 200 | */ 201 | public function info($object, $context = array()) 202 | { 203 | return $this->log(self::INFO, $object, $context); 204 | } 205 | 206 | /** 207 | * Log notice message 208 | * @param mixed $object 209 | * @param array $context 210 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 211 | */ 212 | public function notice($object, $context = array()) 213 | { 214 | return $this->log(self::NOTICE, $object, $context); 215 | } 216 | 217 | /** 218 | * Log warning message 219 | * @param mixed $object 220 | * @param array $context 221 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 222 | */ 223 | public function warning($object, $context = array()) 224 | { 225 | return $this->log(self::WARN, $object, $context); 226 | } 227 | 228 | /** 229 | * DEPRECATED for function warning 230 | * Log warning message 231 | * @param mixed $object 232 | * @param array $context 233 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 234 | */ 235 | public function warn($object, $context = array()) 236 | { 237 | return $this->log(self::WARN, $object, $context); 238 | } 239 | 240 | /** 241 | * Log error message 242 | * @param mixed $object 243 | * @param array $context 244 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 245 | */ 246 | public function error($object, $context = array()) 247 | { 248 | return $this->log(self::ERROR, $object, $context); 249 | } 250 | 251 | /** 252 | * Log critical message 253 | * @param mixed $object 254 | * @param array $context 255 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 256 | */ 257 | public function critical($object, $context = array()) 258 | { 259 | return $this->log(self::CRITICAL, $object, $context); 260 | } 261 | 262 | /** 263 | * DEPRECATED for function critical 264 | * Log fatal message 265 | * @param mixed $object 266 | * @param array $context 267 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 268 | */ 269 | public function fatal($object, $context = array()) 270 | { 271 | return $this->log(self::CRITICAL, $object, $context); 272 | } 273 | 274 | /** 275 | * Log alert message 276 | * @param mixed $object 277 | * @param array $context 278 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 279 | */ 280 | public function alert($object, $context = array()) 281 | { 282 | return $this->log(self::ALERT, $object, $context); 283 | } 284 | 285 | /** 286 | * Log emergency message 287 | * @param mixed $object 288 | * @param array $context 289 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 290 | */ 291 | public function emergency($object, $context = array()) 292 | { 293 | return $this->log(self::EMERGENCY, $object, $context); 294 | } 295 | 296 | /** 297 | * Log message 298 | * @param mixed $level 299 | * @param mixed $object 300 | * @param array $context 301 | * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled 302 | * @throws \InvalidArgumentException If invalid log level 303 | */ 304 | public function log($level, $object, $context = array()) 305 | { 306 | if (!isset(self::$levels[$level])) { 307 | throw new \InvalidArgumentException('Invalid log level supplied to function'); 308 | } else if ($this->enabled && $this->writer && $level <= $this->level) { 309 | $message = (string)$object; 310 | if (count($context) > 0) { 311 | if (isset($context['exception']) && $context['exception'] instanceof \Exception) { 312 | $message .= ' - ' . $context['exception']; 313 | unset($context['exception']); 314 | } 315 | $message = $this->interpolate($message, $context); 316 | } 317 | return $this->writer->write($message, $level); 318 | } else { 319 | return false; 320 | } 321 | } 322 | 323 | /** 324 | * DEPRECATED for function log 325 | * Log message 326 | * @param mixed $object The object to log 327 | * @param int $level The message level 328 | * @return int|bool 329 | */ 330 | protected function write($object, $level) 331 | { 332 | return $this->log($level, $object); 333 | } 334 | 335 | /** 336 | * Interpolate log message 337 | * @param mixed $message The log message 338 | * @param array $context An array of placeholder values 339 | * @return string The processed string 340 | */ 341 | protected function interpolate($message, $context = array()) 342 | { 343 | $replace = array(); 344 | foreach ($context as $key => $value) { 345 | $replace['{' . $key . '}'] = $value; 346 | } 347 | return strtr($message, $replace); 348 | } 349 | } 350 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/LogWriter.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Log Writer 37 | * 38 | * This class is used by Slim_Log to write log messages to a valid, writable 39 | * resource handle (e.g. a file or STDERR). 40 | * 41 | * @package Slim 42 | * @author Josh Lockhart 43 | * @since 1.6.0 44 | */ 45 | class LogWriter 46 | { 47 | /** 48 | * @var resource 49 | */ 50 | protected $resource; 51 | 52 | /** 53 | * Constructor 54 | * @param resource $resource 55 | * @throws \InvalidArgumentException If invalid resource 56 | */ 57 | public function __construct($resource) 58 | { 59 | if (!is_resource($resource)) { 60 | throw new \InvalidArgumentException('Cannot create LogWriter. Invalid resource handle.'); 61 | } 62 | $this->resource = $resource; 63 | } 64 | 65 | /** 66 | * Write message 67 | * @param mixed $message 68 | * @param int $level 69 | * @return int|bool 70 | */ 71 | public function write($message, $level = null) 72 | { 73 | return fwrite($this->resource, (string) $message . PHP_EOL); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Middleware 37 | * 38 | * @package Slim 39 | * @author Josh Lockhart 40 | * @since 1.6.0 41 | */ 42 | abstract class Middleware 43 | { 44 | /** 45 | * @var \Slim\Slim Reference to the primary application instance 46 | */ 47 | protected $app; 48 | 49 | /** 50 | * @var mixed Reference to the next downstream middleware 51 | */ 52 | protected $next; 53 | 54 | /** 55 | * Set application 56 | * 57 | * This method injects the primary Slim application instance into 58 | * this middleware. 59 | * 60 | * @param \Slim\Slim $application 61 | */ 62 | final public function setApplication($application) 63 | { 64 | $this->app = $application; 65 | } 66 | 67 | /** 68 | * Get application 69 | * 70 | * This method retrieves the application previously injected 71 | * into this middleware. 72 | * 73 | * @return \Slim\Slim 74 | */ 75 | final public function getApplication() 76 | { 77 | return $this->app; 78 | } 79 | 80 | /** 81 | * Set next middleware 82 | * 83 | * This method injects the next downstream middleware into 84 | * this middleware so that it may optionally be called 85 | * when appropriate. 86 | * 87 | * @param \Slim|\Slim\Middleware 88 | */ 89 | final public function setNextMiddleware($nextMiddleware) 90 | { 91 | $this->next = $nextMiddleware; 92 | } 93 | 94 | /** 95 | * Get next middleware 96 | * 97 | * This method retrieves the next downstream middleware 98 | * previously injected into this middleware. 99 | * 100 | * @return \Slim\Slim|\Slim\Middleware 101 | */ 102 | final public function getNextMiddleware() 103 | { 104 | return $this->next; 105 | } 106 | 107 | /** 108 | * Call 109 | * 110 | * Perform actions specific to this middleware and optionally 111 | * call the next downstream middleware. 112 | */ 113 | abstract public function call(); 114 | } 115 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware/ContentTypes.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Middleware; 34 | 35 | /** 36 | * Content Types 37 | * 38 | * This is middleware for a Slim application that intercepts 39 | * the HTTP request body and parses it into the appropriate 40 | * PHP data structure if possible; else it returns the HTTP 41 | * request body unchanged. This is particularly useful 42 | * for preparing the HTTP request body for an XML or JSON API. 43 | * 44 | * @package Slim 45 | * @author Josh Lockhart 46 | * @since 1.6.0 47 | */ 48 | class ContentTypes extends \Slim\Middleware 49 | { 50 | /** 51 | * @var array 52 | */ 53 | protected $contentTypes; 54 | 55 | /** 56 | * Constructor 57 | * @param array $settings 58 | */ 59 | public function __construct($settings = array()) 60 | { 61 | $defaults = array( 62 | 'application/json' => array($this, 'parseJson'), 63 | 'application/xml' => array($this, 'parseXml'), 64 | 'text/xml' => array($this, 'parseXml'), 65 | 'text/csv' => array($this, 'parseCsv') 66 | ); 67 | $this->contentTypes = array_merge($defaults, $settings); 68 | } 69 | 70 | /** 71 | * Call 72 | */ 73 | public function call() 74 | { 75 | $mediaType = $this->app->request()->getMediaType(); 76 | if ($mediaType) { 77 | $env = $this->app->environment(); 78 | $env['slim.input_original'] = $env['slim.input']; 79 | $env['slim.input'] = $this->parse($env['slim.input'], $mediaType); 80 | } 81 | $this->next->call(); 82 | } 83 | 84 | /** 85 | * Parse input 86 | * 87 | * This method will attempt to parse the request body 88 | * based on its content type if available. 89 | * 90 | * @param string $input 91 | * @param string $contentType 92 | * @return mixed 93 | */ 94 | protected function parse ($input, $contentType) 95 | { 96 | if (isset($this->contentTypes[$contentType]) && is_callable($this->contentTypes[$contentType])) { 97 | $result = call_user_func($this->contentTypes[$contentType], $input); 98 | if ($result) { 99 | return $result; 100 | } 101 | } 102 | 103 | return $input; 104 | } 105 | 106 | /** 107 | * Parse JSON 108 | * 109 | * This method converts the raw JSON input 110 | * into an associative array. 111 | * 112 | * @param string $input 113 | * @return array|string 114 | */ 115 | protected function parseJson($input) 116 | { 117 | if (function_exists('json_decode')) { 118 | $result = json_decode($input, true); 119 | if ($result) { 120 | return $result; 121 | } 122 | } 123 | } 124 | 125 | /** 126 | * Parse XML 127 | * 128 | * This method creates a SimpleXMLElement 129 | * based upon the XML input. If the SimpleXML 130 | * extension is not available, the raw input 131 | * will be returned unchanged. 132 | * 133 | * @param string $input 134 | * @return \SimpleXMLElement|string 135 | */ 136 | protected function parseXml($input) 137 | { 138 | if (class_exists('SimpleXMLElement')) { 139 | try { 140 | $backup = libxml_disable_entity_loader(true); 141 | $result = new \SimpleXMLElement($input); 142 | libxml_disable_entity_loader($backup); 143 | return $result; 144 | } catch (\Exception $e) { 145 | // Do nothing 146 | } 147 | } 148 | 149 | return $input; 150 | } 151 | 152 | /** 153 | * Parse CSV 154 | * 155 | * This method parses CSV content into a numeric array 156 | * containing an array of data for each CSV line. 157 | * 158 | * @param string $input 159 | * @return array 160 | */ 161 | protected function parseCsv($input) 162 | { 163 | $temp = fopen('php://memory', 'rw'); 164 | fwrite($temp, $input); 165 | fseek($temp, 0); 166 | $res = array(); 167 | while (($data = fgetcsv($temp)) !== false) { 168 | $res[] = $data; 169 | } 170 | fclose($temp); 171 | 172 | return $res; 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware/Flash.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Middleware; 34 | 35 | /** 36 | * Flash 37 | * 38 | * This is middleware for a Slim application that enables 39 | * Flash messaging between HTTP requests. This allows you 40 | * set Flash messages for the current request, for the next request, 41 | * or to retain messages from the previous request through to 42 | * the next request. 43 | * 44 | * @package Slim 45 | * @author Josh Lockhart 46 | * @since 1.6.0 47 | */ 48 | class Flash extends \Slim\Middleware implements \ArrayAccess, \IteratorAggregate, \Countable 49 | { 50 | /** 51 | * @var array 52 | */ 53 | protected $settings; 54 | 55 | /** 56 | * @var array 57 | */ 58 | protected $messages; 59 | 60 | /** 61 | * Constructor 62 | * @param array $settings 63 | */ 64 | public function __construct($settings = array()) 65 | { 66 | $this->settings = array_merge(array('key' => 'slim.flash'), $settings); 67 | $this->messages = array( 68 | 'prev' => array(), //flash messages from prev request (loaded when middleware called) 69 | 'next' => array(), //flash messages for next request 70 | 'now' => array() //flash messages for current request 71 | ); 72 | } 73 | 74 | /** 75 | * Call 76 | */ 77 | public function call() 78 | { 79 | //Read flash messaging from previous request if available 80 | $this->loadMessages(); 81 | 82 | //Prepare flash messaging for current request 83 | $env = $this->app->environment(); 84 | $env['slim.flash'] = $this; 85 | $this->next->call(); 86 | $this->save(); 87 | } 88 | 89 | /** 90 | * Now 91 | * 92 | * Specify a flash message for a given key to be shown for the current request 93 | * 94 | * @param string $key 95 | * @param string $value 96 | */ 97 | public function now($key, $value) 98 | { 99 | $this->messages['now'][(string) $key] = $value; 100 | } 101 | 102 | /** 103 | * Set 104 | * 105 | * Specify a flash message for a given key to be shown for the next request 106 | * 107 | * @param string $key 108 | * @param string $value 109 | */ 110 | public function set($key, $value) 111 | { 112 | $this->messages['next'][(string) $key] = $value; 113 | } 114 | 115 | /** 116 | * Keep 117 | * 118 | * Retain flash messages from the previous request for the next request 119 | */ 120 | public function keep() 121 | { 122 | foreach ($this->messages['prev'] as $key => $val) { 123 | $this->messages['next'][$key] = $val; 124 | } 125 | } 126 | 127 | /** 128 | * Save 129 | */ 130 | public function save() 131 | { 132 | $_SESSION[$this->settings['key']] = $this->messages['next']; 133 | } 134 | 135 | /** 136 | * Load messages from previous request if available 137 | */ 138 | public function loadMessages() 139 | { 140 | if (isset($_SESSION[$this->settings['key']])) { 141 | $this->messages['prev'] = $_SESSION[$this->settings['key']]; 142 | } 143 | } 144 | 145 | /** 146 | * Return array of flash messages to be shown for the current request 147 | * 148 | * @return array 149 | */ 150 | public function getMessages() 151 | { 152 | return array_merge($this->messages['prev'], $this->messages['now']); 153 | } 154 | 155 | /** 156 | * Array Access: Offset Exists 157 | */ 158 | public function offsetExists($offset) 159 | { 160 | $messages = $this->getMessages(); 161 | 162 | return isset($messages[$offset]); 163 | } 164 | 165 | /** 166 | * Array Access: Offset Get 167 | */ 168 | public function offsetGet($offset) 169 | { 170 | $messages = $this->getMessages(); 171 | 172 | return isset($messages[$offset]) ? $messages[$offset] : null; 173 | } 174 | 175 | /** 176 | * Array Access: Offset Set 177 | */ 178 | public function offsetSet($offset, $value) 179 | { 180 | $this->now($offset, $value); 181 | } 182 | 183 | /** 184 | * Array Access: Offset Unset 185 | */ 186 | public function offsetUnset($offset) 187 | { 188 | unset($this->messages['prev'][$offset], $this->messages['now'][$offset]); 189 | } 190 | 191 | /** 192 | * Iterator Aggregate: Get Iterator 193 | * @return \ArrayIterator 194 | */ 195 | public function getIterator() 196 | { 197 | $messages = $this->getMessages(); 198 | 199 | return new \ArrayIterator($messages); 200 | } 201 | 202 | /** 203 | * Countable: Count 204 | */ 205 | public function count() 206 | { 207 | return count($this->getMessages()); 208 | } 209 | 210 | 211 | 212 | } 213 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware/MethodOverride.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Middleware; 34 | 35 | /** 36 | * HTTP Method Override 37 | * 38 | * This is middleware for a Slim application that allows traditional 39 | * desktop browsers to submit pseudo PUT and DELETE requests by relying 40 | * on a pre-determined request parameter. Without this middleware, 41 | * desktop browsers are only able to submit GET and POST requests. 42 | * 43 | * This middleware is included automatically! 44 | * 45 | * @package Slim 46 | * @author Josh Lockhart 47 | * @since 1.6.0 48 | */ 49 | class MethodOverride extends \Slim\Middleware 50 | { 51 | /** 52 | * @var array 53 | */ 54 | protected $settings; 55 | 56 | /** 57 | * Constructor 58 | * @param array $settings 59 | */ 60 | public function __construct($settings = array()) 61 | { 62 | $this->settings = array_merge(array('key' => '_METHOD'), $settings); 63 | } 64 | 65 | /** 66 | * Call 67 | * 68 | * Implements Slim middleware interface. This method is invoked and passed 69 | * an array of environment variables. This middleware inspects the environment 70 | * variables for the HTTP method override parameter; if found, this middleware 71 | * modifies the environment settings so downstream middleware and/or the Slim 72 | * application will treat the request with the desired HTTP method. 73 | * 74 | * @return array[status, header, body] 75 | */ 76 | public function call() 77 | { 78 | $env = $this->app->environment(); 79 | if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) { 80 | // Header commonly used by Backbone.js and others 81 | $env['slim.method_override.original_method'] = $env['REQUEST_METHOD']; 82 | $env['REQUEST_METHOD'] = strtoupper($env['HTTP_X_HTTP_METHOD_OVERRIDE']); 83 | } elseif (isset($env['REQUEST_METHOD']) && $env['REQUEST_METHOD'] === 'POST') { 84 | // HTML Form Override 85 | $req = new \Slim\Http\Request($env); 86 | $method = $req->post($this->settings['key']); 87 | if ($method) { 88 | $env['slim.method_override.original_method'] = $env['REQUEST_METHOD']; 89 | $env['REQUEST_METHOD'] = strtoupper($method); 90 | } 91 | } 92 | $this->next->call(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware/PrettyExceptions.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Middleware; 34 | 35 | /** 36 | * Pretty Exceptions 37 | * 38 | * This middleware catches any Exception thrown by the surrounded 39 | * application and displays a developer-friendly diagnostic screen. 40 | * 41 | * @package Slim 42 | * @author Josh Lockhart 43 | * @since 1.0.0 44 | */ 45 | class PrettyExceptions extends \Slim\Middleware 46 | { 47 | /** 48 | * @var array 49 | */ 50 | protected $settings; 51 | 52 | /** 53 | * Constructor 54 | * @param array $settings 55 | */ 56 | public function __construct($settings = array()) 57 | { 58 | $this->settings = $settings; 59 | } 60 | 61 | /** 62 | * Call 63 | */ 64 | public function call() 65 | { 66 | try { 67 | $this->next->call(); 68 | } catch (\Exception $e) { 69 | $log = $this->app->getLog(); // Force Slim to append log to env if not already 70 | $env = $this->app->environment(); 71 | $env['slim.log'] = $log; 72 | $env['slim.log']->error($e); 73 | $this->app->contentType('text/html'); 74 | $this->app->response()->status(500); 75 | $this->app->response()->body($this->renderBody($env, $e)); 76 | } 77 | } 78 | 79 | /** 80 | * Render response body 81 | * @param array $env 82 | * @param \Exception $exception 83 | * @return string 84 | */ 85 | protected function renderBody(&$env, $exception) 86 | { 87 | $title = 'Slim Application Error'; 88 | $code = $exception->getCode(); 89 | $message = $exception->getMessage(); 90 | $file = $exception->getFile(); 91 | $line = $exception->getLine(); 92 | $trace = str_replace(array('#', '\n'), array('
#', '
'), $exception->getTraceAsString()); 93 | $html = sprintf('

%s

', $title); 94 | $html .= '

The application could not run because of the following error:

'; 95 | $html .= '

Details

'; 96 | $html .= sprintf('
Type: %s
', get_class($exception)); 97 | if ($code) { 98 | $html .= sprintf('
Code: %s
', $code); 99 | } 100 | if ($message) { 101 | $html .= sprintf('
Message: %s
', $message); 102 | } 103 | if ($file) { 104 | $html .= sprintf('
File: %s
', $file); 105 | } 106 | if ($line) { 107 | $html .= sprintf('
Line: %s
', $line); 108 | } 109 | if ($trace) { 110 | $html .= '

Trace

'; 111 | $html .= sprintf('
%s
', $trace); 112 | } 113 | 114 | return sprintf("%s%s", $title, $html); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Middleware/SessionCookie.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Middleware; 34 | 35 | /** 36 | * Session Cookie 37 | * 38 | * This class provides an HTTP cookie storage mechanism 39 | * for session data. This class avoids using a PHP session 40 | * and instead serializes/unserializes the $_SESSION global 41 | * variable to/from an HTTP cookie. 42 | * 43 | * You should NEVER store sensitive data in a client-side cookie 44 | * in any format, encrypted (with cookies.encrypt) or not. If you 45 | * need to store sensitive user information in a session, you should 46 | * rely on PHP's native session implementation, or use other middleware 47 | * to store session data in a database or alternative server-side cache. 48 | * 49 | * Because this class stores serialized session data in an HTTP cookie, 50 | * you are inherently limited to 4 Kb. If you attempt to store 51 | * more than this amount, serialization will fail. 52 | * 53 | * @package Slim 54 | * @author Josh Lockhart 55 | * @since 1.6.0 56 | */ 57 | class SessionCookie extends \Slim\Middleware 58 | { 59 | /** 60 | * @var array 61 | */ 62 | protected $settings; 63 | 64 | /** 65 | * Constructor 66 | * 67 | * @param array $settings 68 | */ 69 | public function __construct($settings = array()) 70 | { 71 | $defaults = array( 72 | 'expires' => '20 minutes', 73 | 'path' => '/', 74 | 'domain' => null, 75 | 'secure' => false, 76 | 'httponly' => false, 77 | 'name' => 'slim_session', 78 | ); 79 | $this->settings = array_merge($defaults, $settings); 80 | if (is_string($this->settings['expires'])) { 81 | $this->settings['expires'] = strtotime($this->settings['expires']); 82 | } 83 | 84 | /** 85 | * Session 86 | * 87 | * We must start a native PHP session to initialize the $_SESSION superglobal. 88 | * However, we won't be using the native session store for persistence, so we 89 | * disable the session cookie and cache limiter. We also set the session 90 | * handler to this class instance to avoid PHP's native session file locking. 91 | */ 92 | ini_set('session.use_cookies', 0); 93 | session_cache_limiter(false); 94 | session_set_save_handler( 95 | array($this, 'open'), 96 | array($this, 'close'), 97 | array($this, 'read'), 98 | array($this, 'write'), 99 | array($this, 'destroy'), 100 | array($this, 'gc') 101 | ); 102 | } 103 | 104 | /** 105 | * Call 106 | */ 107 | public function call() 108 | { 109 | $this->loadSession(); 110 | $this->next->call(); 111 | $this->saveSession(); 112 | } 113 | 114 | /** 115 | * Load session 116 | */ 117 | protected function loadSession() 118 | { 119 | if (session_id() === '') { 120 | session_start(); 121 | } 122 | 123 | $value = $this->app->getCookie($this->settings['name']); 124 | 125 | if ($value) { 126 | try { 127 | $_SESSION = unserialize($value); 128 | } catch (\Exception $e) { 129 | $this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage()); 130 | } 131 | } else { 132 | $_SESSION = array(); 133 | } 134 | } 135 | 136 | /** 137 | * Save session 138 | */ 139 | protected function saveSession() 140 | { 141 | $value = serialize($_SESSION); 142 | 143 | if (strlen($value) > 4096) { 144 | $this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.'); 145 | } else { 146 | $this->app->setCookie( 147 | $this->settings['name'], 148 | $value, 149 | $this->settings['expires'], 150 | $this->settings['path'], 151 | $this->settings['domain'], 152 | $this->settings['secure'], 153 | $this->settings['httponly'] 154 | ); 155 | } 156 | // session_destroy(); 157 | } 158 | 159 | /******************************************************************************** 160 | * Session Handler 161 | *******************************************************************************/ 162 | 163 | /** 164 | * @codeCoverageIgnore 165 | */ 166 | public function open($savePath, $sessionName) 167 | { 168 | return true; 169 | } 170 | 171 | /** 172 | * @codeCoverageIgnore 173 | */ 174 | public function close() 175 | { 176 | return true; 177 | } 178 | 179 | /** 180 | * @codeCoverageIgnore 181 | */ 182 | public function read($id) 183 | { 184 | return ''; 185 | } 186 | 187 | /** 188 | * @codeCoverageIgnore 189 | */ 190 | public function write($id, $data) 191 | { 192 | return true; 193 | } 194 | 195 | /** 196 | * @codeCoverageIgnore 197 | */ 198 | public function destroy($id) 199 | { 200 | return true; 201 | } 202 | 203 | /** 204 | * @codeCoverageIgnore 205 | */ 206 | public function gc($maxlifetime) 207 | { 208 | return true; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Route.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Route 37 | * @package Slim 38 | * @author Josh Lockhart, Thomas Bley 39 | * @since 1.0.0 40 | */ 41 | class Route 42 | { 43 | /** 44 | * @var string The route pattern (e.g. "/books/:id") 45 | */ 46 | protected $pattern; 47 | 48 | /** 49 | * @var mixed The route callable 50 | */ 51 | protected $callable; 52 | 53 | /** 54 | * @var array Conditions for this route's URL parameters 55 | */ 56 | protected $conditions = array(); 57 | 58 | /** 59 | * @var array Default conditions applied to all route instances 60 | */ 61 | protected static $defaultConditions = array(); 62 | 63 | /** 64 | * @var string The name of this route (optional) 65 | */ 66 | protected $name; 67 | 68 | /** 69 | * @var array Key-value array of URL parameters 70 | */ 71 | protected $params = array(); 72 | 73 | /** 74 | * @var array value array of URL parameter names 75 | */ 76 | protected $paramNames = array(); 77 | 78 | /** 79 | * @var array key array of URL parameter names with + at the end 80 | */ 81 | protected $paramNamesPath = array(); 82 | 83 | /** 84 | * @var array HTTP methods supported by this Route 85 | */ 86 | protected $methods = array(); 87 | 88 | /** 89 | * @var array[Callable] Middleware to be run before only this route instance 90 | */ 91 | protected $middleware = array(); 92 | 93 | /** 94 | * @var bool Whether or not this route should be matched in a case-sensitive manner 95 | */ 96 | protected $caseSensitive; 97 | 98 | /** 99 | * Constructor 100 | * @param string $pattern The URL pattern (e.g. "/books/:id") 101 | * @param mixed $callable Anything that returns TRUE for is_callable() 102 | * @param bool $caseSensitive Whether or not this route should be matched in a case-sensitive manner 103 | */ 104 | public function __construct($pattern, $callable, $caseSensitive = true) 105 | { 106 | $this->setPattern($pattern); 107 | $this->setCallable($callable); 108 | $this->setConditions(self::getDefaultConditions()); 109 | $this->caseSensitive = $caseSensitive; 110 | } 111 | 112 | /** 113 | * Set default route conditions for all instances 114 | * @param array $defaultConditions 115 | */ 116 | public static function setDefaultConditions(array $defaultConditions) 117 | { 118 | self::$defaultConditions = $defaultConditions; 119 | } 120 | 121 | /** 122 | * Get default route conditions for all instances 123 | * @return array 124 | */ 125 | public static function getDefaultConditions() 126 | { 127 | return self::$defaultConditions; 128 | } 129 | 130 | /** 131 | * Get route pattern 132 | * @return string 133 | */ 134 | public function getPattern() 135 | { 136 | return $this->pattern; 137 | } 138 | 139 | /** 140 | * Set route pattern 141 | * @param string $pattern 142 | */ 143 | public function setPattern($pattern) 144 | { 145 | $this->pattern = $pattern; 146 | } 147 | 148 | /** 149 | * Get route callable 150 | * @return mixed 151 | */ 152 | public function getCallable() 153 | { 154 | return $this->callable; 155 | } 156 | 157 | /** 158 | * Set route callable 159 | * @param mixed $callable 160 | * @throws \InvalidArgumentException If argument is not callable 161 | */ 162 | public function setCallable($callable) 163 | { 164 | $matches = array(); 165 | if (is_string($callable) && preg_match('!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!', $callable, $matches)) { 166 | $class = $matches[1]; 167 | $method = $matches[2]; 168 | $callable = function() use ($class, $method) { 169 | static $obj = null; 170 | if ($obj === null) { 171 | $obj = new $class; 172 | } 173 | return call_user_func_array(array($obj, $method), func_get_args()); 174 | }; 175 | } 176 | 177 | if (!is_callable($callable)) { 178 | throw new \InvalidArgumentException('Route callable must be callable'); 179 | } 180 | 181 | $this->callable = $callable; 182 | } 183 | 184 | /** 185 | * Get route conditions 186 | * @return array 187 | */ 188 | public function getConditions() 189 | { 190 | return $this->conditions; 191 | } 192 | 193 | /** 194 | * Set route conditions 195 | * @param array $conditions 196 | */ 197 | public function setConditions(array $conditions) 198 | { 199 | $this->conditions = $conditions; 200 | } 201 | 202 | /** 203 | * Get route name 204 | * @return string|null 205 | */ 206 | public function getName() 207 | { 208 | return $this->name; 209 | } 210 | 211 | /** 212 | * Set route name 213 | * @param string $name 214 | */ 215 | public function setName($name) 216 | { 217 | $this->name = (string)$name; 218 | } 219 | 220 | /** 221 | * Get route parameters 222 | * @return array 223 | */ 224 | public function getParams() 225 | { 226 | return $this->params; 227 | } 228 | 229 | /** 230 | * Set route parameters 231 | * @param array $params 232 | */ 233 | public function setParams($params) 234 | { 235 | $this->params = $params; 236 | } 237 | 238 | /** 239 | * Get route parameter value 240 | * @param string $index Name of URL parameter 241 | * @return string 242 | * @throws \InvalidArgumentException If route parameter does not exist at index 243 | */ 244 | public function getParam($index) 245 | { 246 | if (!isset($this->params[$index])) { 247 | throw new \InvalidArgumentException('Route parameter does not exist at specified index'); 248 | } 249 | 250 | return $this->params[$index]; 251 | } 252 | 253 | /** 254 | * Set route parameter value 255 | * @param string $index Name of URL parameter 256 | * @param mixed $value The new parameter value 257 | * @throws \InvalidArgumentException If route parameter does not exist at index 258 | */ 259 | public function setParam($index, $value) 260 | { 261 | if (!isset($this->params[$index])) { 262 | throw new \InvalidArgumentException('Route parameter does not exist at specified index'); 263 | } 264 | $this->params[$index] = $value; 265 | } 266 | 267 | /** 268 | * Add supported HTTP method(s) 269 | */ 270 | public function setHttpMethods() 271 | { 272 | $args = func_get_args(); 273 | $this->methods = $args; 274 | } 275 | 276 | /** 277 | * Get supported HTTP methods 278 | * @return array 279 | */ 280 | public function getHttpMethods() 281 | { 282 | return $this->methods; 283 | } 284 | 285 | /** 286 | * Append supported HTTP methods 287 | */ 288 | public function appendHttpMethods() 289 | { 290 | $args = func_get_args(); 291 | $this->methods = array_merge($this->methods, $args); 292 | } 293 | 294 | /** 295 | * Append supported HTTP methods (alias for Route::appendHttpMethods) 296 | * @return \Slim\Route 297 | */ 298 | public function via() 299 | { 300 | $args = func_get_args(); 301 | $this->methods = array_merge($this->methods, $args); 302 | 303 | return $this; 304 | } 305 | 306 | /** 307 | * Detect support for an HTTP method 308 | * @param string $method 309 | * @return bool 310 | */ 311 | public function supportsHttpMethod($method) 312 | { 313 | return in_array($method, $this->methods); 314 | } 315 | 316 | /** 317 | * Get middleware 318 | * @return array[Callable] 319 | */ 320 | public function getMiddleware() 321 | { 322 | return $this->middleware; 323 | } 324 | 325 | /** 326 | * Set middleware 327 | * 328 | * This method allows middleware to be assigned to a specific Route. 329 | * If the method argument `is_callable` (including callable arrays!), 330 | * we directly append the argument to `$this->middleware`. Else, we 331 | * assume the argument is an array of callables and merge the array 332 | * with `$this->middleware`. Each middleware is checked for is_callable() 333 | * and an InvalidArgumentException is thrown immediately if it isn't. 334 | * 335 | * @param Callable|array[Callable] 336 | * @return \Slim\Route 337 | * @throws \InvalidArgumentException If argument is not callable or not an array of callables. 338 | */ 339 | public function setMiddleware($middleware) 340 | { 341 | if (is_callable($middleware)) { 342 | $this->middleware[] = $middleware; 343 | } elseif (is_array($middleware)) { 344 | foreach ($middleware as $callable) { 345 | if (!is_callable($callable)) { 346 | throw new \InvalidArgumentException('All Route middleware must be callable'); 347 | } 348 | } 349 | $this->middleware = array_merge($this->middleware, $middleware); 350 | } else { 351 | throw new \InvalidArgumentException('Route middleware must be callable or an array of callables'); 352 | } 353 | 354 | return $this; 355 | } 356 | 357 | /** 358 | * Matches URI? 359 | * 360 | * Parse this route's pattern, and then compare it to an HTTP resource URI 361 | * This method was modeled after the techniques demonstrated by Dan Sosedoff at: 362 | * 363 | * http://blog.sosedoff.com/2009/09/20/rails-like-php-url-router/ 364 | * 365 | * @param string $resourceUri A Request URI 366 | * @return bool 367 | */ 368 | public function matches($resourceUri) 369 | { 370 | //Convert URL params into regex patterns, construct a regex for this route, init params 371 | $patternAsRegex = preg_replace_callback( 372 | '#:([\w]+)\+?#', 373 | array($this, 'matchesCallback'), 374 | str_replace(')', ')?', (string)$this->pattern) 375 | ); 376 | if (substr($this->pattern, -1) === '/') { 377 | $patternAsRegex .= '?'; 378 | } 379 | 380 | $regex = '#^' . $patternAsRegex . '$#'; 381 | 382 | if ($this->caseSensitive === false) { 383 | $regex .= 'i'; 384 | } 385 | 386 | //Cache URL params' names and values if this route matches the current HTTP request 387 | if (!preg_match($regex, $resourceUri, $paramValues)) { 388 | return false; 389 | } 390 | foreach ($this->paramNames as $name) { 391 | if (isset($paramValues[$name])) { 392 | if (isset($this->paramNamesPath[$name])) { 393 | $this->params[$name] = explode('/', urldecode($paramValues[$name])); 394 | } else { 395 | $this->params[$name] = urldecode($paramValues[$name]); 396 | } 397 | } 398 | } 399 | 400 | return true; 401 | } 402 | 403 | /** 404 | * Convert a URL parameter (e.g. ":id", ":id+") into a regular expression 405 | * @param array $m URL parameters 406 | * @return string Regular expression for URL parameter 407 | */ 408 | protected function matchesCallback($m) 409 | { 410 | $this->paramNames[] = $m[1]; 411 | if (isset($this->conditions[$m[1]])) { 412 | return '(?P<' . $m[1] . '>' . $this->conditions[$m[1]] . ')'; 413 | } 414 | if (substr($m[0], -1) === '+') { 415 | $this->paramNamesPath[$m[1]] = 1; 416 | 417 | return '(?P<' . $m[1] . '>.+)'; 418 | } 419 | 420 | return '(?P<' . $m[1] . '>[^/]+)'; 421 | } 422 | 423 | /** 424 | * Set route name 425 | * @param string $name The name of the route 426 | * @return \Slim\Route 427 | */ 428 | public function name($name) 429 | { 430 | $this->setName($name); 431 | 432 | return $this; 433 | } 434 | 435 | /** 436 | * Merge route conditions 437 | * @param array $conditions Key-value array of URL parameter conditions 438 | * @return \Slim\Route 439 | */ 440 | public function conditions(array $conditions) 441 | { 442 | $this->conditions = array_merge($this->conditions, $conditions); 443 | 444 | return $this; 445 | } 446 | 447 | /** 448 | * Dispatch route 449 | * 450 | * This method invokes the route object's callable. If middleware is 451 | * registered for the route, each callable middleware is invoked in 452 | * the order specified. 453 | * 454 | * @return bool 455 | */ 456 | public function dispatch() 457 | { 458 | foreach ($this->middleware as $mw) { 459 | call_user_func_array($mw, array($this)); 460 | } 461 | 462 | $return = call_user_func_array($this->getCallable(), array_values($this->getParams())); 463 | return ($return === false) ? false : true; 464 | } 465 | } 466 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/Router.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Router 37 | * 38 | * This class organizes, iterates, and dispatches \Slim\Route objects. 39 | * 40 | * @package Slim 41 | * @author Josh Lockhart 42 | * @since 1.0.0 43 | */ 44 | class Router 45 | { 46 | /** 47 | * @var Route The current route (most recently dispatched) 48 | */ 49 | protected $currentRoute; 50 | 51 | /** 52 | * @var array Lookup hash of all route objects 53 | */ 54 | protected $routes; 55 | 56 | /** 57 | * @var array Lookup hash of named route objects, keyed by route name (lazy-loaded) 58 | */ 59 | protected $namedRoutes; 60 | 61 | /** 62 | * @var array Array of route objects that match the request URI (lazy-loaded) 63 | */ 64 | protected $matchedRoutes; 65 | 66 | /** 67 | * @var array Array containing all route groups 68 | */ 69 | protected $routeGroups; 70 | 71 | /** 72 | * Constructor 73 | */ 74 | public function __construct() 75 | { 76 | $this->routes = array(); 77 | $this->routeGroups = array(); 78 | } 79 | 80 | /** 81 | * Get Current Route object or the first matched one if matching has been performed 82 | * @return \Slim\Route|null 83 | */ 84 | public function getCurrentRoute() 85 | { 86 | if ($this->currentRoute !== null) { 87 | return $this->currentRoute; 88 | } 89 | 90 | if (is_array($this->matchedRoutes) && count($this->matchedRoutes) > 0) { 91 | return $this->matchedRoutes[0]; 92 | } 93 | 94 | return null; 95 | } 96 | 97 | /** 98 | * Return route objects that match the given HTTP method and URI 99 | * @param string $httpMethod The HTTP method to match against 100 | * @param string $resourceUri The resource URI to match against 101 | * @param bool $reload Should matching routes be re-parsed? 102 | * @return array[\Slim\Route] 103 | */ 104 | public function getMatchedRoutes($httpMethod, $resourceUri, $reload = false) 105 | { 106 | if ($reload || is_null($this->matchedRoutes)) { 107 | $this->matchedRoutes = array(); 108 | foreach ($this->routes as $route) { 109 | if (!$route->supportsHttpMethod($httpMethod) && !$route->supportsHttpMethod("ANY")) { 110 | continue; 111 | } 112 | 113 | if ($route->matches($resourceUri)) { 114 | $this->matchedRoutes[] = $route; 115 | } 116 | } 117 | } 118 | 119 | return $this->matchedRoutes; 120 | } 121 | 122 | /** 123 | * Add a route object to the router 124 | * @param \Slim\Route $route The Slim Route 125 | */ 126 | public function map(\Slim\Route $route) 127 | { 128 | list($groupPattern, $groupMiddleware) = $this->processGroups(); 129 | 130 | $route->setPattern($groupPattern . $route->getPattern()); 131 | $this->routes[] = $route; 132 | 133 | 134 | foreach ($groupMiddleware as $middleware) { 135 | $route->setMiddleware($middleware); 136 | } 137 | } 138 | 139 | /** 140 | * A helper function for processing the group's pattern and middleware 141 | * @return array Returns an array with the elements: pattern, middlewareArr 142 | */ 143 | protected function processGroups() 144 | { 145 | $pattern = ""; 146 | $middleware = array(); 147 | foreach ($this->routeGroups as $group) { 148 | $k = key($group); 149 | $pattern .= $k; 150 | if (is_array($group[$k])) { 151 | $middleware = array_merge($middleware, $group[$k]); 152 | } 153 | } 154 | return array($pattern, $middleware); 155 | } 156 | 157 | /** 158 | * Add a route group to the array 159 | * @param string $group The group pattern (ie. "/books/:id") 160 | * @param array|null $middleware Optional parameter array of middleware 161 | * @return int The index of the new group 162 | */ 163 | public function pushGroup($group, $middleware = array()) 164 | { 165 | return array_push($this->routeGroups, array($group => $middleware)); 166 | } 167 | 168 | /** 169 | * Removes the last route group from the array 170 | * @return bool True if successful, else False 171 | */ 172 | public function popGroup() 173 | { 174 | return (array_pop($this->routeGroups) !== null); 175 | } 176 | 177 | /** 178 | * Get URL for named route 179 | * @param string $name The name of the route 180 | * @param array $params Associative array of URL parameter names and replacement values 181 | * @throws \RuntimeException If named route not found 182 | * @return string The URL for the given route populated with provided replacement values 183 | */ 184 | public function urlFor($name, $params = array()) 185 | { 186 | if (!$this->hasNamedRoute($name)) { 187 | throw new \RuntimeException('Named route not found for name: ' . $name); 188 | } 189 | $search = array(); 190 | foreach ($params as $key => $value) { 191 | $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#'; 192 | } 193 | $pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern()); 194 | 195 | //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters 196 | return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern); 197 | } 198 | 199 | /** 200 | * Add named route 201 | * @param string $name The route name 202 | * @param \Slim\Route $route The route object 203 | * @throws \RuntimeException If a named route already exists with the same name 204 | */ 205 | public function addNamedRoute($name, \Slim\Route $route) 206 | { 207 | if ($this->hasNamedRoute($name)) { 208 | throw new \RuntimeException('Named route already exists with name: ' . $name); 209 | } 210 | $this->namedRoutes[(string) $name] = $route; 211 | } 212 | 213 | /** 214 | * Has named route 215 | * @param string $name The route name 216 | * @return bool 217 | */ 218 | public function hasNamedRoute($name) 219 | { 220 | $this->getNamedRoutes(); 221 | 222 | return isset($this->namedRoutes[(string) $name]); 223 | } 224 | 225 | /** 226 | * Get named route 227 | * @param string $name 228 | * @return \Slim\Route|null 229 | */ 230 | public function getNamedRoute($name) 231 | { 232 | $this->getNamedRoutes(); 233 | if ($this->hasNamedRoute($name)) { 234 | return $this->namedRoutes[(string) $name]; 235 | } else { 236 | return null; 237 | } 238 | } 239 | 240 | /** 241 | * Get named routes 242 | * @return \ArrayIterator 243 | */ 244 | public function getNamedRoutes() 245 | { 246 | if (is_null($this->namedRoutes)) { 247 | $this->namedRoutes = array(); 248 | foreach ($this->routes as $route) { 249 | if ($route->getName() !== null) { 250 | $this->addNamedRoute($route->getName(), $route); 251 | } 252 | } 253 | } 254 | 255 | return new \ArrayIterator($this->namedRoutes); 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/Slim/View.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.4.2 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * View 37 | * 38 | * The view is responsible for rendering a template. The view 39 | * should subclass \Slim\View and implement this interface: 40 | * 41 | * public render(string $template); 42 | * 43 | * This method should render the specified template and return 44 | * the resultant string. 45 | * 46 | * @package Slim 47 | * @author Josh Lockhart 48 | * @since 1.0.0 49 | */ 50 | class View 51 | { 52 | /** 53 | * Data available to the view templates 54 | * @var \Slim\Helper\Set 55 | */ 56 | protected $data; 57 | 58 | /** 59 | * Path to templates base directory (without trailing slash) 60 | * @var string 61 | */ 62 | protected $templatesDirectory; 63 | 64 | /** 65 | * Constructor 66 | */ 67 | public function __construct() 68 | { 69 | $this->data = new \Slim\Helper\Set(); 70 | } 71 | 72 | /******************************************************************************** 73 | * Data methods 74 | *******************************************************************************/ 75 | 76 | /** 77 | * Does view data have value with key? 78 | * @param string $key 79 | * @return boolean 80 | */ 81 | public function has($key) 82 | { 83 | return $this->data->has($key); 84 | } 85 | 86 | /** 87 | * Return view data value with key 88 | * @param string $key 89 | * @return mixed 90 | */ 91 | public function get($key) 92 | { 93 | return $this->data->get($key); 94 | } 95 | 96 | /** 97 | * Set view data value with key 98 | * @param string $key 99 | * @param mixed $value 100 | */ 101 | public function set($key, $value) 102 | { 103 | $this->data->set($key, $value); 104 | } 105 | 106 | /** 107 | * Set view data value as Closure with key 108 | * @param string $key 109 | * @param mixed $value 110 | */ 111 | public function keep($key, \Closure $value) 112 | { 113 | $this->data->keep($key, $value); 114 | } 115 | 116 | /** 117 | * Return view data 118 | * @return array 119 | */ 120 | public function all() 121 | { 122 | return $this->data->all(); 123 | } 124 | 125 | /** 126 | * Replace view data 127 | * @param array $data 128 | */ 129 | public function replace(array $data) 130 | { 131 | $this->data->replace($data); 132 | } 133 | 134 | /** 135 | * Clear view data 136 | */ 137 | public function clear() 138 | { 139 | $this->data->clear(); 140 | } 141 | 142 | /******************************************************************************** 143 | * Legacy data methods 144 | *******************************************************************************/ 145 | 146 | /** 147 | * DEPRECATION WARNING! This method will be removed in the next major point release 148 | * 149 | * Get data from view 150 | */ 151 | public function getData($key = null) 152 | { 153 | if (!is_null($key)) { 154 | return isset($this->data[$key]) ? $this->data[$key] : null; 155 | } else { 156 | return $this->data->all(); 157 | } 158 | } 159 | 160 | /** 161 | * DEPRECATION WARNING! This method will be removed in the next major point release 162 | * 163 | * Set data for view 164 | */ 165 | public function setData() 166 | { 167 | $args = func_get_args(); 168 | if (count($args) === 1 && is_array($args[0])) { 169 | $this->data->replace($args[0]); 170 | } elseif (count($args) === 2) { 171 | // Ensure original behavior is maintained. DO NOT invoke stored Closures. 172 | if (is_object($args[1]) && method_exists($args[1], '__invoke')) { 173 | $this->data->set($args[0], $this->data->protect($args[1])); 174 | } else { 175 | $this->data->set($args[0], $args[1]); 176 | } 177 | } else { 178 | throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); 179 | } 180 | } 181 | 182 | /** 183 | * DEPRECATION WARNING! This method will be removed in the next major point release 184 | * 185 | * Append data to view 186 | * @param array $data 187 | */ 188 | public function appendData($data) 189 | { 190 | if (!is_array($data)) { 191 | throw new \InvalidArgumentException('Cannot append view data. Expected array argument.'); 192 | } 193 | $this->data->replace($data); 194 | } 195 | 196 | /******************************************************************************** 197 | * Resolve template paths 198 | *******************************************************************************/ 199 | 200 | /** 201 | * Set the base directory that contains view templates 202 | * @param string $directory 203 | * @throws \InvalidArgumentException If directory is not a directory 204 | */ 205 | public function setTemplatesDirectory($directory) 206 | { 207 | $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR); 208 | } 209 | 210 | /** 211 | * Get templates base directory 212 | * @return string 213 | */ 214 | public function getTemplatesDirectory() 215 | { 216 | return $this->templatesDirectory; 217 | } 218 | 219 | /** 220 | * Get fully qualified path to template file using templates base directory 221 | * @param string $file The template file pathname relative to templates base directory 222 | * @return string 223 | */ 224 | public function getTemplatePathname($file) 225 | { 226 | return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR); 227 | } 228 | 229 | /******************************************************************************** 230 | * Rendering 231 | *******************************************************************************/ 232 | 233 | /** 234 | * Display template 235 | * 236 | * This method echoes the rendered template to the current output buffer 237 | * 238 | * @param string $template Pathname of template file relative to templates directory 239 | * @param array $data Any additonal data to be passed to the template. 240 | */ 241 | public function display($template, $data = null) 242 | { 243 | echo $this->fetch($template, $data); 244 | } 245 | 246 | /** 247 | * Return the contents of a rendered template file 248 | * 249 | * @param string $template The template pathname, relative to the template base directory 250 | * @param array $data Any additonal data to be passed to the template. 251 | * @return string The rendered template 252 | */ 253 | public function fetch($template, $data = null) 254 | { 255 | return $this->render($template, $data); 256 | } 257 | 258 | /** 259 | * Render a template file 260 | * 261 | * NOTE: This method should be overridden by custom view subclasses 262 | * 263 | * @param string $template The template pathname, relative to the template base directory 264 | * @param array $data Any additonal data to be passed to the template. 265 | * @return string The rendered template 266 | * @throws \RuntimeException If resolved template pathname is not a valid file 267 | */ 268 | protected function render($template, $data = null) 269 | { 270 | $templatePathname = $this->getTemplatePathname($template); 271 | if (!is_file($templatePathname)) { 272 | throw new \RuntimeException("View cannot render `$template` because the template does not exist"); 273 | } 274 | 275 | $data = array_merge($this->data->all(), (array) $data); 276 | extract($data); 277 | ob_start(); 278 | require $templatePathname; 279 | 280 | return ob_get_clean(); 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/assets/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-wifidog/files/root/www/wifidog/assets/loader.gif -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.eot -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2014 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.ttf -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/luci-app-wifidog/files/root/www/wifidog/assets/ratchicons.woff -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/index.php: -------------------------------------------------------------------------------- 1 | gwAddress = trim(shell_exec('uci get wifidog.settings.gateway_host')); 8 | $app->gwPort = trim(shell_exec('uci get wifidog.settings.gatewayport')); 9 | $app->gwName = trim(shell_exec('uci get wifidog.settings.gateway_hostname')); 10 | $app->timeLimit = trim(shell_exec('uci get wifidog.settings.client_time_limit')); 11 | $app->gwMac = preg_replace('/(.+)HWaddr (.+)/i', '${2}', trim(shell_exec('ifconfig br-lan | grep HWaddr'))); 12 | $app->gwId = str_replace(':', '', $app->gwMac); 13 | 14 | $app->get('/hello/:name', function ($name) use ($app) { 15 | echo "Hello, ".$name."
"; 16 | }); 17 | 18 | $app->get('/login', function () use ($app) { 19 | $db = $app->dao; 20 | parse_str($app->environment['QUERY_STRING']); 21 | $isReturnUser = $app->getCookie('is_return_user'); 22 | // $user = $db->query("SELECT * FROM users WHERE mac = '{$mac}'"); 23 | 24 | if(!$isReturnUser) { 25 | // echo 'mac was not found.'; 26 | $app->render('touch.php', array('mac' => $mac, 'title' => $app->gwName)); 27 | } 28 | else { 29 | $app->render('touch.php', array('title' => $app->gwName)); 30 | } 31 | 32 | $db = null; 33 | }); 34 | 35 | $app->post('/users', function() use ($app) { 36 | $db = $app->dao; 37 | $params = $app->request->post(); 38 | $user = $db->query("SELECT * FROM users WHERE phone = '{$params['phone']}'")->fetch(); 39 | 40 | if(!$user) { 41 | $db->exec("INSERT INTO users (phone, mac) 42 | VALUES ('{$params['phone']}', '{$params['mac']}')"); 43 | } 44 | else { 45 | $db->exec("UPDATE users SET mac = '{$params['mac']}', updated_at = datetime('now', 'localtime') WHERE id = {$user['id']}"); 46 | } 47 | 48 | $db = null; 49 | $app->setCookie('is_return_user', true, '365 days'); 50 | $app->halt(200, '{ "error": "" }'); 51 | }); 52 | 53 | $app->get('/portal', function() use ($app) { 54 | $app->render('show.php', array('title' => $app->gwName, 'id' => $app->gwId)); 55 | }); 56 | 57 | $app->get('/portal/touch', function() use ($app) { 58 | $db = $app->dao; 59 | $uuid = $app->uuid; 60 | $id = $app->uuid; 61 | $offset = $app->timeLimit; 62 | $db->exec("INSERT INTO connections (id, token, expires_on) 63 | VALUES ('{$id}', '{$uuid}', datetime(datetime('now','localtime'), '+{$offset} minutes'))"); 64 | $db = null; 65 | $app->redirect("http://{$app->gwAddress}:{$app->gwPort}/wifidog/auth?token={$uuid}"); 66 | }); 67 | 68 | $app->get('/ping', function () use ($app) { 69 | $db = $app->dao; 70 | parse_str($app->environment['QUERY_STRING']); 71 | $db->exec("UPDATE gateways SET sys_uptime = {$sys_uptime}, sys_load = {$sys_load}, sys_memfree = {$sys_memfree}, wifidog_uptime = {$wifidog_uptime}, last_seen = datetime('now','localtime'), updated_at = datetime('now','localtime') WHERE id = 1"); 72 | $db = null; 73 | $app->halt(200, 'Pong'); 74 | }); 75 | 76 | $app->get('/auth', function () use ($app) { 77 | $auth = 0; 78 | $db = $app->dao; 79 | parse_str($app->environment['QUERY_STRING']); 80 | $connection = $db->query("SELECT * FROM connections WHERE token = '{$token}'")->fetch(); 81 | 82 | if (!$connection) { 83 | $auth = 6; 84 | } 85 | else { 86 | switch ($stage) { 87 | case 'login': 88 | $expires_on = $connection['expires_on']; 89 | echo (strtotime($expires_on) < strtotime('now')); 90 | 91 | if ($connection['used_on'] != '' || ($expires_on != '' && strtotime($expires_on) < strtotime('now'))) { 92 | // Tried to login with used or expired token 93 | $auth = 6; 94 | } else { 95 | # Login normal 96 | $db->exec("UPDATE connections SET used_on = datetime('now', 'localtime'), updated_at = datetime('now', 'localtime') WHERE id = '{$connection['id']}'"); 97 | $auth = 1; 98 | } 99 | 100 | break; 101 | 102 | case 'counters': 103 | $expires_on = $connection['expires_on']; 104 | 105 | if ($expires_on == '' || strtotime($expires_on) > strtotime('now')) { 106 | $db->exec("UPDATE connections SET ip = '{$ip}', mac = '{$mac}', incoming_bytes = {$incoming}, outgoing_bytes = {$outgoing}, updated_at = datetime('now', 'localtime') WHERE id = '{$connection['id']}'"); 107 | $auth = 1; 108 | } 109 | 110 | break; 111 | 112 | case 'logout': 113 | $db->exec("UPDATE connections SET expires_on = datetime('now', 'localtime'), updated_at = datetime('now', 'localtime') WHERE id = '{$connection['id']}'"); 114 | break; 115 | 116 | default: 117 | # code... 118 | break; 119 | } 120 | } 121 | 122 | $db = null; 123 | $app->halt(200, "Auth: {$auth}"); 124 | }); 125 | 126 | $app->get('/cnzz/:id', function ($id) use ($app) { 127 | $app->render('701.html'); 128 | }); 129 | 130 | $app->get('/info', function () use ($app) { 131 | phpinfo(); 132 | }); 133 | 134 | $app->get('/list_images', function () use ($app) { 135 | if ($handle = opendir('./assets/ads')) { 136 | 137 | while (false !== ($entry = readdir($handle))) { 138 | 139 | if ($entry != "." && $entry != "..") { 140 | 141 | echo "$entry\n"; 142 | } 143 | } 144 | 145 | closedir($handle); 146 | } 147 | }); 148 | 149 | $app->dao = function () use ($app) { 150 | $db = null; 151 | 152 | try { 153 | $db = new PDO('sqlite:/tmp/wifidog.sqlite3'); 154 | //$db->setAttribute(PDO::ATTR_ERRMODE, 155 | // PDO::ERRMODE_EXCEPTION); 156 | $result = $db->query('SELECT * FROM gateways'); 157 | 158 | if(!$result) { 159 | // echo "gateways was not existed."; 160 | $db->exec("CREATE TABLE IF NOT EXISTS gateways ( 161 | id INTEGER PRIMARY KEY, 162 | sys_uptime INTEGER DEFAULT 0, 163 | sys_load INTEGER DEFAULT 0, 164 | sys_memfree INTEGER DEFAULT 0, 165 | wifidog_uptime INTEGER DEFAULT 0, 166 | last_seen DATETIME, 167 | created_at DATETIME DEFAULT (datetime('now','localtime')), 168 | updated_at DATETIME DEFAULT (datetime('now','localtime')))"); 169 | 170 | $db->exec("CREATE TABLE IF NOT EXISTS connections ( 171 | id VARCHAR(255) PRIMARY KEY, 172 | token VARCHAR(255), 173 | expires_on DATETIME, 174 | used_on DATETIME, 175 | ip VARCHAR(255), 176 | mac VARCHAR(255), 177 | incoming_bytes INTEGER DEFAULT 0, 178 | outgoing_bytes INTEGER DEFAULT 0, 179 | created_at DATETIME DEFAULT (datetime('now','localtime')), 180 | updated_at DATETIME DEFAULT (datetime('now','localtime')))"); 181 | 182 | $db->exec("CREATE TABLE IF NOT EXISTS users ( 183 | id INTEGER PRIMARY KEY AUTOINCREMENT, 184 | mac VARCHAR(255), 185 | phone VARCHAR(255), 186 | created_at DATETIME DEFAULT (datetime('now','localtime')), 187 | updated_at DATETIME DEFAULT (datetime('now','localtime')))"); 188 | 189 | $db->exec("INSERT INTO gateways (id) VALUES (1)"); 190 | } 191 | //var_dump($result); 192 | //echo count($result); 193 | } 194 | catch(PDOException $e) { 195 | echo $e->getMessage(); 196 | $db = null; 197 | } 198 | 199 | return $db; 200 | }; 201 | $app->uuid = function() { 202 | return exec('uuidgen'); 203 | }; 204 | 205 | $app->run(); -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/jobs/sync.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php-cli -q 2 | find('pre') as $element) { 8 | // echo $element->innertext; 9 | // } 10 | $db = new PDO('sqlite:/tmp/wifidog.sqlite3'); 11 | $gwMac = preg_replace('/(.+)HWaddr (.+)/i', '${2}', trim(shell_exec('ifconfig br-lan | grep HWaddr'))); 12 | $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 13 | $db->exec("UPDATE connections SET expires_on = datetime('now', 'localtime'), updated_at = datetime('now', 'localtime') WHERE used_on is not null and updated_at <= datetime(datetime('now','localtime'), '-5 minutes') and expires_on > datetime('now', 'localtime')"); 14 | $gateway = $db->query("SELECT * FROM gateways WHERE id = '1'")->fetch(PDO::FETCH_ASSOC); 15 | $users = $db->query("SELECT * FROM users WHERE updated_at > datetime(datetime('now','localtime'), '-5 minutes')")->fetchAll(PDO::FETCH_ASSOC); 16 | $connections = $db->query("SELECT * FROM connections WHERE used_on is not null and updated_at > datetime(datetime('now','localtime'), '-5 minutes')")->fetchAll(PDO::FETCH_ASSOC); 17 | $data = array('gw_id' => $gwMac, 'gateway' => $gateway, 'users' => $users, 'connections' => $connections); 18 | $data_string = json_encode($data); 19 | $db = null; 20 | // echo $data_string; 21 | 22 | $ch = curl_init('http://392a21d6.ngrok.com/portal/sync.json'); 23 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 24 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 26 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( 27 | 'Content-Type: application/json', 28 | 'Content-Length: ' . strlen($data_string)) 29 | ); 30 | 31 | $result = curl_exec($ch); 32 | // var_dump($result); 33 | $response = curl_getinfo( $ch ); 34 | // var_dump($response); 35 | curl_close ( $ch ); 36 | ?> -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/templates/701.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

The page you were looking for doesn't exist.

13 |

You may have mistyped the address or the page may have moved.

14 |
15 |

If you are the application owner check the logs for more information.

16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/templates/show.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <?= $title ?> 10 | 11 | 12 | 13 | 14 | 15 |
16 |

17 |
18 | 20 |
21 | 24 |
    25 |
  • 26 |
    正在连接免费Wi-Fi网络, 27 |
    秒后点击完成上网
    28 |
  • 29 |
30 |
31 |
32 |
Loader 33 |
34 |
35 |
    36 |
  • 37 |
38 |
39 |
40 | 60 | 65 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /luci-app-wifidog/files/root/www/wifidog/templates/touch.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <?= $title ?> 10 | 11 | 12 | 13 | 14 | 15 |
16 |

17 |
18 |
19 |
20 |
21 |
22 | 23 |
24 |
25 | 26 |
27 |
28 |
    29 |
  • 30 |
31 |
32 | 33 |
34 |
35 | 36 |
37 |
    38 |
  • 39 |

    为了向您提供安全可靠的免费Wi-Fi服务,用户首次使用需获取手机短信验证码注册

  • 40 |
  • 41 | 42 | 43 |
  • 44 |
  • 45 | 47 |
    48 |
    49 |
    50 |
  • 51 |
52 |
53 |
54 | 55 |
56 | 57 |
    58 |
  • 59 |

    欢迎您再次使用万罗热点,享受免费Wi-Fi服务

    60 |
  • 61 |
  • 62 | 64 |
    65 |
    66 |
    67 |
  • 68 |
69 |
70 | 71 |
72 | 73 |
74 | 89 | 91 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /radvd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2006-2012 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=radvd 11 | PKG_VERSION:=1.9.1 12 | PKG_RELEASE:=2 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_URL:=http://v6web.litech.org/radvd/dist \ 16 | http://download.sourcemage.org/mirror 17 | PKG_MD5SUM:=e807ad7e9a76d46b6133df391385cd31 18 | 19 | PKG_INSTALL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | 23 | define Package/radvd/Default 24 | SECTION:=net 25 | CATEGORY:=Network 26 | TITLE:=IPv6 Routing Advertisement 27 | URL:=http://v6web.litech.org/radvd/ 28 | DEPENDS:=+kmod-ipv6 +libdaemon 29 | endef 30 | 31 | define Package/radvd 32 | $(call Package/radvd/Default) 33 | TITLE+= Daemon 34 | endef 35 | 36 | define Package/radvd/description 37 | radvd is the router advertisement daemon for IPv6. It listens to router 38 | solicitations and sends router advertisements as described in "Neighbor 39 | Discovery for IP Version 6 (IPv6)" (RFC 4861). With these advertisements hosts 40 | can automatically configure their addresses and some other parameters. They also 41 | can choose a default router based on these advertisements. 42 | endef 43 | 44 | define Package/radvdump 45 | $(call Package/radvd/Default) 46 | TITLE+= Dumper 47 | endef 48 | 49 | define Package/radvdump/description 50 | radvdump prints out the contents of incoming router advertisements sent by radvd 51 | or some other software implementing (parts of) "Neighbor Discovery for IP 52 | Version 6 (IPv6)" (RFC 4861). 53 | endef 54 | 55 | CONFIGURE_ARGS += \ 56 | --with-configfile=/etc/radvd.conf \ 57 | --with-logfile=/var/log/radvd.log \ 58 | --with-pidfile=/var/run/radvd.pid 59 | 60 | define Package/radvd/conffiles 61 | /etc/config/radvd 62 | endef 63 | 64 | define Package/radvd/install 65 | $(INSTALL_DIR) $(1)/etc/config 66 | $(INSTALL_CONF) ./files/radvd.config $(1)/etc/config/radvd 67 | $(INSTALL_DIR) $(1)/etc/init.d 68 | $(INSTALL_BIN) ./files/radvd.init $(1)/etc/init.d/radvd 69 | $(INSTALL_DIR) $(1)/usr/sbin 70 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/radvd $(1)/usr/sbin/ 71 | endef 72 | 73 | define Package/radvdump/install 74 | $(INSTALL_DIR) $(1)/usr/sbin 75 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/radvdump $(1)/usr/sbin/ 76 | endef 77 | 78 | $(eval $(call BuildPackage,radvd)) 79 | $(eval $(call BuildPackage,radvdump)) 80 | -------------------------------------------------------------------------------- /radvd/files/radvd.config: -------------------------------------------------------------------------------- 1 | config interface 2 | option interface 'lan' 3 | option AdvSendAdvert 1 4 | option AdvManagedFlag 0 5 | option AdvOtherConfigFlag 0 6 | list client '' 7 | option ignore 1 8 | 9 | config prefix 10 | option interface 'lan' 11 | # If not specified, a non-link-local prefix of the interface is used 12 | list prefix '' 13 | option AdvOnLink 1 14 | option AdvAutonomous 1 15 | option AdvRouterAddr 0 16 | option ignore 1 17 | 18 | config route 19 | option interface 'lan' 20 | list prefix '' 21 | option ignore 1 22 | 23 | config rdnss 24 | option interface 'lan' 25 | # If not specified, the link-local address of the interface is used 26 | list addr '' 27 | option ignore 1 28 | 29 | config dnssl 30 | option interface 'lan' 31 | list suffix '' 32 | option ignore 1 33 | -------------------------------------------------------------------------------- /radvd/files/radvd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2008-2011 OpenWrt.org 3 | # Copyright (C) 2008 Alina Friedrichsen 4 | 5 | START=50 6 | 7 | SERVICE_USE_PID=1 8 | 9 | RADVD_INTERFACE_STRING_OPTIONS='MaxRtrAdvInterval MinRtrAdvInterval MinDelayBetweenRAs AdvLinkMTU AdvReachableTime AdvRetransTimer AdvCurHopLimit AdvDefaultLifetime AdvDefaultPreference HomeAgentLifetime HomeAgentPreference' 10 | RADVD_INTERFACE_BOOLEAN_OPTIONS='IgnoreIfMissing AdvSendAdvert UnicastOnly AdvManagedFlag AdvOtherConfigFlag AdvSourceLLAddress AdvHomeAgentFlag AdvHomeAgentInfo AdvMobRtrSupportFlag AdvIntervalOpt' 11 | 12 | RADVD_PREFIX_STRING_OPTIONS='AdvValidLifetime AdvPreferredLifetime' 13 | RADVD_PREFIX_BOOLEAN_OPTIONS='AdvOnLink AdvAutonomous AdvRouterAddr DeprecatePrefix DecrementLifetimes' 14 | 15 | RADVD_ROUTE_STRING_OPTIONS='AdvRouteLifetime AdvRoutePreference' 16 | RADVD_ROUTE_BOOLEAN_OPTIONS='RemoveRoute' 17 | 18 | RADVD_RDNSS_STRING_OPTIONS='AdvRDNSSLifetime FlushRDNSS' 19 | 20 | RADVD_DNSSL_STRING_OPTIONS='AdvDNSSLLifetime FlushDNSSL' 21 | 22 | validate_varname() { 23 | local varname=$1 24 | [ -z "$varname" -o "$varname" != "${varname%%[!A-Za-z0-9_]*}" ] && return 1 25 | return 0 26 | } 27 | 28 | validate_ip6addr() { 29 | local ip6addr=$1 30 | [ -z "$ip6addr" -o "$ip6addr" != "${ip6addr%%[!A-Fa-f0-9.:]*}" ] && return 1 31 | return 0 32 | } 33 | 34 | validate_ip6prefix() { 35 | local ip6prefix=$1 36 | [ -z "$ip6prefix" -o "$ip6prefix" != "${ip6prefix%%[!A-Fa-f0-9./:]*}" ] && return 1 37 | return 0 38 | } 39 | 40 | validate_radvd_string() { 41 | local radvd_string=$1 42 | [ -z "$radvd_string" -o "$radvd_string" != "${radvd_string%%[!A-Za-z0-9.:_-]*}" ] && return 1 43 | return 0 44 | } 45 | 46 | get_ip6addr() { 47 | local ifname=$1 48 | local scope=$2 49 | local iproute2_scope 50 | local ifconfig_scope 51 | local ip6addr 52 | 53 | case "$scope" in 54 | host) iproute2_scope=host ifconfig_scope=Host;; 55 | link) iproute2_scope=link ifconfig_scope=Link;; 56 | site) iproute2_scope=site ifconfig_scope=Site;; 57 | global) iproute2_scope=global ifconfig_scope=Global;; 58 | "") get_ip6addr "$ifname" global || get_ip6addr "$ifname" site; return;; 59 | *) return 1;; 60 | esac 61 | 62 | ip6addr=$(LANG=C ip -f inet6 -- addr show dev "$ifname" 2> /dev/null | sed -n -e 's/^ *inet6 \([A-Fa-f0-9.:]*[/][0-9]*\) scope '"$iproute2_scope"' $/\1/p' | head -n 1) 63 | if [ -z "$ip6addr" ]; then 64 | ip6addr=$(LANG=C ifconfig "$ifname" 2> /dev/null | sed -n -e 's/^ *inet6 addr: \([A-Fa-f0-9.:]*[/][0-9]*\) Scope:'"$ifconfig_scope"'$/\1/p' | tail -n 1) 65 | [ -z "$ip6addr" ] && return 1 66 | fi 67 | 68 | printf '%s\n' "$ip6addr" 69 | 70 | return 0 71 | } 72 | 73 | radvd_find_config_file() { 74 | local cfg=$1 75 | validate_varname "$cfg" || return 0 76 | 77 | config_get_bool ignore "$cfg" ignore 0 78 | [ "$ignore" -ne 0 ] && return 0 79 | config_get RADVD_CONFIG_FILE "$cfg" config_file 80 | 81 | return 0 82 | } 83 | 84 | radvd_add_interface() { 85 | local cfg=$1 86 | validate_varname "$cfg" || return 0 87 | local ignore 88 | local interfaces 89 | local interface 90 | local list_interface 91 | local exist 92 | 93 | config_get_bool ignore "$cfg" ignore 0 94 | [ "$ignore" -ne 0 ] && return 0 95 | 96 | config_get interfaces "$cfg" interface 97 | for interface in $interfaces; do 98 | validate_varname "$interface" || continue 99 | exist=0 100 | for list_interface in $RADVD_INTERFACES; do 101 | [ "$interface" = "$list_interface" ] && exist=1 102 | done 103 | [ "$exist" -eq 0 ] && RADVD_INTERFACES="$RADVD_INTERFACES $interface" 104 | done 105 | 106 | return 0 107 | } 108 | 109 | radvd_write_interface() { 110 | local cfg=$1 111 | validate_varname "$cfg" || return 0 112 | local ignore 113 | local interfaces 114 | local interface 115 | local name 116 | local value 117 | 118 | config_get_bool ignore "$cfg" ignore 0 119 | [ "$ignore" -ne 0 ] && return 0 120 | 121 | config_get interfaces "$cfg" interface 122 | exist=0 123 | for interface in $interfaces; do 124 | [ "$INTERFACE" = "$interface" ] && exist=1 125 | done 126 | [ "$exist" -eq 0 ] && return 0 127 | 128 | for name in $RADVD_INTERFACE_STRING_OPTIONS; do 129 | config_get value "$cfg" "$name" 130 | validate_radvd_string "$value" || continue 131 | printf '\t%s %s;\n' "$name" "$value" 132 | done 133 | 134 | for name in $RADVD_INTERFACE_BOOLEAN_OPTIONS; do 135 | config_get value "$cfg" "$name" 136 | [ -z "$value" ] && continue 137 | config_get_bool value "$cfg" "$name" 0 138 | if [ "$value" -ne 0 ]; then 139 | printf '\t%s on;\n' "$name" 140 | else 141 | printf '\t%s off;\n' "$name" 142 | fi 143 | done 144 | 145 | config_get clients "$cfg" client 146 | if [ -n "$clients" ]; then 147 | printf '\n\tclients\n\t{\n' 148 | 149 | for client in $clients; do 150 | validate_ip6addr "$client" || continue 151 | printf '\t\t%s;\n' "$client" 152 | done 153 | 154 | printf '\t};\n' 155 | fi 156 | 157 | return 0 158 | } 159 | 160 | radvd_write_prefix() { 161 | local cfg=$1 162 | validate_varname "$cfg" || return 0 163 | local ignore 164 | local interfaces 165 | local interface 166 | local device 167 | local prefixes 168 | local prefix 169 | local name 170 | local value 171 | local cfgt 172 | 173 | config_get_bool ignore "$cfg" ignore 0 174 | [ "$ignore" -ne 0 ] && return 0 175 | 176 | config_get interfaces "$cfg" interface 177 | exist=0 178 | for interface in $interfaces; do 179 | [ "$INTERFACE" = "$interface" ] && exist=1 180 | done 181 | [ "$exist" -eq 0 ] && return 0 182 | 183 | config_get prefixes "$cfg" prefix 184 | if [ -z "$prefixes" ]; then 185 | prefixes=$(get_ip6addr "$IFNAME") || return 0 186 | fi 187 | 188 | for prefix in $prefixes; do 189 | validate_ip6prefix "$prefix" || continue 190 | printf '\n\tprefix %s\n\t{\n' "$prefix" 191 | 192 | for name in $RADVD_PREFIX_STRING_OPTIONS; do 193 | config_get value "$cfg" "$name" 194 | validate_radvd_string "$value" || continue 195 | printf '\t\t%s %s;\n' "$name" "$value" 196 | done 197 | 198 | for name in $RADVD_PREFIX_BOOLEAN_OPTIONS; do 199 | config_get value "$cfg" "$name" 200 | [ -z "$value" ] && continue 201 | config_get_bool value "$cfg" "$name" 0 202 | if [ "$value" -ne 0 ]; then 203 | printf '\t\t%s on;\n' "$name" 204 | else 205 | printf '\t\t%s off;\n' "$name" 206 | fi 207 | done 208 | 209 | config_get value "$cfg" Base6Interface 210 | if [ -n "$value" ]; then 211 | if network_get_device device "$value"; then 212 | printf '\t\t%s %s;\n' "Base6Interface" "$device" 213 | fi 214 | fi 215 | 216 | config_get value "$cfg" Base6to4Interface 217 | if [ -n "$value" ]; then 218 | if network_get_device device "$value"; then 219 | printf '\t\t%s %s;\n' "Base6to4Interface" "$device" 220 | fi 221 | fi 222 | 223 | printf '\t};\n' 224 | done 225 | 226 | return 0 227 | } 228 | 229 | radvd_write_route() { 230 | local cfg=$1 231 | validate_varname "$cfg" || return 0 232 | local ignore 233 | local interfaces 234 | local interface 235 | local prefixes 236 | local prefix 237 | local name 238 | local value 239 | 240 | config_get_bool ignore "$cfg" ignore 0 241 | [ "$ignore" -ne 0 ] && return 0 242 | 243 | config_get interfaces "$cfg" interface 244 | exist=0 245 | for interface in $interfaces; do 246 | [ "$INTERFACE" = "$interface" ] && exist=1 247 | done 248 | [ "$exist" -eq 0 ] && return 0 249 | 250 | config_get prefixes "$cfg" prefix 251 | for prefix in $prefixes; do 252 | validate_ip6prefix "$prefix" || continue 253 | printf '\n\troute %s\n\t{\n' "$prefix" 254 | 255 | for name in $RADVD_ROUTE_STRING_OPTIONS; do 256 | config_get value "$cfg" "$name" 257 | validate_radvd_string "$value" || continue 258 | printf '\t\t%s %s;\n' "$name" "$value" 259 | done 260 | 261 | for name in $RADVD_ROUTE_BOOLEAN_OPTIONS; do 262 | config_get value "$cfg" "$name" 263 | [ -z "$value" ] && continue 264 | config_get_bool value "$cfg" "$name" 0 265 | if [ "$value" -ne 0 ]; then 266 | printf '\t\t%s on;\n' "$name" 267 | else 268 | printf '\t\t%s off;\n' "$name" 269 | fi 270 | done 271 | 272 | printf '\t};\n' 273 | done 274 | 275 | return 0 276 | } 277 | 278 | radvd_write_rdnss() { 279 | local cfg=$1 280 | validate_varname "$cfg" || return 0 281 | local ignore 282 | local interfaces 283 | local interface 284 | local addrs 285 | local addr 286 | local addr_list 287 | local name 288 | local value 289 | local i 290 | 291 | config_get_bool ignore "$cfg" ignore 0 292 | [ "$ignore" -ne 0 ] && return 0 293 | 294 | config_get interfaces "$cfg" interface 295 | exist=0 296 | for interface in $interfaces; do 297 | [ "$INTERFACE" = "$interface" ] && exist=1 298 | done 299 | [ "$exist" -eq 0 ] && return 0 300 | 301 | config_get addrs "$cfg" addr 302 | i=0 303 | for addr in $addrs; do 304 | [ "$i" -ge 3 ] && break 305 | validate_ip6addr "$addr" || continue 306 | addr_list="$addr_list $addr" 307 | i=$(($i+1)) 308 | done 309 | 310 | if [ -z "$addr_list" ]; then 311 | addr=$(get_ip6addr "$IFNAME" link) || return 0 312 | addr_list=" ${addr%%[/]*}" 313 | fi 314 | 315 | printf '\n\tRDNSS%s\n\t{\n' "$addr_list" 316 | 317 | for name in $RADVD_RDNSS_STRING_OPTIONS; do 318 | config_get value "$cfg" "$name" 319 | validate_radvd_string "$value" || continue 320 | printf '\t\t%s %s;\n' "$name" "$value" 321 | done 322 | 323 | printf '\t};\n' 324 | 325 | return 0 326 | } 327 | 328 | radvd_write_dnssl() { 329 | local cfg=$1 330 | validate_varname "$cfg" || return 0 331 | local ignore 332 | local interfaces 333 | local interface 334 | local suffixes 335 | local suffix 336 | local suffix_list 337 | local name 338 | local value 339 | 340 | config_get_bool ignore "$cfg" ignore 0 341 | [ "$ignore" -ne 0 ] && return 0 342 | 343 | config_get interfaces "$cfg" interface 344 | exist=0 345 | for interface in $interfaces; do 346 | [ "$INTERFACE" = "$interface" ] && exist=1 347 | done 348 | [ "$exist" -eq 0 ] && return 0 349 | 350 | config_get suffixes "$cfg" suffix 351 | for suffix in $suffixes; do 352 | validate_radvd_string "$suffix" || continue 353 | suffix_list="$suffix_list $suffix" 354 | done 355 | 356 | printf '\n\tDNSSL%s\n\t{\n' "$suffix_list" 357 | 358 | for name in $RADVD_DNSSL_STRING_OPTIONS; do 359 | config_get value "$cfg" "$name" 360 | validate_radvd_string "$value" || continue 361 | printf '\t\t%s %s;\n' "$name" "$value" 362 | done 363 | 364 | printf '\t};\n' 365 | 366 | return 0 367 | } 368 | 369 | radvd_write_config() { 370 | . /lib/functions/network.sh 371 | 372 | RADVD_INTERFACES= 373 | config_foreach radvd_add_interface interface 374 | config_foreach radvd_add_interface prefix 375 | config_foreach radvd_add_interface route 376 | config_foreach radvd_add_interface RDNSS 377 | config_foreach radvd_add_interface DNSSL 378 | 379 | for INTERFACE in $RADVD_INTERFACES; do 380 | network_get_device IFNAME "$INTERFACE" || continue 381 | printf 'interface %s\n{\n' "$IFNAME" 382 | config_foreach radvd_write_interface interface 383 | config_foreach radvd_write_prefix prefix 384 | config_foreach radvd_write_route route 385 | config_foreach radvd_write_rdnss rdnss 386 | config_foreach radvd_write_dnssl dnssl 387 | printf '};\n\n' 388 | done 389 | 390 | return 0 391 | } 392 | 393 | start() { 394 | config_load radvd 395 | 396 | RADVD_CONFIG_FILE= 397 | config_foreach radvd_find_config_file radvd 398 | 399 | if [ -z "$RADVD_CONFIG_FILE" ]; then 400 | mkdir -p -- /var/etc/ 401 | radvd_write_config > /var/etc/radvd.conf 402 | if [ -s "/var/etc/radvd.conf" ]; then 403 | RADVD_CONFIG_FILE=/var/etc/radvd.conf 404 | fi 405 | fi 406 | 407 | [ -z "$RADVD_CONFIG_FILE" ] && return 1 408 | 409 | sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null 2> /dev/null 410 | 411 | service_start /usr/sbin/radvd -C "$RADVD_CONFIG_FILE" -m stderr_syslog -p /var/run/radvd.pid 412 | } 413 | 414 | stop() { 415 | service_stop /usr/sbin/radvd 416 | } 417 | -------------------------------------------------------------------------------- /radvd/patches/100-silent-netlink-config-reload.patch: -------------------------------------------------------------------------------- 1 | --- a/netlink.c 2 | +++ b/netlink.c 3 | @@ -67,7 +67,7 @@ void process_netlink_msg(int sock) 4 | else { 5 | dlog(LOG_DEBUG, 3, "%s, ifindex %d, flags is *NOT* running", ifname, ifinfo->ifi_index); 6 | } 7 | - reload_config(); 8 | + reload_config(LOG_DEBUG); 9 | } 10 | } 11 | 12 | --- a/radvd.c 13 | +++ b/radvd.c 14 | @@ -443,7 +443,7 @@ void main_loop(void) 15 | if (sighup_received) 16 | { 17 | dlog(LOG_INFO, 3, "sig hup received.\n"); 18 | - reload_config(); 19 | + reload_config(LOG_INFO); 20 | sighup_received = 0; 21 | } 22 | 23 | @@ -552,11 +552,11 @@ stop_adverts(void) 24 | } 25 | } 26 | 27 | -void reload_config(void) 28 | +void reload_config(int loglevel) 29 | { 30 | struct Interface *iface; 31 | 32 | - flog(LOG_INFO, "attempting to reread config file"); 33 | + flog(loglevel, "attempting to reread config file"); 34 | 35 | iface=IfaceList; 36 | while(iface) 37 | @@ -626,7 +626,7 @@ void reload_config(void) 38 | config_interface(); 39 | kickoff_adverts(); 40 | 41 | - flog(LOG_INFO, "resuming normal operation"); 42 | + flog(loglevel, "resuming normal operation"); 43 | } 44 | 45 | void 46 | --- a/radvd.h 47 | +++ b/radvd.h 48 | @@ -185,7 +185,7 @@ int yylex(void); 49 | 50 | /* radvd.c */ 51 | int check_ip6_forwarding(void); 52 | -void reload_config(void); 53 | +void reload_config(int); 54 | void reset_prefix_lifetimes(void); 55 | 56 | /* timer.c */ 57 | --- a/send.c 58 | +++ b/send.c 59 | @@ -154,7 +154,7 @@ send_ra(struct Interface *iface, struct 60 | * reload_config() will kick off new timers anyway. This avoids 61 | * timer list corruption. 62 | */ 63 | - reload_config(); 64 | + reload_config(LOG_INFO); 65 | return -1; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /samba-hotplug/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=samba-hotplug 11 | PKG_VERSION:=1 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/samba-hotplug 17 | SECTION:=net 18 | CATEGORY:=Network 19 | TITLE:=Samba autoconfig hotplug script. 20 | MAINTAINER:=GuoGuo 21 | endef 22 | 23 | define Package/samba-hotplug/description 24 | A hotplug script to config Samba share automatically. 25 | endef 26 | 27 | define Build/Compile 28 | endef 29 | 30 | define Package/samba-hotplug/install 31 | $(INSTALL_DIR) $(1)/etc/hotplug.d/block 32 | $(INSTALL_BIN) ./files/hotplug.sh $(1)/etc/hotplug.d/block/20-samba-hotplug 33 | endef 34 | 35 | $(eval $(call BuildPackage,samba-hotplug)) 36 | -------------------------------------------------------------------------------- /samba-hotplug/files/hotplug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Samba自动配置脚本,参考PandoraBox的脚本框架并重写。以下为原脚本作者信息: 3 | #=================================================================================== 4 | # 5 | # D-Team Technology Co.,Ltd. ShenZhen 6 | # 作者:Vic 7 | # 8 | # 9 | # 警告:对着屏幕的哥们,我们允许你使用此脚本,但不允许你抹去作者的信息,请保留这段话。 10 | #=================================================================================== 11 | . /lib/functions.sh 12 | 13 | set_samba(){ 14 | section=$(echo $get_uuid | sed 's/-//g') 15 | 16 | uci set samba.${section}="sambashare" 17 | uci set samba.${section}.name="Disk_${device}" 18 | uci set samba.${section}.path="${mountpoint}" 19 | uci set samba.${section}.read_only="no" 20 | uci set samba.${section}.guest_ok="yes" 21 | uci commit samba 22 | } 23 | set_samba_path(){ 24 | section=$(echo $get_uuid | sed 's/-//g') 25 | 26 | uci set samba.${section}.path="${mountpoint}" 27 | uci commit samba 28 | } 29 | 30 | 31 | device=`basename $DEVPATH` 32 | 33 | case "$ACTION" in 34 | add) 35 | 36 | case "$device" in 37 | sd*) ;; 38 | md*) ;; 39 | hd*);; 40 | mmcblk*);; 41 | *) return;; 42 | esac 43 | 44 | sleep 2 45 | mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts` 46 | get_uuid=`block info | grep "/dev/${device}" | awk -F "UUID=" '{print $2}'| awk -F "\"" '{print $2}'` 47 | have_uuid=$(uci show samba | grep -c "$get_uuid") 48 | [ "$have_uuid" = "0" ] && set_samba 49 | [ "$have_uuid" -gt "0" ] && set_samba_path 50 | /etc/init.d/samba restart 51 | ;; 52 | remove) 53 | ;; 54 | esac 55 | -------------------------------------------------------------------------------- /ufsd-chkntfs-mipseb/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2014 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=ufsd-chkntfs 11 | PKG_VERSION:=8.9.0 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/ufsd-chkntfs 17 | SECTION:=utils 18 | CATEGORY:=Utilities 19 | SUBMENU:=Filesystem 20 | DEPENDS:=+kmod-ufsd @TARGET_ar71xx 21 | TITLE:=chkntfs from paragon ufsd 22 | endef 23 | 24 | define Package/ufsd-chkntfs/description 25 | chkntfs from paragon ufsd 26 | endef 27 | 28 | define Build/Compile 29 | endef 30 | 31 | define Package/ufsd-chkntfs/install 32 | $(INSTALL_DIR) $(1)/usr/sbin 33 | $(INSTALL_BIN) ./files/chkntfs $(1)/usr/sbin/chkntfs 34 | cd $(1)/usr/sbin 35 | chmod +x $(1)/usr/sbin/chkntfs 36 | ln -s chkntfs $(1)/usr/sbin/fsck.ntfs 37 | ln -s chkntfs $(1)/usr/sbin/fsck.ufsd 38 | endef 39 | 40 | $(eval $(call BuildPackage,ufsd-chkntfs)) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /ufsd-chkntfs-mipseb/files/chkntfs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/ufsd-chkntfs-mipseb/files/chkntfs -------------------------------------------------------------------------------- /ufsd-mkntfs-mipseb/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2014 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=ufsd-mkntfs 11 | PKG_VERSION:=8.9.0 12 | PKG_RELEASE:=1 13 | 14 | include $(INCLUDE_DIR)/package.mk 15 | 16 | define Package/ufsd-mkntfs 17 | SECTION:=utils 18 | CATEGORY:=Utilities 19 | SUBMENU:=Filesystem 20 | DEPENDS:=+kmod-ufsd @TARGET_ar71xx 21 | TITLE:=mkntfs from paragon ufsd 22 | endef 23 | 24 | define Package/ufsd-mkntfs/description 25 | mkntfs from paragon ufsd 26 | endef 27 | 28 | define Build/Compile 29 | endef 30 | 31 | define Package/ufsd-mkntfs/install 32 | $(INSTALL_DIR) $(1)/usr/sbin 33 | $(INSTALL_BIN) ./files/mkntfs $(1)/usr/sbin/mkntfs 34 | cd $(1)/usr/sbin 35 | chmod +x $(1)/usr/sbin/mkntfs 36 | ln -s mkntfs $(1)/usr/sbin/mkfs.ntfs 37 | ln -s mkntfs $(1)/usr/sbin/mkfs.ufsd 38 | endef 39 | 40 | $(eval $(call BuildPackage,ufsd-mkntfs)) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /ufsd-mkntfs-mipseb/files/mkntfs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrt-stuff/openwrt-maz1/118c5b6cbb5901caaafcba1dcf77d36b8032dcc2/ufsd-mkntfs-mipseb/files/mkntfs --------------------------------------------------------------------------------