\r\n\t\t\t控制板订阅缓存<\/td>\r\n\t\t\t | 0<\/td>\r\n\t\t\t | \r\n \r\n <\/td>\r\n\t\t<\/tr>\r\n\t<\/tbody>\r\n<\/table>",
- "new_lines": "wpautop",
- "esc_html": 0
- },
- {
- "key": "field_5e07599034645",
- "label": "CDN设置",
- "name": "",
- "type": "tab",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "placement": "top",
- "endpoint": 0
- },
- {
- "key": "field_5e0759ab34646",
- "label": "使用说明",
- "name": "",
- "type": "message",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "message": "注意:积木本身不具CDN功能,仅是实现对站点内资源域名的替换。",
- "new_lines": "wpautop",
- "esc_html": 0
- },
- {
- "key": "field_5e075b73d6985",
- "label": "启用CDN替换",
- "name": "open_cdn_replace",
- "type": "button_group",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "choices": {
- "disabled": "禁用",
- "enable": "启用"
- },
- "allow_null": 0,
- "default_value": "disabled",
- "layout": "horizontal",
- "return_format": "value"
- },
- {
- "key": "field_5e075c70d6986",
- "label": "替换列表",
- "name": "cdn_replace_list",
- "type": "repeater",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5e075b73d6985",
- "operator": "==",
- "value": "enable"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "collapsed": "",
- "min": 1,
- "max": 0,
- "layout": "table",
- "button_label": "添加替换",
- "sub_fields": [
- {
- "key": "field_5e075cb1d6987",
- "label": "源域名",
- "name": "source",
- "type": "text",
- "instructions": "需要替换的域名,不包含 http:\/\/ 或 https:\/\/",
- "required": 1,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "prepend": "",
- "append": "",
- "maxlength": ""
- },
- {
- "key": "field_5e075cf1d6988",
- "label": "CDN域名",
- "name": "target",
- "type": "text",
- "instructions": "目标域名,不包含 http:\/\/ 或 https:\/\/",
- "required": 1,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "prepend": "",
- "append": "",
- "maxlength": ""
- }
- ]
- },
- {
- "key": "field_5e0816891b77a",
- "label": "安全防护",
- "name": "",
- "type": "tab",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "placement": "top",
- "endpoint": 0
- },
- {
- "key": "field_5e0818611b77c",
- "label": "后台访问控制",
- "name": "wp-admin-access-control",
- "type": "button_group",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "choices": {
- "disabled": "禁用",
- "enable": "启用"
- },
- "allow_null": 0,
- "default_value": "disabled",
- "layout": "horizontal",
- "return_format": "value"
- },
- {
- "key": "field_5e0816c91b77b",
- "label": "允许访问后台的用户组",
- "name": "wp-admin-access-group",
- "type": "select",
- "instructions": "默认包含 administrator 管理员 用户组",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5e0818611b77c",
- "operator": "==",
- "value": "enable"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "choices": {
- "administrator": "管理员",
- "editor": "编辑",
- "author": "作者",
- "contributor": "贡献者",
- "subscriber": "订阅者"
- },
- "default_value": [],
- "allow_null": 0,
- "multiple": 1,
- "ui": 1,
- "ajax": 1,
- "return_format": "value",
- "placeholder": ""
- },
- {
- "key": "field_5e08ad006953d",
- "label": "后台安全入口",
- "name": "nice-security-access",
- "type": "button_group",
- "instructions": "开启后,需访问指定的URL才能进行登录后台操作。",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "choices": {
- "disabled": "禁用",
- "enable": "启用"
- },
- "allow_null": 0,
- "default_value": "disabled",
- "layout": "horizontal",
- "return_format": "value"
- },
- {
- "key": "field_5e08b26ca4dc2",
- "label": "安全入口路径",
- "name": "nice-security-access-path",
- "type": "text",
- "instructions": "栗子:设置安全入口路径为 nicetheme ,则登录路径为 网站地址\/wp-login.php?nicetheme 。其它路径将无法获得登录表单",
- "required": 1,
- "conditional_logic": [
- [
- {
- "field": "field_5e08ad006953d",
- "operator": "==",
- "value": "enable"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "prepend": "",
- "append": "",
- "maxlength": ""
- },
- {
- "key": "field_5c24afcc8069f",
- "label": "自定义",
- "name": "",
- "type": "tab",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "placement": "top",
- "endpoint": 0
- },
- {
- "key": "field_5c23843882ef7",
- "label": "自定义设置",
- "name": "site",
- "type": "group",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "layout": "block",
- "sub_fields": [
- {
- "key": "field_5c23847d82ef8",
- "label": "头部自定义代码",
- "name": "custom_head_code",
- "type": "textarea",
- "instructions": "请谨慎填写,自定义代码不作任何安全处理!",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "maxlength": "",
- "rows": "",
- "new_lines": ""
- },
- {
- "key": "field_5c2384cd82ef9",
- "label": "底部自定义代码",
- "name": "custom_footer_code",
- "type": "textarea",
- "instructions": "请谨慎填写,自定义代码不做任何安全处理!",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "maxlength": "",
- "rows": "",
- "new_lines": ""
- }
- ]
- }
- ],
- "location": [
- [
- {
- "param": "options_page",
- "operator": "==",
- "value": "nc-optimizeup-options"
- }
- ]
- ],
- "menu_order": 0,
- "position": "normal",
- "style": "default",
- "label_placement": "top",
- "instruction_placement": "label",
- "hide_on_screen": "",
- "active": 1,
- "description": "",
- "config_save_path": "plugins\/nicetheme-jimu\/modules\/base\/conf",
- "modified": 1579569597
-}
\ No newline at end of file
diff --git a/modules/base/conf/group_5bfa538e2d540.json b/modules/base/conf/group_5bfa538e2d540.json
deleted file mode 100644
index 858c76d..0000000
--- a/modules/base/conf/group_5bfa538e2d540.json
+++ /dev/null
@@ -1,205 +0,0 @@
-{
- "key": "group_5bfa538e2d540",
- "title": "SEO 设置",
- "fields": [
- {
- "key": "field_5bfa53958ae40",
- "label": "自定义标题",
- "name": "seo_title",
- "type": "text",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5c00e509e0772",
- "operator": "==",
- "value": "1"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "留空为不启用",
- "prepend": "",
- "append": "",
- "maxlength": ""
- },
- {
- "key": "field_5bfb81023e1d1",
- "label": "手动设置页面关键词(Meta keywords)",
- "name": "seo_manual_keywords",
- "type": "true_false",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5c00e509e0772",
- "operator": "==",
- "value": "1"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "message": "",
- "default_value": 0,
- "ui": 0,
- "ui_on_text": "",
- "ui_off_text": ""
- },
- {
- "key": "field_5bfa53b74f618",
- "label": "自定义关键词",
- "name": "seo_keywords",
- "type": "textarea",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5bfb81023e1d1",
- "operator": "==",
- "value": "1"
- },
- {
- "field": "field_5c00e509e0772",
- "operator": "==",
- "value": "1"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "留空为不启用",
- "maxlength": "",
- "rows": "",
- "new_lines": ""
- },
- {
- "key": "field_5bfb81163e1d2",
- "label": "手动设置页面描述(Meta description)",
- "name": "seo_manual_des",
- "type": "true_false",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5c00e509e0772",
- "operator": "==",
- "value": "1"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "message": "",
- "default_value": 0,
- "ui": 0,
- "ui_on_text": "",
- "ui_off_text": ""
- },
- {
- "key": "field_5bfa53c54f619",
- "label": "自定义描述",
- "name": "seo_description",
- "type": "textarea",
- "instructions": "",
- "required": 0,
- "conditional_logic": [
- [
- {
- "field": "field_5bfb81163e1d2",
- "operator": "==",
- "value": "1"
- },
- {
- "field": "field_5c00e509e0772",
- "operator": "==",
- "value": "1"
- }
- ]
- ],
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "留空为不启用",
- "maxlength": "",
- "rows": "",
- "new_lines": ""
- }
- ],
- "location": [
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "post"
- }
- ],
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "page"
- }
- ],
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "website"
- }
- ],
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "bookmovie"
- }
- ],
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "news"
- }
- ],
- [
- {
- "param": "post_type",
- "operator": "==",
- "value": "music"
- }
- ]
- ],
- "menu_order": 3,
- "position": "normal",
- "style": "default",
- "label_placement": "top",
- "instruction_placement": "label",
- "hide_on_screen": "",
- "active": 1,
- "description": "",
- "config_save_path": "plugins\/nicetheme-jimu\/modules\/base\/conf",
- "modified": 1575518434
-}
\ No newline at end of file
diff --git a/modules/base/conf/group_5c00e9a304f98.json b/modules/base/conf/group_5c00e9a304f98.json
deleted file mode 100644
index f48f734..0000000
--- a/modules/base/conf/group_5c00e9a304f98.json
+++ /dev/null
@@ -1,82 +0,0 @@
-{
- "key": "group_5c00e9a304f98",
- "title": "分类法相关 SEO 设置",
- "fields": [
- {
- "key": "field_5c00e9b1c9698",
- "label": "自定义标题",
- "name": "taxonomy_title",
- "type": "text",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "prepend": "",
- "append": "",
- "maxlength": ""
- },
- {
- "key": "field_5c00eab1c9699",
- "label": "自定义关键词",
- "name": "taxonomy_keywords",
- "type": "text",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "prepend": "",
- "append": "",
- "maxlength": ""
- },
- {
- "key": "field_5c00eac1c969a",
- "label": "自定义描述",
- "name": "taxonomy_desc",
- "type": "textarea",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "default_value": "",
- "placeholder": "",
- "maxlength": "",
- "rows": "",
- "new_lines": ""
- }
- ],
- "location": [
- [
- {
- "param": "taxonomy",
- "operator": "==",
- "value": "all"
- }
- ]
- ],
- "menu_order": 0,
- "position": "normal",
- "style": "default",
- "label_placement": "top",
- "instruction_placement": "label",
- "hide_on_screen": "",
- "active": 1,
- "description": "",
- "config_save_path": "plugins\/nc-plugins\/modules\/base\/conf",
- "modified": 1552982935
-}
\ No newline at end of file
diff --git a/modules/base/conf/group_5c4dc918e5ca5.json b/modules/base/conf/group_5c4dc918e5ca5.json
deleted file mode 100644
index 71171b7..0000000
--- a/modules/base/conf/group_5c4dc918e5ca5.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
- "key": "group_5c4dc918e5ca5",
- "title": "关于 WP积木 插件",
- "fields": [
- {
- "key": "field_5c4dcb364bf8d",
- "label": "介绍",
- "name": "",
- "type": "message",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "message": "WP 积木插件 2019年3月20日 更名为:WP 积木 。\r\n\r\n目前来说,WordPress的使用覆盖全世界,使用范围从个人博客到企业网站等等,通过WordPress主题+WordPress插件,绝大多数的WordPress使用者可以搭建出自己的网站。但往往都遇到一个情况,便是:主题和插件的样式不统一,或者设计过于规范统一,不尽完美和匹配。要么忍受,要么有能力的,进行二次开发。\r\n\r\n而,nicetheme 是一个不将就的设计开发团队。\r\n\r\n因此,我们希望把一些功能模块化,做成小而美的、匹配主题设计风格的积木——积木,从而搭建属于自己style的小窝(网站)。",
- "new_lines": "wpautop",
- "esc_html": 0
- },
- {
- "key": "field_5c4dcdb2f8c07",
- "label": "插件详细介绍&更新日志",
- "name": "",
- "type": "message",
- "instructions": "",
- "required": 0,
- "conditional_logic": 0,
- "wrapper": {
- "width": "",
- "class": "",
- "id": ""
- },
- "message": "请详看官网:https:\/\/www.nicetheme.cn\/jimu",
- "new_lines": "wpautop",
- "esc_html": 0
- }
- ],
- "location": [
- [
- {
- "param": "options_page",
- "operator": "==",
- "value": "nc-intro"
- }
- ]
- ],
- "menu_order": 0,
- "position": "normal",
- "style": "default",
- "label_placement": "top",
- "instruction_placement": "label",
- "hide_on_screen": "",
- "active": 1,
- "description": "",
- "config_save_path": "plugins\/nc-plugins\/modules\/base\/conf",
- "modified": 1553093834
-}
\ No newline at end of file
diff --git a/modules/base/main.php b/modules/base/main.php
deleted file mode 100644
index b59ffd2..0000000
--- a/modules/base/main.php
+++ /dev/null
@@ -1,138 +0,0 @@
-
- 错误: 网站优化 积木 缺少依赖插件 WP 积木 请先安装并启用 WP 积木 插件。
- ';
- echo $html;
- }
-
- } else {
-
- load_theme_textdomain('jimu', NC_OPTIMIZEUP_DIR . '/languages');
-
- acf_add_options_sub_page(
- array(
- 'page_title' => '网站优化 积木',
- 'menu_title' => '网站优化 积木',
- 'menu_slug' => 'nc-optimizeup-options',
- 'parent_slug' => 'nc-modules-store',
- 'capability' => 'manage_options',
- 'update_button' => '保存',
- 'updated_message' => '设置已保存!'
- )
- );
-
-
- add_filter('nc_save_json_paths', 'nc_optimizeup_acf_json_save_point');
-
- function nc_optimizeup_acf_json_save_point( $path ) {
-
- $path[] = NC_OPTIMIZEUP_DIR . '/conf';
-
- return $path;
-
- }
-
- add_filter('acf/settings/load_json', 'nc_optimizeup_acf_json_load_point');
-
- function nc_optimizeup_acf_json_load_point( $paths ) {
-
- $paths[] = NC_OPTIMIZEUP_DIR . '/conf';
-
- return $paths;
-
- }
-
-
-
- function nc_set_main_option() {
- $field_group_json = 'group_5beacfbc334a4.json';
- $option_config = json_decode(file_get_contents(NC_OPTIMIZEUP_CONF_DIR.$field_group_json), true);
- $nc_option = get_all_custom_field_meta('option', $option_config);
- update_option('nc_option', $nc_option, true);
- }
- add_action('acf/save_post', 'nc_set_main_option');
-
- $nc_option = get_option('nc_option');
-
- get_field('seo_switcher', 'option'); // trick
-
- if (false == $nc_option) nc_set_main_option();
-
- include_once NC_OPTIMIZEUP_DIR . '/functions/utils.php';
- include_once NC_OPTIMIZEUP_DIR . '/functions/rocket.php';
- include_once NC_OPTIMIZEUP_DIR . '/functions/usability.php';
- if ($nc_option['seo_switcher']) {
- include_once NC_OPTIMIZEUP_DIR . '/functions/seo.php';
- }
- if ($nc_option['smtp_switcher']) {
- include_once NC_OPTIMIZEUP_DIR . '/functions/smtp.php';
- }
-
- if ($nc_option['general']['anti_spam_switcher']) {
- include_once NC_OPTIMIZEUP_DIR . '/functions/anti-spam.php';
- }
- include_once NC_OPTIMIZEUP_DIR . '/functions/seo-extra.php';
- include_once NC_OPTIMIZEUP_DIR . '/functions/database.php';
-
- if( isset( $nc_option['open_cdn_replace'] ) && $nc_option['open_cdn_replace'] == 'enable' ){
- $GLOBALS['nc_cdn_replace_list'] = $nc_option['cdn_replace_list'];
- include_once NC_OPTIMIZEUP_DIR . '/functions/cdn.php';
- }
-
- if( isset( $nc_option['wp-admin-access-control'] ) && $nc_option['wp-admin-access-control'] == 'enable' ){
- $GLOBALS['wp-admin-access-group'] = $nc_option['wp-admin-access-group'];
- include_once NC_OPTIMIZEUP_DIR . '/functions/wp-admin-access-control.php';
- }
-
- function wp_admin_access_group_select( $field ) {
- global $wp_roles;
-
- $roles = $wp_roles->roles;
-
- $choices = [];
-
- foreach ($roles as $key => $value) {
- $choices[$key] = translate_user_role($value['name']);
- }
-
- $field['choices'] = $choices;
-
- return $field;
-
- }
- add_action( 'acf/load_field/name=wp-admin-access-group', 'wp_admin_access_group_select', 10, 1 );
-
- if( isset( $nc_option['nice-security-access'] ) && $nc_option['nice-security-access'] == 'enable' ){
- $GLOBALS['nice-security-access-path'] = $nc_option['nice-security-access-path'];
- include_once NC_OPTIMIZEUP_DIR . '/functions/nice-security-access.php';
- }
-
- }
-}
-
-
diff --git a/modules/field-group/Field_Group_Values.php b/modules/field-group/Field_Group_Values.php
deleted file mode 100644
index 0656707..0000000
--- a/modules/field-group/Field_Group_Values.php
+++ /dev/null
@@ -1,444 +0,0 @@
-
- * @license GNU General Public License 3.0+
- * @link https://www.timjensen.us
- * @since 1.3.0
- * @package TimJensen\ACF\Field_Group_Values
- */
-
-declare( strict_types = 1 );
-
-namespace TimJensen\ACF;
-
-if ( ! class_exists( 'TimJensen\ACF\Field_Group_Values' ) ) :
-
- /**
- * Class Field_Group_Values
- */
- class Field_Group_Values {
-
- /**
- * Field group configuration array for the current level of recursion.
- *
- * @var array
- */
- public $config;
-
- /**
- * Field group configuration array containing fields/groups to clone.
- *
- * @since 2.0.0
- *
- * @var array
- */
- protected $clone_fields;
-
- /**
- * Post ID, 'option', or 'term_{id}'.
- *
- * @var int|string
- */
- protected $post_id;
-
- /**
- * Stores all the custom field values.
- *
- * @var array
- */
- protected $results = [];
-
- /**
- * Field_Group_Values constructor.
- *
- * @param int|string $post_id Post ID, 'option', or 'term_{id}'.
- * @param array $config Field group configuration array.
- * @param array $clone_fields Field group configuration arrays for cloned fields/groups.
- */
- public function __construct( $post_id, array $config, $clone_fields = [] ) {
- $this->post_id = $post_id;
- $this->config = $config['fields'];
- $this->clone_fields = array_merge( [ $config ], $clone_fields );
- }
-
- /**
- * Builds the multidimensional array that contains all the custom field values.
- *
- * @param array $config
- * @return array
- */
- public function get_all_field_group_values( array $config ): array {
- $this->reset_results();
-
- foreach ( $config as $field ) {
-
- if ( ! $this->has_valid_field_structure( $field ) ) {
- continue;
- }
-
- $field_key = $this->get_field_key( $field );
- $field_value = $this->get_field_value( $field_key );
-
- switch ( $field['type'] ) :
-
- case 'group':
- $this->get_group_field_values( $field, $field_key );
-
- break;
-
- case 'repeater':
- if ( empty( $field_value ) ) {
- break;
- }
-
- $this->get_repeater_field_values( $field, $field_key, $field_value );
-
- break;
-
- case 'flexible_content':
- if ( empty( $field_value ) ) {
- break;
- }
-
- $this->get_flexible_content_field_values( $field, $field_key, $field_value );
-
- break;
-
- case 'clone':
- $this->get_clone_field_values( $field );
-
- break;
-
- default:
- $this->store_field_value( $field, $field_value );
-
- endswitch;
- }
-
- return $this->results;
- }
-
- /**
- * Resets the results property so that the final array is formatted correctly.
- *
- * @return void
- */
- protected function reset_results() {
- $this->results = [];
- }
-
- /**
- * Determines whether the specified field has a valid structure.
- *
- * @param array $field ACF field configuration.
- * @return bool
- */
- protected function has_valid_field_structure( array $field ): bool {
- return ! empty( $field['name'] ) && ! empty( $field['type'] );
- }
-
- /**
- * Builds the field key that is used for looking up the custom field value.
- *
- * @param array $field ACF field configuration.
- * @return string
- */
- protected function get_field_key( array $field ): string {
- $field_key = $field['name'];
-
- if ( isset( $field['meta_key_prefix'] ) ) {
- return $field['meta_key_prefix'] . $field_key;
- }
-
- return $field_key;
- }
-
- /**
- * Retrieve the value for the specified field from the options, term_meta, or post meta tables.
- *
- * @param string $field_key Custom field key.
- * @return mixed
- */
- protected function get_field_value( string $field_key ) {
- // Allow 'option' or 'options'.
- if ( in_array( $this->post_id, [ 'option', 'options' ], true ) ) {
- return get_option( "options_{$field_key}" );
- } elseif ( 'term_' === substr( (string) $this->post_id, 0, 5 ) ) {
- $term_id = (int) substr( $this->post_id, 5 );
-
- return get_term_meta( $term_id, $field_key, true );
- } elseif ( 'user_' === substr( (string) $this->post_id, 0, 5 ) ) {
- $user_id = (int) substr( $this->post_id, 5 );
-
- return get_user_meta( $user_id, $field_key, true );
- }
-
- return get_post_meta( $this->post_id, $field_key, true );
- }
-
- /**
- * Returns an array of ACF flexible content layout types.
- *
- * @param array $field ACF field configuration.
- * @return array
- */
- protected function get_flexible_content_layout_types( array $field ): array {
- $layout_types = [];
- foreach ( $field['layouts'] as $layout ) {
- $layout_types[ $layout['name'] ] = $layout;
- }
-
- return $layout_types;
- }
-
- /**
- * Returns the values for repeater fields.
- *
- * @param array $field ACF field configuration.
- * @param string $parent_meta_key Field key.
- * @param array $field_value Array of layout types for each flexible content row.
- * @return void
- */
- protected function get_flexible_content_field_values( array $field, string $parent_meta_key, array $field_value ) {
- $results = $this->results;
-
- $layout_types = $this->get_flexible_content_layout_types( $field );
-
- // Loop through the chosen layouts.
- foreach ( $field_value as $index => $current_layout_type ) {
-
- // Check if the layout has been deleted from the ACF group.
- if ( empty( $layout_types[ $current_layout_type ]['sub_fields'] ) ) {
- continue;
- }
-
- $config = $layout_types[ $current_layout_type ]['sub_fields'];
-
- $config = $this->set_meta_key_prefix( 'flexible_content', $config, $parent_meta_key, $index );
-
- $results[ $field['name'] ][] = array_merge(
- [
- 'acf_fc_layout' => $current_layout_type,
- ],
- $this->get_all_field_group_values( $config )
- );
- }
-
- $this->results = $results;
- }
-
- /**
- * Returns the custom field values for clone fields.
- *
- * @since 1.4.0
- *
- * @param array $field ACF field configuration.
- * @return void
- */
- protected function get_clone_field_values( array $field ) {
- $results = $this->results;
-
- $config = [];
- foreach ( $field['clone'] as $clone_field_key ) {
-
- $clone_field_config = $this->get_clone_field_config( $clone_field_key, $this->clone_fields );
-
- // A `false` value means the corresponding field was deleted from the field group.
- if ( false === $clone_field_config ) {
- continue;
- }
-
- $config = array_merge( $config, $clone_field_config );
- }
-
- // Build the field key prefix including ACF's option for prefixing, if set. The prefix is only used for
- // retrieving meta values, not for storing the values in the returned array.
- $meta_key_prefix = $field['meta_key_prefix'] ?? '';
-
- if ( $field['prefix_name'] ) {
- $meta_key_prefix .= "{$field['name']}_";
- }
-
- $config = $this->set_meta_key_prefix( 'clone', $config, $meta_key_prefix );
-
- // ACF optionally saves the data in a prefixed format, so we need to account for that.
- if ( $field['prefix_name'] ) {
- $this->result_key_prefix = $field['name'];
- }
-
- $results = array_merge( $results, $this->get_all_field_group_values( $config ) );
-
- // Ensure the prefix does not get applied to other fields.
- unset( $this->result_key_prefix );
-
- $this->results = $results;
- }
-
- /**
- * Sets the value for the meta key prefix and adds it to the field configuration array.
- *
- * @since 2.1.2
- *
- * @param string $field_type Field type: 'clone', 'repeater', 'flexible_content', or 'group'.
- * @param array $config Field configuration.
- * @param string $parent_meta_key Meta key of the parent field.
- * @param int $index Loop index.
- * @return array
- */
- protected function set_meta_key_prefix( string $field_type, array $config, string $parent_meta_key = '', int $index = 0 ): array {
-
- foreach ( $config as &$field_config ) {
-
- switch ( $field_type ) :
-
- case 'group':
- $field_config['meta_key_prefix'] = "{$parent_meta_key}_";
-
- break;
-
- case 'repeater':
- $field_config['meta_key_prefix'] = "{$parent_meta_key}_{$index}_";
-
- break;
-
- case 'flexible_content':
- $field_config['meta_key_prefix'] = "{$parent_meta_key}_{$index}_";
-
- break;
-
- case 'clone':
- $field_config['meta_key_prefix'] = $parent_meta_key;
-
- endswitch;
- }
-
- return $config;
- }
-
- /**
- * Recursively search for the appropriate clone group/field configuration array.
- *
- * @since 1.4.0
- *
- * @param string $clone_field_key Field key to search for.
- * @param array $clone_fields ACF fields configuration.
- * @return bool|array
- */
- protected function get_clone_field_config( string $clone_field_key, array $clone_fields ) {
-
- foreach ( $clone_fields as $field ) {
-
- if ( $field['key'] === $clone_field_key ) {
-
- if ( isset( $field['fields'] ) ) {
- // Return the matched field group.
- return $field['fields'];
- }
-
- // Return the matched field in a new array.
- return [ $field ];
-
- } elseif ( isset( $field['fields'] ) ) { // Whole field group.
- $config = $field['fields'];
- } elseif ( isset( $field['sub_fields'] ) ) { // Repeater, Group, and Flex Content layouts.
- $config = $field['sub_fields'];
- } elseif ( isset( $field['layouts'] ) ) { // Flexible Content.
- $config = $field['layouts'];
- }
-
- if ( empty( $config ) ) {
- // Stop recursion for the current field.
- continue;
- }
-
- $result = $this->get_clone_field_config( $clone_field_key, $config );
-
- if ( $result ) {
- return $result;
- }
- }
-
- return false;
- }
-
- /**
- * Returns the custom field values for group fields.
- *
- * @since 1.4.0
- *
- * @param array $field ACF field configuration.
- * @param string $parent_meta_key Field key.
- * @return void
- */
- protected function get_group_field_values( array $field, string $parent_meta_key ) {
- $results = $this->results;
-
- $field['sub_fields'] = $this->set_meta_key_prefix( 'group', $field['sub_fields'], $parent_meta_key );
-
- $results[ $field['name'] ] = $this->get_all_field_group_values( $field['sub_fields'] );
-
- $this->results = $results;
- }
-
- /**
- * Returns the custom field values for repeater fields.
- *
- * @param array $field ACF field configuration.
- * @param string $parent_meta_key Field key.
- * @param string $field_value Field value.
- * @return void
- */
- protected function get_repeater_field_values( array $field, string $parent_meta_key,$field_value ) {
- $results = $this->results;
-
- for ( $i = 0; $i < $field_value; $i ++ ) {
- $field['sub_fields'] = $this->set_meta_key_prefix( 'repeater', $field['sub_fields'], $parent_meta_key, $i );
-
- $results[ $field['name'] ][] = $this->get_all_field_group_values( $field['sub_fields'] );
- }
-
- $this->results = $results;
- }
-
- /**
- * Store the field value to the results property.
- *
- * @param array $field ACF field configuration.
- * @param string|array $field_value Field value.
- */
- protected function store_field_value( array $field, $field_value ) {
- // ACF allows clone fields to be prefixed.
- $result_key = ! empty( $this->result_key_prefix )
- ? "{$this->result_key_prefix}_{$field['name']}"
- : $field['name'];
-
- $this->results[ $result_key ] = $field_value;
- }
-
- /**
- * Getter method.
- *
- * @param string $property Name of the property to return.
- * @return mixed
- */
- public function __get( $property ) {
- return $this->{$property};
- }
-
- /**
- * Returns a multidimensional array containing all the custom field values.
- *
- * @return array
- */
- public function get_results(): array {
- if ( empty( $this->results ) ) {
- $this->get_all_field_group_values( $this->config );
- }
-
- return $this->results;
- }
- }
-
-endif;
diff --git a/modules/field-group/get_all_custom_field_meta.php b/modules/field-group/get_all_custom_field_meta.php
deleted file mode 100644
index 850de3d..0000000
--- a/modules/field-group/get_all_custom_field_meta.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
- * @license GNU General Public License 3.0+
- * @since 2.2.1
- */
-
-if ( ! function_exists( 'get_all_custom_field_meta' ) ) :
-
- /**
- * Instantiates the Field_Group_Values class and returns the results.
- *
- * @link https://www.timjensen.us/acf-get-field-alternative/
- *
- * @param int|string $post_id Required. Post ID, 'option', or 'term_{id}'.
- * @param array $config Required. ACF field group JSON reformatted as an array.
- * @param array $clone_fields Optional. ACF field group JSON arrays for all cloned fields/groups.
- * @return array
- */
- function get_all_custom_field_meta( $post_id, array $config, array $clone_fields = [] ): array {
- if ( empty( $config['fields'] ) ) {
- $corrected_config['fields'] = $config;
- $config = $corrected_config;
- trigger_error( 'As of version 2.0.0 the $config argument should include the field group key in addition to the array of fields. Pass $config instead of $config[\'fields\'].', E_USER_WARNING );
- }
-
- $field_group_values = new \TimJensen\ACF\Field_Group_Values( $post_id, $config, $clone_fields );
-
- return $field_group_values->get_results();
- }
-
-endif;
diff --git a/modules/jimu.css b/modules/jimu.css
deleted file mode 100644
index 90ecdc1..0000000
--- a/modules/jimu.css
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
- /$$
- /$$ /$$$$
- | $$ |_ $$ /$$$$$$$
- /$$$$$$$$ | $$ /$$_____/
-|__ $$__/ | $$ | $$$$$$
- | $$ | $$ \____ $$
- |__/ /$$$$$$ /$$$$$$$/
- |______/|_______/
-================================
- Keep calm and get rich.
- Is the best.
-
- @Author: Dami
- @Date: 2019-03-18 17:47:07
- * @Last Modified by: suxing
- * @Last Modified time: 2019-08-13 11:23:35
-*/
-
-
-/*
- SimpleBar style
-*/
-
-
-[data-simplebar] {
- position: relative;
- flex-direction: column;
- flex-wrap: wrap;
- justify-content: flex-start;
- align-content: flex-start;
- align-items: flex-start;
-}
-
-.simplebar-wrapper {
- overflow: hidden;
- width: inherit;
- height: inherit;
- max-width: inherit;
- max-height: inherit;
-}
-
-.simplebar-mask {
- direction: inherit;
- position: absolute;
- overflow: hidden;
- padding: 0;
- margin: 0;
- left: 0;
- top: 0;
- bottom: 0;
- right: 0;
- width: auto !important;
- height: auto !important;
- z-index: 0;
-}
-
-.simplebar-offset {
- direction: inherit !important;
- box-sizing: inherit !important;
- resize: none !important;
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- padding: 0;
- margin: 0;
- -webkit-overflow-scrolling: touch;
-}
-
-.simplebar-content-wrapper {
- direction: inherit;
- box-sizing: border-box !important;
- position: relative;
- display: block;
- height: 100%;
- /* Required for horizontal native scrollbar to not appear if parent is taller than natural height */
- width: auto;
- visibility: visible;
- overflow: auto;
- /* Scroll on this element otherwise element can't have a padding applied properly */
- max-width: 100%;
- /* Not required for horizontal scroll to trigger */
- max-height: 100%;
- /* Needed for vertical scroll to trigger */
-}
-
-.simplebar-content:before,
-.simplebar-content:after {
- content: " ";
- display: table;
-}
-
-.simplebar-placeholder {
- max-height: 100%;
- max-width: 100%;
- width: 100%;
- pointer-events: none;
-}
-
-.simplebar-height-auto-observer-wrapper {
- box-sizing: inherit !important;
- height: 100%;
- width: inherit;
- max-width: 1px;
- position: relative;
- float: left;
- max-height: 1px;
- overflow: hidden;
- z-index: -1;
- padding: 0;
- margin: 0;
- pointer-events: none;
- flex-grow: inherit;
- flex-shrink: 0;
- flex-basis: 0;
-}
-
-.simplebar-height-auto-observer {
- box-sizing: inherit;
- display: block;
- opacity: 0;
- position: absolute;
- top: 0;
- left: 0;
- height: 1000%;
- width: 1000%;
- min-height: 1px;
- min-width: 1px;
- overflow: hidden;
- pointer-events: none;
- z-index: -1;
-}
-
-.simplebar-track {
- z-index: 1;
- position: absolute;
- right: 0;
- bottom: 0;
- pointer-events: none;
- overflow: hidden;
-}
-
-[data-simplebar].simplebar-dragging .simplebar-track {
- pointer-events: all;
-}
-
-.simplebar-scrollbar {
- position: absolute;
- right: 2px;
- width: 7px;
- min-height: 10px;
-}
-
-.simplebar-scrollbar:before {
- position: absolute;
- content: "";
- background: black;
- border-radius: 7px;
- left: 0;
- right: 0;
- opacity: 0;
- transition: opacity 0.2s linear;
-}
-
-.simplebar-track .simplebar-scrollbar.simplebar-visible:before {
-
- /* When hovered, remove all transitions from drag handle */
- opacity: 0.5;
- transition: opacity 0s linear;
-}
-
-.simplebar-track.simplebar-vertical {
- top: 0;
- width: 11px;
-}
-
-.simplebar-track.simplebar-vertical .simplebar-scrollbar:before {
- top: 2px;
- bottom: 2px;
-}
-
-.simplebar-track.simplebar-horizontal {
- left: 0;
- height: 11px;
-}
-
-.simplebar-track.simplebar-horizontal .simplebar-scrollbar:before {
- height: 100%;
- left: 2px;
- right: 2px;
-}
-
-.simplebar-track.simplebar-horizontal .simplebar-scrollbar {
- right: auto;
- left: 0;
- top: 2px;
- height: 7px;
- min-height: 0;
- min-width: 10px;
- width: auto;
-}
-
-/* Rtl support */
-[data-simplebar-direction="rtl"] .simplebar-track.simplebar-vertical {
- right: auto;
- left: 0;
-}
-
-.hs-dummy-scrollbar-size {
- direction: rtl;
- position: fixed;
- opacity: 0;
- visibility: hidden;
- height: 500px;
- width: 500px;
- overflow-y: hidden;
- overflow-x: scroll;
-}
-
-/*--------------------------------------------------------------
- POPUP CSS
---------------------------------------------------------------*/
-.nice-tips,
-.nice-tips-overlay {
- width: 100%;
- height: 100vh;
- top: 0;
- left: 0;
-}
-
-.nice-tips {
- position: fixed;
- display: -webkit-flex;
- display: flex;
- -webkit-align-items: center;
- align-items: center;
- -webkit-justify-content: center;
- justify-content: center;
- pointer-events: none
-}
-
-.nice-tips-open {
- z-index: 1031;
-}
-
-.nice-tips-overlay {
- position: absolute;
- background: rgba(120, 129, 147, .22);
- opacity: 0;
- -webkit-transition: opacity .3s;
- transition: opacity .3s;
- -webkit-backface-visibility: hidden -webkit-transition-duration: .3s;
- transition-duration: .3s
-}
-
-.nice-tips-open .nice-tips-overlay {
- opacity: 1;
- pointer-events: auto;
-}
-
-@supports (-webkit-backdrop-filter:blur(10px)) or (backdrop-filter:blur(10px)) {
- .nice-tips-open .nice-tips-overlay {
- -webkit-backdrop-filter: blur(10px);
- backdrop-filter: blur(10px);
- }
-
-}
-/*--------------------------------------------------------------
- tips body
---------------------------------------------------------------*/
-.nice-tips-body {
- position: relative;
- opacity: 0;
- max-width: 400px;
- width: 100%;
-}
-
-@media (max-width: 575.98px) {
- .nice-tips-body {
- max-width: 93.3333%;
- }
-}
-
-.nice-tips-open .nice-tips-body {
- pointer-events: auto;
-}
-
-.nice-tips-xl .nice-tips-body {
- width: 100%;
- max-width: 790px;
-}
-
-.nice-tips-scroll .nice-tips-body{
- width: 100%;
- max-width: 790px;
- display: flex;
- -webkit-align-items: center;
- align-items: center;
- -webkit-justify-content: center;
- justify-content: center;
- max-height: calc(100vh - 100px);
- height: calc(100vh - 100px);
-}
-
-.nice-tips-lg .nice-tips-body {
- width: 100%;
- max-width: 790px;
-}
-
-.nice-tips-md .nice-tips-body {
- max-width: 540px;
- width: 100%;
-}
-
-.nice-tips-sm .nice-tips-body {
- max-width: 300px;
- width: auto;
-}
-
-.nice-tips-nopd .nice-tips-body {
- max-width: 340px;
-}
-
-@media (min-width:768px) and (max-width:991.98px) {
- .nice-tips-scroll .nice-tips-body,
- .nice-tips-xl .nice-tips-body {
- max-width: 670px;
- }
-
-}
-
-@media (max-width:767.98px) {
- .nice-tips-scroll .nice-tips-body,
- .nice-tips-xl .nice-tips-body {
- height: 100vh;
- }
- .nice-tips-md .nice-tips-body {
- padding:1rem;
- }
-
-}
-
-/*--------------------------------------------------------------
- tips body animation
---------------------------------------------------------------*/
-
-.nice-tips.nice-tips-open .nice-tips-body,
-.nice-tips.nice-tips-close .nice-tips-body {
- -webkit-animation-duration: .3s;
- animation-duration: .3s;
- -webkit-animation-fill-mode: forwards;
- animation-fill-mode: forwards
-}
-
-.nice-tips.nice-tips-open .nice-tips-body {
- -webkit-animation-name: tips-open;
- animation-name: tips-open
-}
-
-.nice-tips.nice-tips-close .nice-tips-body {
- -webkit-animation-name: tips-close;
- animation-name: tips-close
-}
-
-@-webkit-keyframes tips-open {
- 0% {
- opacity: 0;
- -webkit-transform: translate3d(0, 50px, 0)
- }
-
- 100% {
- opacity: 1;
- -webkit-transform: translate3d(0, 0, 0)
- }
-
-}
-
-@keyframes tips-open {
- 0% {
- opacity: 0;
- -webkit-transform: translate3d(0, 50px, 0);
- transform: translate3d(0, 50px, 0)
- }
-
- 100% {
- opacity: 1;
- -webkit-transform: translate3d(0, 0, 0);
- transform: translate3d(0, 0, 0)
- }
-
-}
-
-@-webkit-keyframes tips-close {
- 0% {
- opacity: 1;
- -webkit-transform: translate3d(0, 0, 0)
- }
-
- 100% {
- opacity: 0;
- -webkit-transform: translate3d(0, 50px, 0)
- }
-
-}
-
-@keyframes tips-close {
- 0% {
- opacity: 1;
- -webkit-transform: translate3d(0, 0, 0);
- transform: translate3d(0, 0, 0)
- }
-
- 100% {
- opacity: 0;
- -webkit-transform: translate3d(0, 50px, 0);
- transform: translate3d(0, 50px, 0)
- }
-
-}
-/*--------------------------------------------------------------
- tips content
---------------------------------------------------------------*/
-.nice-tips-content {
- background: #fff;
- padding: 1.25rem;
- position: relative;
- border-radius: 4px;
- border: 1px solid #f4f5f9;
- box-shadow: 0 10px 50px -5px rgba(6, 39, 67, 0.12);
-}
-.nice-tips-xl .nice-tips-content{
- padding: 0;
- border: 0;
- width: 100%;
- height: auto;
- overflow: hidden;
-}
-
-.nice-tips-scroll .nice-tips-content{
- padding: 0;
- border: 0;
- width: 100%;
- height: 100%;
- overflow: hidden;
-}
-
-.nice-tips-lg .nice-tips-content {
- padding: 0;
- border: 0;
- border-radius: 0;
-}
-.nice-tips-sm .nice-tips-content {
- padding: 2rem;
- padding: 1.75rem 2.5rem;
-}
-
-.nice-tips-nopd .nice-tips-content {
- padding: 0;
- border: 0;
-}
-
-@media (max-width:767.98px) {
- .nice-tips-scroll .nice-tips-body .nice-tips-content,
- .nice-tips-xl .nice-tips-body .nice-tips-content {
- box-shadow: none;
- border-radius: 0;
- height: 100vh;
- }
-}
-
-/*--------------------------------------------------------------
- tips svg color
---------------------------------------------------------------*/
-
-.nice-tips-content .text-success svg path {
- fill: #28a745;
-}
-
-.nice-tips-content .text-danger svg path {
- fill: #ffc107;
-}
-
-/*--------------------------------------------------------------
- tips close btn
---------------------------------------------------------------*/
-.btn-close-tips {
- position: absolute;
- bottom: 0px;
- left: 0;
- width: 100%;
- z-index: 44;
- cursor: pointer;
- transform: translateY(150%);
- text-align: center;
-}
-
-.btn-close-tips svg path {
- fill: #fff
-}
-
-@media (max-width:767.98px) {
- .nice-tips-scroll .btn-close-tips{
- transform: translateY(120%);
- }
- .nice-tips-xl .btn-close-tips {
- transform: translateY(-100%);
- }
- .nice-tips-scroll .btn-close-tips svg path ,
- .nice-tips-xl .btn-close-tips svg path {
- fill: #888;
- }
-
-}
-@media (min-width:768px) {
- .nice-tips-scroll .btn-close-tips {
- right: 0;
- top: 0;
- bottom: auto;
- left: auto;
- width: auto;
- z-index: 44;
- cursor: pointer;
- transform: translateX(120%);
- }
-}
-
-
-/*
- post cover style
-*/
-.nice-tips-cover .nice-tips-overlay {
- background: rgb(120, 129, 147);
-}
-
-.tips-content-cover {
- max-width: 340px;
- width: 100%;
- padding: 0;
- border: 0;
- border-radius: .22rem;
-}
-
-.cover-image {
- position: relative;
- overflow: hidden;
- border-radius: .22rem .22rem 0 0;
- padding: 0;
-}
-
-.cover-image img {}
-
-.cover-overlay {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- -webkit-filter: blur(10px);
- filter: blur(20px);
- z-index: -1;
-}
-
-.cover-overlay:before {
- content: '';
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- background-color: #000;
- opacity: .11;
-}
-
-.cover-share {
- text-align: center;
- padding: 1rem 0;
- border-top: 1px solid #f4f6f9;
-}
-
-.cover-share a {
- color: #8a92a9;
- padding: .25rem;
- margin: .25rem;
- font-size: 1.125rem;
-}
-
-.cover-share a:hover {
- color: #062743;
-}
-
-.cover-text {
- text-align: center;
- position: absolute;
- top: 0px;
- left: 0;
- width: 100%;
- z-index: 44;
- cursor: pointer;
- transform: translateY(-36px);
- text-align: center;
- color: #fff;
- font-size: .875rem;
-}
\ No newline at end of file
diff --git a/modules/jimu.js b/modules/jimu.js
deleted file mode 100644
index 52e773d..0000000
--- a/modules/jimu.js
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- /$$
- /$$ /$$$$
- | $$ |_ $$ /$$$$$$$
- /$$$$$$$$ | $$ /$$_____/
-|__ $$__/ | $$ | $$$$$$
- | $$ | $$ \____ $$
- |__/ /$$$$$$ /$$$$$$$/
- |______/|_______/
-================================
- Keep calm and get rich.
- Is the best.
-
- @Author: Dami
- @Date: 2019-03-18 17:47:07
- * @Last Modified by: suxing
- * @Last Modified time: 2019-08-14 20:48:09
-*/
-/**
- * SimpleBar.js - v4.0.0-alpha.5
- * Scrollbars, simpler.
- * https://grsmto.github.io/simplebar/
- *
- * Made by Adrien Denat from a fork by Jonathan Nicol
- * Under MIT License
- */
-
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).SimpleBar=e()}(this,function(){"use strict";var t=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},e=function(t){try{return!!t()}catch(t){return!0}},i={}.toString,r=function(t){return i.call(t).slice(8,-1)},n="".split,s=e(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==r(t)?n.call(t,""):Object(t)}:Object,o=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},a=function(t){return Object(o(t))},l=Math.ceil,c=Math.floor,u=function(t){return isNaN(t=+t)?0:(t>0?c:l)(t)},h=Math.min,f=function(t){return t>0?h(u(t),9007199254740991):0},d=function(t){return"object"==typeof t?null!==t:"function"==typeof t},p=Array.isArray||function(t){return"Array"==r(t)},v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t,e){return t(e={exports:{}},e.exports),e.exports}var b,m,y,x,E="object"==typeof window&&window&&window.Math==Math?window:"object"==typeof self&&self&&self.Math==Math?self:Function("return this")(),w=!e(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),O=E.document,_=d(O)&&d(O.createElement),S=!w&&!e(function(){return 7!=Object.defineProperty((t="div",_?O.createElement(t):{}),"a",{get:function(){return 7}}).a;var t}),A=function(t){if(!d(t))throw TypeError(String(t)+" is not an object");return t},L=function(t,e){if(!d(t))return t;var i,r;if(e&&"function"==typeof(i=t.toString)&&!d(r=i.call(t)))return r;if("function"==typeof(i=t.valueOf)&&!d(r=i.call(t)))return r;if(!e&&"function"==typeof(i=t.toString)&&!d(r=i.call(t)))return r;throw TypeError("Can't convert object to primitive value")},M=Object.defineProperty,k={f:w?M:function(t,e,i){if(A(t),e=L(e,!0),A(i),S)try{return M(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},W=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},T=w?function(t,e,i){return k.f(t,e,W(1,i))}:function(t,e,i){return t[e]=i,t},j=function(t,e){try{T(E,t,e)}catch(i){E[t]=e}return e},R=g(function(t){var e=E["__core-js_shared__"]||j("__core-js_shared__",{});(t.exports=function(t,i){return e[t]||(e[t]=void 0!==i?i:{})})("versions",[]).push({version:"3.0.1",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),N=0,z=Math.random(),C=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++N+z).toString(36))},V=!e(function(){return!String(Symbol())}),D=R("wks"),B=E.Symbol,I=function(t){return D[t]||(D[t]=V&&B[t]||(V?B:C)("Symbol."+t))},P=I("species"),H=function(t,e){var i;return p(t)&&("function"!=typeof(i=t.constructor)||i!==Array&&!p(i.prototype)?d(i)&&null===(i=i[P])&&(i=void 0):i=void 0),new(void 0===i?Array:i)(0===e?0:e)},q=function(e,i){var r=1==e,n=2==e,o=3==e,l=4==e,c=6==e,u=5==e||c,h=i||H;return function(i,d,p){for(var v,g,b=a(i),m=s(b),y=function(e,i,r){if(t(e),void 0===i)return e;switch(r){case 0:return function(){return e.call(i)};case 1:return function(t){return e.call(i,t)};case 2:return function(t,r){return e.call(i,t,r)};case 3:return function(t,r,n){return e.call(i,t,r,n)}}return function(){return e.apply(i,arguments)}}(d,p,3),x=f(m.length),E=0,w=r?h(i,x):n?h(i,0):void 0;x>E;E++)if((u||E in m)&&(g=y(v=m[E],E,b),e))if(r)w[E]=g;else if(g)switch(e){case 3:return!0;case 5:return v;case 6:return E;case 2:w.push(v)}else if(l)return!1;return c?-1:o||l?l:w}},F=I("species"),$={}.propertyIsEnumerable,X=Object.getOwnPropertyDescriptor,Y={f:X&&!$.call({1:2},1)?function(t){var e=X(this,t);return!!e&&e.enumerable}:$},G=function(t){return s(o(t))},K={}.hasOwnProperty,U=function(t,e){return K.call(t,e)},J=Object.getOwnPropertyDescriptor,Q={f:w?J:function(t,e){if(t=G(t),e=L(e,!0),S)try{return J(t,e)}catch(t){}if(U(t,e))return W(!Y.f.call(t,e),t[e])}},Z=R("native-function-to-string",Function.toString),tt=E.WeakMap,et="function"==typeof tt&&/native code/.test(Z.call(tt)),it=R("keys"),rt={},nt=E.WeakMap;if(et){var st=new nt,ot=st.get,at=st.has,lt=st.set;b=function(t,e){return lt.call(st,t,e),e},m=function(t){return ot.call(st,t)||{}},y=function(t){return at.call(st,t)}}else{var ct=it[x="state"]||(it[x]=C(x));rt[ct]=!0,b=function(t,e){return T(t,ct,e),e},m=function(t){return U(t,ct)?t[ct]:{}},y=function(t){return U(t,ct)}}var ut,ht,ft={set:b,get:m,has:y,enforce:function(t){return y(t)?m(t):b(t,{})},getterFor:function(t){return function(e){var i;if(!d(e)||(i=m(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return i}}},dt=g(function(t){var e=ft.get,i=ft.enforce,r=String(Z).split("toString");R("inspectSource",function(t){return Z.call(t)}),(t.exports=function(t,e,n,s){var o=!!s&&!!s.unsafe,a=!!s&&!!s.enumerable,l=!!s&&!!s.noTargetGet;"function"==typeof n&&("string"!=typeof e||U(n,"name")||T(n,"name",e),i(n).source=r.join("string"==typeof e?e:"")),t!==E?(o?!l&&t[e]&&(a=!0):delete t[e],a?t[e]=n:T(t,e,n)):a?t[e]=n:j(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Z.call(this)})}),pt=Math.max,vt=Math.min,gt=(ut=!1,function(t,e,i){var r,n=G(t),s=f(n.length),o=function(t,e){var i=u(t);return i<0?pt(i+e,0):vt(i,e)}(i,s);if(ut&&e!=e){for(;s>o;)if((r=n[o++])!=r)return!0}else for(;s>o;o++)if((ut||o in n)&&n[o]===e)return ut||o||0;return!ut&&-1}),bt=function(t,e){var i,r=G(t),n=0,s=[];for(i in r)!U(rt,i)&&U(r,i)&&s.push(i);for(;e.length>n;)U(r,i=e[n++])&&(~gt(s,i)||s.push(i));return s},mt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],yt=mt.concat("length","prototype"),xt={f:Object.getOwnPropertyNames||function(t){return bt(t,yt)}},Et={f:Object.getOwnPropertySymbols},wt=E.Reflect,Ot=wt&&wt.ownKeys||function(t){var e=xt.f(A(t)),i=Et.f;return i?e.concat(i(t)):e},_t=function(t,e){for(var i=Ot(e),r=k.f,n=Q.f,s=0;s=0:u>h;h+=d)h in c&&(n=i(n,c[h],h,l));return n}(this,e,arguments.length,arguments[1],!1)}});var Bt=k.f,It=Function.prototype,Pt=It.toString,Ht=/^\s*function ([^ (]*)/;!w||"name"in It||Bt(It,"name",{configurable:!0,get:function(){try{return Pt.call(this).match(Ht)[1]}catch(t){return""}}});var qt=Object.keys||function(t){return bt(t,mt)},Ft=Object.assign,$t=!Ft||e(function(){var t={},e={},i=Symbol();return t[i]=7,"abcdefghijklmnopqrst".split("").forEach(function(t){e[t]=t}),7!=Ft({},t)[i]||"abcdefghijklmnopqrst"!=qt(Ft({},e)).join("")})?function(t,e){for(var i=a(t),r=arguments.length,n=1,o=Et.f,l=Y.f;r>n;)for(var c,u=s(arguments[n++]),h=o?qt(u).concat(o(u)):qt(u),f=h.length,d=0;f>d;)l.call(u,c=h[d++])&&(i[c]=u[c]);return i}:Ft;Rt({target:"Object",stat:!0,forced:Object.assign!==$t},{assign:$t});var Xt="\t\n\v\f\r \u2028\u2029\ufeff",Yt="["+Xt+"]",Gt=RegExp("^"+Yt+Yt+"*"),Kt=RegExp(Yt+Yt+"*$"),Ut=E.parseInt,Jt=/^[-+]?0[xX]/,Qt=8!==Ut(Xt+"08")||22!==Ut(Xt+"0x16")?function(t,e){var i=function(t,e){return t=String(o(t)),1&e&&(t=t.replace(Gt,"")),2&e&&(t=t.replace(Kt,"")),t}(String(t),3);return Ut(i,e>>>0||(Jt.test(i)?16:10))}:Ut;Rt({global:!0,forced:parseInt!=Qt},{parseInt:Qt});var Zt,te,ee=RegExp.prototype.exec,ie=String.prototype.replace,re=ee,ne=(Zt=/a/,te=/b*/g,ee.call(Zt,"a"),ee.call(te,"a"),0!==Zt.lastIndex||0!==te.lastIndex),se=void 0!==/()??/.exec("")[1];(ne||se)&&(re=function(t){var e,i,r,n,s=this;return se&&(i=new RegExp("^"+s.source+"$(?!\\s)",function(){var t=A(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}.call(s))),ne&&(e=s.lastIndex),r=ee.call(s,t),ne&&r&&(s.lastIndex=s.global?r.index+r[0].length:e),se&&r&&r.length>1&&ie.call(r[0],i,function(){for(n=1;n=l?i?"":void 0:(r=s.charCodeAt(a))<55296||r>56319||a+1===l||(n=s.charCodeAt(a+1))<56320||n>57343?i?s.charAt(a):r:i?s.slice(a,a+2):n-56320+(r-55296<<10)+65536}(t,e,!0).length:1)},le=function(t,e){var i=t.exec;if("function"==typeof i){var n=i.call(t,e);if("object"!=typeof n)throw TypeError("RegExp exec method returned something other than an Object or null");return n}if("RegExp"!==r(t))throw TypeError("RegExp#exec called on incompatible receiver");return oe.call(t,e)},ce=I("species"),ue=!e(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),he=!e(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var i="ab".split(t);return 2!==i.length||"a"!==i[0]||"b"!==i[1]}),fe=function(t,i,r,n){var s=I(t),o=!e(function(){var e={};return e[s]=function(){return 7},7!=""[t](e)}),a=o&&!e(function(){var e=!1,i=/a/;return i.exec=function(){return e=!0,null},"split"===t&&(i.constructor={},i.constructor[ce]=function(){return i}),i[s](""),!e});if(!o||!a||"replace"===t&&!ue||"split"===t&&!he){var l=/./[s],c=r(s,""[t],function(t,e,i,r,n){return e.exec===oe?o&&!n?{done:!0,value:l.call(e,i,r)}:{done:!0,value:t.call(i,e,r)}:{done:!1}}),u=c[0],h=c[1];dt(String.prototype,t,u),dt(RegExp.prototype,s,2==i?function(t,e){return h.call(t,this,e)}:function(t){return h.call(t,this)}),n&&T(RegExp.prototype[s],"sham",!0)}};fe("match",1,function(t,e,i){return[function(e){var i=o(this),r=null==e?void 0:e[t];return void 0!==r?r.call(e,i):new RegExp(e)[t](String(i))},function(t){var r=i(e,t,this);if(r.done)return r.value;var n=A(t),s=String(this);if(!n.global)return le(n,s);var o=n.unicode;n.lastIndex=0;for(var a,l=[],c=0;null!==(a=le(n,s));){var u=String(a[0]);l[c]=u,""===u&&(n.lastIndex=ae(s,f(n.lastIndex),o)),c++}return 0===c?null:l}]});var de=Math.max,pe=Math.min,ve=Math.floor,ge=/\$([$&`']|\d\d?|<[^>]*>)/g,be=/\$([$&`']|\d\d?)/g;fe("replace",2,function(t,e,i){return[function(i,r){var n=o(this),s=null==i?void 0:i[t];return void 0!==s?s.call(i,n,r):e.call(String(n),i,r)},function(t,n){var s=i(e,t,this,n);if(s.done)return s.value;var o=A(t),a=String(this),l="function"==typeof n;l||(n=String(n));var c=o.global;if(c){var h=o.unicode;o.lastIndex=0}for(var d=[];;){var p=le(o,a);if(null===p)break;if(d.push(p),!c)break;""===String(p[0])&&(o.lastIndex=ae(a,f(o.lastIndex),h))}for(var v,g="",b=0,m=0;m=b&&(g+=a.slice(b,x)+S,b=x+y.length)}return g+a.slice(b)}];function r(t,i,r,n,s,o){var l=r+t.length,c=n.length,u=be;return void 0!==s&&(s=a(s),u=ge),e.call(o,u,function(e,o){var a;switch(o.charAt(0)){case"$":return"$";case"&":return t;case"`":return i.slice(0,r);case"'":return i.slice(l);case"<":a=s[o.slice(1,-1)];break;default:var u=+o;if(0===u)return e;if(u>c){var h=ve(u/10);return 0===h?e:h<=c?void 0===n[h-1]?o.charAt(1):n[h-1]+o.charAt(1):e}a=n[u-1]}return void 0===a?"":a})}});for(var me in{CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}){var ye=E[me],xe=ye&&ye.prototype;if(xe&&xe.forEach!==Dt)try{T(xe,"forEach",Dt)}catch(t){xe.forEach=Dt}}var Ee=g(function(t,e){t.exports=function(){if("undefined"==typeof document)return 0;var t,e=document.body,i=document.createElement("div"),r=i.style;return r.position="absolute",r.top=r.left="-9999px",r.width=r.height="100px",r.overflow="scroll",e.appendChild(i),t=i.offsetWidth-i.clientWidth,e.removeChild(i),t}}),we="Expected a function",Oe=NaN,_e="[object Symbol]",Se=/^\s+|\s+$/g,Ae=/^[-+]0x[0-9a-f]+$/i,Le=/^0b[01]+$/i,Me=/^0o[0-7]+$/i,ke=parseInt,We="object"==typeof v&&v&&v.Object===Object&&v,Te="object"==typeof self&&self&&self.Object===Object&&self,je=We||Te||Function("return this")(),Re=Object.prototype.toString,Ne=Math.max,ze=Math.min,Ce=function(){return je.Date.now()};function Ve(t,e,i){var r,n,s,o,a,l,c=0,u=!1,h=!1,f=!0;if("function"!=typeof t)throw new TypeError(we);function d(e){var i=r,s=n;return r=n=void 0,c=e,o=t.apply(s,i)}function p(t){var i=t-l;return void 0===l||i>=e||i<0||h&&t-c>=s}function v(){var t=Ce();if(p(t))return g(t);a=setTimeout(v,function(t){var i=e-(t-l);return h?ze(i,s-(t-c)):i}(t))}function g(t){return a=void 0,f&&r?d(t):(r=n=void 0,o)}function b(){var t=Ce(),i=p(t);if(r=arguments,n=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(v,e),u?d(t):o}(l);if(h)return a=setTimeout(v,e),d(l)}return void 0===a&&(a=setTimeout(v,e)),o}return e=Be(e)||0,De(i)&&(u=!!i.leading,s=(h="maxWait"in i)?Ne(Be(i.maxWait)||0,e):s,f="trailing"in i?!!i.trailing:f),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=l=n=a=void 0},b.flush=function(){return void 0===a?o:g(Ce())},b}function De(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Be(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Re.call(t)==_e}(t))return Oe;if(De(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=De(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Se,"");var i=Le.test(t);return i||Me.test(t)?ke(t.slice(2),i?2:8):Ae.test(t)?Oe:+t}var Ie=function(t,e,i){var r=!0,n=!0;if("function"!=typeof t)throw new TypeError(we);return De(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),Ve(t,e,{leading:r,maxWait:e,trailing:n})},Pe="Expected a function",He=NaN,qe="[object Symbol]",Fe=/^\s+|\s+$/g,$e=/^[-+]0x[0-9a-f]+$/i,Xe=/^0b[01]+$/i,Ye=/^0o[0-7]+$/i,Ge=parseInt,Ke="object"==typeof v&&v&&v.Object===Object&&v,Ue="object"==typeof self&&self&&self.Object===Object&&self,Je=Ke||Ue||Function("return this")(),Qe=Object.prototype.toString,Ze=Math.max,ti=Math.min,ei=function(){return Je.Date.now()};function ii(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function ri(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Qe.call(t)==qe}(t))return He;if(ii(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ii(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Fe,"");var i=Xe.test(t);return i||Ye.test(t)?Ge(t.slice(2),i?2:8):$e.test(t)?He:+t}var ni=function(t,e,i){var r,n,s,o,a,l,c=0,u=!1,h=!1,f=!0;if("function"!=typeof t)throw new TypeError(Pe);function d(e){var i=r,s=n;return r=n=void 0,c=e,o=t.apply(s,i)}function p(t){var i=t-l;return void 0===l||i>=e||i<0||h&&t-c>=s}function v(){var t=ei();if(p(t))return g(t);a=setTimeout(v,function(t){var i=e-(t-l);return h?ti(i,s-(t-c)):i}(t))}function g(t){return a=void 0,f&&r?d(t):(r=n=void 0,o)}function b(){var t=ei(),i=p(t);if(r=arguments,n=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(v,e),u?d(t):o}(l);if(h)return a=setTimeout(v,e),d(l)}return void 0===a&&(a=setTimeout(v,e)),o}return e=ri(e)||0,ii(i)&&(u=!!i.leading,s=(h="maxWait"in i)?Ze(ri(i.maxWait)||0,e):s,f="trailing"in i?!!i.trailing:f),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=l=n=a=void 0},b.flush=function(){return void 0===a?o:g(ei())},b},si="Expected a function",oi="__lodash_hash_undefined__",ai="[object Function]",li="[object GeneratorFunction]",ci=/^\[object .+?Constructor\]$/,ui="object"==typeof v&&v&&v.Object===Object&&v,hi="object"==typeof self&&self&&self.Object===Object&&self,fi=ui||hi||Function("return this")();var di=Array.prototype,pi=Function.prototype,vi=Object.prototype,gi=fi["__core-js_shared__"],bi=function(){var t=/[^.]+$/.exec(gi&&gi.keys&&gi.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),mi=pi.toString,yi=vi.hasOwnProperty,xi=vi.toString,Ei=RegExp("^"+mi.call(yi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wi=di.splice,Oi=Ti(fi,"Map"),_i=Ti(Object,"create");function Si(t){var e=-1,i=t?t.length:0;for(this.clear();++e-1},Ai.prototype.set=function(t,e){var i=this.__data__,r=Mi(i,t);return r<0?i.push([t,e]):i[r][1]=e,this},Li.prototype.clear=function(){this.__data__={hash:new Si,map:new(Oi||Ai),string:new Si}},Li.prototype.delete=function(t){return Wi(this,t).delete(t)},Li.prototype.get=function(t){return Wi(this,t).get(t)},Li.prototype.has=function(t){return Wi(this,t).has(t)},Li.prototype.set=function(t,e){return Wi(this,t).set(t,e),this},ji.Cache=Li;var Ni=ji,zi=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var i=-1;return t.some(function(t,r){return t[0]===e&&(i=r,!0)}),i}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var i=t(this.__entries__,e),r=this.__entries__[i];return r&&r[1]},e.prototype.set=function(e,i){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=i:this.__entries__.push([e,i])},e.prototype.delete=function(e){var i=this.__entries__,r=t(i,e);~r&&i.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var i=0,r=this.__entries__;i0},t.prototype.connect_=function(){Ci&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Hi?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){Ci&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,i=void 0===e?"":e;Pi.some(function(t){return!!~i.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),Fi=function(t,e){for(var i=0,r=Object.keys(e);i0},t}(),ir="undefined"!=typeof WeakMap?new WeakMap:new zi,rr=function(){return function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var i=qi.getInstance(),r=new er(e,i,this);ir.set(this,r)}}();["observe","unobserve","disconnect"].forEach(function(t){rr.prototype[t]=function(){var e;return(e=ir.get(this))[t].apply(e,arguments)}});var nr=void 0!==Vi.ResizeObserver?Vi.ResizeObserver:rr,sr=!("undefined"==typeof window||!window.document||!window.document.createElement),or=function(){function t(e,i){var r=this;this.onScroll=function(){r.scrollXTicking||(window.requestAnimationFrame(r.scrollX),r.scrollXTicking=!0),r.scrollYTicking||(window.requestAnimationFrame(r.scrollY),r.scrollYTicking=!0)},this.scrollX=function(){r.axis.x.isOverflowing&&(r.showScrollbar("x"),r.positionScrollbar("x")),r.scrollXTicking=!1},this.scrollY=function(){r.axis.y.isOverflowing&&(r.showScrollbar("y"),r.positionScrollbar("y")),r.scrollYTicking=!1},this.onMouseEnter=function(){r.showScrollbar("x"),r.showScrollbar("y")},this.onMouseMove=function(t){r.mouseX=t.clientX,r.mouseY=t.clientY,(r.axis.x.isOverflowing||r.axis.x.forceVisible)&&r.onMouseMoveForAxis("x"),(r.axis.y.isOverflowing||r.axis.y.forceVisible)&&r.onMouseMoveForAxis("y")},this.onMouseLeave=function(){r.onMouseMove.cancel(),(r.axis.x.isOverflowing||r.axis.x.forceVisible)&&r.onMouseLeaveForAxis("x"),(r.axis.y.isOverflowing||r.axis.y.forceVisible)&&r.onMouseLeaveForAxis("y"),r.mouseX=-1,r.mouseY=-1},this.onWindowResize=function(){r.scrollbarWidth=Ee(),r.hideNativeScrollbar()},this.hideScrollbars=function(){r.axis.x.track.rect=r.axis.x.track.el.getBoundingClientRect(),r.axis.y.track.rect=r.axis.y.track.el.getBoundingClientRect(),r.isWithinBounds(r.axis.y.track.rect)||(r.axis.y.scrollbar.el.classList.remove(r.classNames.visible),r.axis.y.isVisible=!1),r.isWithinBounds(r.axis.x.track.rect)||(r.axis.x.scrollbar.el.classList.remove(r.classNames.visible),r.axis.x.isVisible=!1)},this.onPointerEvent=function(t){var e,i;r.axis.x.scrollbar.rect=r.axis.x.scrollbar.el.getBoundingClientRect(),r.axis.y.scrollbar.rect=r.axis.y.scrollbar.el.getBoundingClientRect(),(r.axis.x.isOverflowing||r.axis.x.forceVisible)&&(i=r.isWithinBounds(r.axis.x.scrollbar.rect)),(r.axis.y.isOverflowing||r.axis.y.forceVisible)&&(e=r.isWithinBounds(r.axis.y.scrollbar.rect)),(e||i)&&(t.preventDefault(),t.stopPropagation(),"mousedown"===t.type&&(e&&r.onDragStart(t,"y"),i&&r.onDragStart(t,"x")))},this.drag=function(e){var i=r.axis[r.draggedAxis].track,n=i.rect[r.axis[r.draggedAxis].sizeAttr],s=r.axis[r.draggedAxis].scrollbar;e.preventDefault(),e.stopPropagation();var o=(("y"===r.draggedAxis?e.pageY:e.pageX)-i.rect[r.axis[r.draggedAxis].offsetAttr]-r.axis[r.draggedAxis].dragOffset)/i.rect[r.axis[r.draggedAxis].sizeAttr]*r.contentWrapperEl[r.axis[r.draggedAxis].scrollSizeAttr];"x"===r.draggedAxis&&(o=r.isRtl&&t.getRtlHelpers().isRtlScrollbarInverted?o-(n+s.size):o,o=r.isRtl&&t.getRtlHelpers().isRtlScrollingInverted?-o:o),r.contentWrapperEl[r.axis[r.draggedAxis].scrollOffsetAttr]=o},this.onEndDrag=function(t){t.preventDefault(),t.stopPropagation(),r.el.classList.remove(r.classNames.dragging),document.removeEventListener("mousemove",r.drag),document.removeEventListener("mouseup",r.onEndDrag)},this.el=e,this.flashTimeout,this.contentEl,this.contentWrapperEl,this.offsetEl,this.maskEl,this.globalObserver,this.mutationObserver,this.resizeObserver,this.scrollbarWidth,this.minScrollbarWidth=20,this.options=Object.assign({},t.defaultOptions,i),this.classNames=Object.assign({},t.defaultOptions.classNames,this.options.classNames),this.isRtl,this.axis={x:{scrollOffsetAttr:"scrollLeft",sizeAttr:"width",scrollSizeAttr:"scrollWidth",offsetAttr:"left",overflowAttr:"overflowX",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}},y:{scrollOffsetAttr:"scrollTop",sizeAttr:"height",scrollSizeAttr:"scrollHeight",offsetAttr:"top",overflowAttr:"overflowY",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}}},this.el.SimpleBar||(this.recalculate=Ie(this.recalculate.bind(this),64),this.onMouseMove=Ie(this.onMouseMove.bind(this),64),this.hideScrollbars=ni(this.hideScrollbars.bind(this),this.options.timeout),this.onWindowResize=ni(this.onWindowResize.bind(this),64,{leading:!0}),t.getRtlHelpers=Ni(t.getRtlHelpers),this.init())}t.getRtlHelpers=function(){var e=document.createElement("div");e.innerHTML='';var i=e.firstElementChild;document.body.appendChild(i);var r=i.firstElementChild;i.scrollLeft=0;var n=t.getOffset(i),s=t.getOffset(r);i.scrollLeft=999;var o=t.getOffset(r);return{isRtlScrollingInverted:n.left!==s.left&&s.left-o.left!=0,isRtlScrollbarInverted:n.left!==s.left}},t.initHtmlApi=function(){this.initDOMLoadedElements=this.initDOMLoadedElements.bind(this),"undefined"!=typeof MutationObserver&&(this.globalObserver=new MutationObserver(function(e){e.forEach(function(e){Array.prototype.forEach.call(e.addedNodes,function(e){1===e.nodeType&&(e.hasAttribute("data-simplebar")?!e.SimpleBar&&new t(e,t.getElOptions(e)):Array.prototype.forEach.call(e.querySelectorAll("[data-simplebar]"),function(e){!e.SimpleBar&&new t(e,t.getElOptions(e))}))}),Array.prototype.forEach.call(e.removedNodes,function(t){1===t.nodeType&&(t.hasAttribute("data-simplebar")?t.SimpleBar&&t.SimpleBar.unMount():Array.prototype.forEach.call(t.querySelectorAll("[data-simplebar]"),function(t){t.SimpleBar&&t.SimpleBar.unMount()}))})})}),this.globalObserver.observe(document,{childList:!0,subtree:!0})),"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?window.setTimeout(this.initDOMLoadedElements):(document.addEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.addEventListener("load",this.initDOMLoadedElements))},t.getElOptions=function(t){return Array.prototype.reduce.call(t.attributes,function(t,e){var i=e.name.match(/data-simplebar-(.+)/);if(i){var r=i[1].replace(/\W+(.)/g,function(t,e){return e.toUpperCase()});switch(e.value){case"true":t[r]=!0;break;case"false":t[r]=!1;break;case void 0:t[r]=!0;break;default:t[r]=e.value}}return t},{})},t.removeObserver=function(){this.globalObserver.disconnect()},t.initDOMLoadedElements=function(){document.removeEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.removeEventListener("load",this.initDOMLoadedElements),Array.prototype.forEach.call(document.querySelectorAll("[data-simplebar]"),function(e){e.SimpleBar||new t(e,t.getElOptions(e))})},t.getOffset=function(t){var e=t.getBoundingClientRect();return{top:e.top+(window.pageYOffset||document.documentElement.scrollTop),left:e.left+(window.pageXOffset||document.documentElement.scrollLeft)}};var e=t.prototype;return e.init=function(){this.el.SimpleBar=this,sr&&(this.initDOM(),this.scrollbarWidth=Ee(),this.recalculate(),this.initListeners())},e.initDOM=function(){var t=this;if(Array.prototype.filter.call(this.el.children,function(e){return e.classList.contains(t.classNames.wrapper)}).length)this.wrapperEl=this.el.querySelector("."+this.classNames.wrapper),this.contentWrapperEl=this.el.querySelector("."+this.classNames.contentWrapper),this.offsetEl=this.el.querySelector("."+this.classNames.offset),this.maskEl=this.el.querySelector("."+this.classNames.mask),this.contentEl=this.el.querySelector("."+this.classNames.contentEl),this.placeholderEl=this.el.querySelector("."+this.classNames.placeholder),this.heightAutoObserverWrapperEl=this.el.querySelector("."+this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl=this.el.querySelector("."+this.classNames.heightAutoObserverEl),this.axis.x.track.el=this.el.querySelector("."+this.classNames.track+"."+this.classNames.horizontal),this.axis.y.track.el=this.el.querySelector("."+this.classNames.track+"."+this.classNames.vertical);else{for(this.wrapperEl=document.createElement("div"),this.contentWrapperEl=document.createElement("div"),this.offsetEl=document.createElement("div"),this.maskEl=document.createElement("div"),this.contentEl=document.createElement("div"),this.placeholderEl=document.createElement("div"),this.heightAutoObserverWrapperEl=document.createElement("div"),this.heightAutoObserverEl=document.createElement("div"),this.wrapperEl.classList.add(this.classNames.wrapper),this.contentWrapperEl.classList.add(this.classNames.contentWrapper),this.offsetEl.classList.add(this.classNames.offset),this.maskEl.classList.add(this.classNames.mask),this.contentEl.classList.add(this.classNames.contentEl),this.placeholderEl.classList.add(this.classNames.placeholder),this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);this.el.firstChild;)this.contentEl.appendChild(this.el.firstChild);this.contentWrapperEl.appendChild(this.contentEl),this.offsetEl.appendChild(this.contentWrapperEl),this.maskEl.appendChild(this.offsetEl),this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl),this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl),this.wrapperEl.appendChild(this.maskEl),this.wrapperEl.appendChild(this.placeholderEl),this.el.appendChild(this.wrapperEl)}if(!this.axis.x.track.el||!this.axis.y.track.el){var e=document.createElement("div"),i=document.createElement("div");e.classList.add(this.classNames.track),i.classList.add(this.classNames.scrollbar),e.appendChild(i),this.axis.x.track.el=e.cloneNode(!0),this.axis.x.track.el.classList.add(this.classNames.horizontal),this.axis.y.track.el=e.cloneNode(!0),this.axis.y.track.el.classList.add(this.classNames.vertical),this.el.appendChild(this.axis.x.track.el),this.el.appendChild(this.axis.y.track.el)}this.axis.x.scrollbar.el=this.axis.x.track.el.querySelector("."+this.classNames.scrollbar),this.axis.y.scrollbar.el=this.axis.y.track.el.querySelector("."+this.classNames.scrollbar),this.options.autoHide||(this.axis.x.scrollbar.el.classList.add(this.classNames.visible),this.axis.y.scrollbar.el.classList.add(this.classNames.visible)),this.el.setAttribute("data-simplebar","init")},e.initListeners=function(){var t=this;this.options.autoHide&&this.el.addEventListener("mouseenter",this.onMouseEnter),["mousedown","click","dblclick","touchstart","touchend","touchmove"].forEach(function(e){t.el.addEventListener(e,t.onPointerEvent,!0)}),this.el.addEventListener("mousemove",this.onMouseMove),this.el.addEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.onWindowResize),this.resizeObserver=new nr(this.recalculate),this.resizeObserver.observe(this.el),this.resizeObserver.observe(this.contentEl)},e.recalculate=function(){var t=this.heightAutoObserverEl.offsetHeight<=1,e=this.heightAutoObserverEl.offsetWidth<=1;this.elStyles=window.getComputedStyle(this.el),this.isRtl="rtl"===this.elStyles.direction,this.contentEl.style.padding=this.elStyles.paddingTop+" "+this.elStyles.paddingRight+" "+this.elStyles.paddingBottom+" "+this.elStyles.paddingLeft,this.wrapperEl.style.margin="-"+this.elStyles.paddingTop+" -"+this.elStyles.paddingRight+" -"+this.elStyles.paddingBottom+" -"+this.elStyles.paddingLeft,this.contentWrapperEl.style.height=t?"auto":"100%",this.placeholderEl.style.width=e?this.contentEl.offsetWidth+"px":"auto",this.placeholderEl.style.height=this.contentEl.scrollHeight+"px",this.axis.x.isOverflowing=this.contentWrapperEl.scrollWidth>this.contentWrapperEl.offsetWidth,this.axis.y.isOverflowing=this.contentWrapperEl.scrollHeight>this.contentWrapperEl.offsetHeight,this.axis.x.isOverflowing="hidden"!==this.elStyles.overflowX&&this.axis.x.isOverflowing,this.axis.y.isOverflowing="hidden"!==this.elStyles.overflowY&&this.axis.y.isOverflowing,this.axis.x.forceVisible="x"===this.options.forceVisible||!0===this.options.forceVisible,this.axis.y.forceVisible="y"===this.options.forceVisible||!0===this.options.forceVisible,this.hideNativeScrollbar(),this.axis.x.track.rect=this.axis.x.track.el.getBoundingClientRect(),this.axis.y.track.rect=this.axis.y.track.el.getBoundingClientRect(),this.axis.x.scrollbar.size=this.getScrollbarSize("x"),this.axis.y.scrollbar.size=this.getScrollbarSize("y"),this.axis.x.scrollbar.el.style.width=this.axis.x.scrollbar.size+"px",this.axis.y.scrollbar.el.style.height=this.axis.y.scrollbar.size+"px",this.positionScrollbar("x"),this.positionScrollbar("y"),this.toggleTrackVisibility("x"),this.toggleTrackVisibility("y")},e.getScrollbarSize=function(t){void 0===t&&(t="y");var e,i=this.scrollbarWidth?this.contentWrapperEl[this.axis[t].scrollSizeAttr]:this.contentWrapperEl[this.axis[t].scrollSizeAttr]-this.minScrollbarWidth,r=this.axis[t].track.rect[this.axis[t].sizeAttr];if(this.axis[t].isOverflowing){var n=r/i;return e=Math.max(~~(n*r),this.options.scrollbarMinSize),this.options.scrollbarMaxSize&&(e=Math.min(e,this.options.scrollbarMaxSize)),e}},e.positionScrollbar=function(e){void 0===e&&(e="y");var i=this.contentWrapperEl[this.axis[e].scrollSizeAttr],r=this.axis[e].track.rect[this.axis[e].sizeAttr],n=parseInt(this.elStyles[this.axis[e].sizeAttr],10),s=this.axis[e].scrollbar,o=this.contentWrapperEl[this.axis[e].scrollOffsetAttr],a=(o="x"===e&&this.isRtl&&t.getRtlHelpers().isRtlScrollingInverted?-o:o)/(i-n),l=~~((r-s.size)*a);l="x"===e&&this.isRtl&&t.getRtlHelpers().isRtlScrollbarInverted?l+(r-s.size):l,s.el.style.transform="x"===e?"translate3d("+l+"px, 0, 0)":"translate3d(0, "+l+"px, 0)"},e.toggleTrackVisibility=function(t){void 0===t&&(t="y");var e=this.axis[t].track.el,i=this.axis[t].scrollbar.el;this.axis[t].isOverflowing||this.axis[t].forceVisible?(e.style.visibility="visible",this.contentWrapperEl.style[this.axis[t].overflowAttr]="scroll"):(e.style.visibility="hidden",this.contentWrapperEl.style[this.axis[t].overflowAttr]="hidden"),this.axis[t].isOverflowing?i.style.display="block":i.style.display="none"},e.hideNativeScrollbar=function(){if(this.offsetEl.style[this.isRtl?"left":"right"]=this.axis.y.isOverflowing||this.axis.y.forceVisible?"-"+(this.scrollbarWidth||this.minScrollbarWidth)+"px":0,this.offsetEl.style.bottom=this.axis.x.isOverflowing||this.axis.x.forceVisible?"-"+(this.scrollbarWidth||this.minScrollbarWidth)+"px":0,!this.scrollbarWidth){var t=[this.isRtl?"paddingLeft":"paddingRight"];this.contentWrapperEl.style[t]=this.axis.y.isOverflowing||this.axis.y.forceVisible?this.minScrollbarWidth+"px":0,this.contentWrapperEl.style.paddingBottom=this.axis.x.isOverflowing||this.axis.x.forceVisible?this.minScrollbarWidth+"px":0}},e.onMouseMoveForAxis=function(t){void 0===t&&(t="y"),this.axis[t].track.rect=this.axis[t].track.el.getBoundingClientRect(),this.axis[t].scrollbar.rect=this.axis[t].scrollbar.el.getBoundingClientRect(),this.isWithinBounds(this.axis[t].scrollbar.rect)?this.axis[t].scrollbar.el.classList.add(this.classNames.hover):this.axis[t].scrollbar.el.classList.remove(this.classNames.hover),this.isWithinBounds(this.axis[t].track.rect)?(this.showScrollbar(t),this.axis[t].track.el.classList.add(this.classNames.hover)):this.axis[t].track.el.classList.remove(this.classNames.hover)},e.onMouseLeaveForAxis=function(t){void 0===t&&(t="y"),this.axis[t].track.el.classList.remove(this.classNames.hover),this.axis[t].scrollbar.el.classList.remove(this.classNames.hover)},e.showScrollbar=function(t){void 0===t&&(t="y");var e=this.axis[t].scrollbar.el;this.axis[t].isVisible||(e.classList.add(this.classNames.visible),this.axis[t].isVisible=!0),this.options.autoHide&&this.hideScrollbars()},e.onDragStart=function(t,e){void 0===e&&(e="y");var i=this.axis[e].scrollbar.el,r="y"===e?t.pageY:t.pageX;this.axis[e].dragOffset=r-i.getBoundingClientRect()[this.axis[e].offsetAttr],this.draggedAxis=e,this.el.classList.add(this.classNames.dragging),document.addEventListener("mousemove",this.drag),document.addEventListener("mouseup",this.onEndDrag)},e.getContentElement=function(){return this.contentEl},e.getScrollElement=function(){return this.contentWrapperEl},e.removeListeners=function(){var t=this;this.options.autoHide&&this.el.removeEventListener("mouseenter",this.onMouseEnter),["mousedown","click","dblclick","touchstart","touchend","touchmove"].forEach(function(e){t.el.removeEventListener(e,t.onPointerEvent)}),this.el.removeEventListener("mousemove",this.onMouseMove),this.el.removeEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onWindowResize),this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver.disconnect(),this.recalculate.cancel(),this.onMouseMove.cancel(),this.hideScrollbars.cancel(),this.onWindowResize.cancel()},e.unMount=function(){this.removeListeners(),this.el.SimpleBar=null},e.isChildNode=function(t){return null!==t&&(t===this.el||this.isChildNode(t.parentNode))},e.isWithinBounds=function(t){return this.mouseX>=t.left&&this.mouseX<=t.left+t.width&&this.mouseY>=t.top&&this.mouseY<=t.top+t.height},t}();return or.defaultOptions={autoHide:!0,forceVisible:!1,classNames:{contentEl:"simplebar-content",contentWrapper:"simplebar-content-wrapper",offset:"simplebar-offset",mask:"simplebar-mask",wrapper:"simplebar-wrapper",placeholder:"simplebar-placeholder",scrollbar:"simplebar-scrollbar",track:"simplebar-track",heightAutoObserverWrapperEl:"simplebar-height-auto-observer-wrapper",heightAutoObserverEl:"simplebar-height-auto-observer",visible:"simplebar-visible",horizontal:"simplebar-horizontal",vertical:"simplebar-vertical",hover:"simplebar-hover",dragging:"simplebar-dragging"},scrollbarMinSize:25,scrollbarMaxSize:0,timeout:1e3},sr&&or.initHtmlApi(),or});
-
-/* ---------------------------------------------- /*
- * POPUP
-/* ---------------------------------------------- */
-if (typeof jQuery != 'undefined') {
- var $ = jQuery.noConflict();
-}
-
-function ncPopupTips(type, msg) {
- var ico = type ? '' : '';
- var c = type ? 'tips-success' : 'tips-error';
- var html = '';
- var tips = $(html);
- $('body').append(tips);
- $('body').addClass('modal-open');
- if (typeof lazyLoadInstance !== "undefined") {
- lazyLoadInstance.update();
- }
-
- setTimeout(function(){
- $('body').removeClass('modal-open');
- tips.removeClass('nice-tips-open');
- tips.addClass('nice-tips-close');
-
- setTimeout(function(){
- tips.removeClass('nice-tips-close');
- setTimeout(function(){
- tips.remove();
- }, 200);
- },400);
- },1200);
-}
-
-function ncPopup(type, html, maskStyle, btnCallBack) {
-
- var maskStyle = maskStyle ? 'style="' + maskStyle + '"' : '';
-
- var size = '';
-
- if( type == 'big' ){
- size = 'nice-tips-lg';
- }else if( type == 'no-padding' ){
- size = 'nice-tips-nopd';
- }else if( type == 'cover' ){
- size = 'nice-tips-cover nice-tips-nopd';
- }else if( type == 'full' ){
- size = 'nice-tips-xl';
- }else if( type == 'scroll' ){
- size = 'nice-tips-scroll';
- }else if( type == 'middle' ){
- size = 'nice-tips-md';
- }else if( type == 'small' ){
- size = 'nice-tips-sm';
- }
-
- var template = '\
- \
- \
- \
- \
- '+html+'\
- \
- \
- \
- \
- ';
-
- var popup = $(template);
- $('body').append(popup);
- $('body').addClass('modal-open');
- if (typeof lazyLoadInstance !== "undefined") {
- lazyLoadInstance.update();
- }
-
- var close = function(){
- $('body').removeClass('modal-open');
- $(popup).removeClass('nice-tips-open');
- $(popup).addClass('nice-tips-close');
- setTimeout(function(){
- $(popup).removeClass('nice-tips-close');
- setTimeout(function(){
- popup.remove();
- }, 200);
- },600);
- }
-
- $(popup).on('click touchstart', '.btn-close-tips, .nice-tips-overlay', function(event) {
- event.preventDefault();
- close();
- });
-
-
- if( typeof btnCallBack == 'object' ){
- Object.keys(btnCallBack).forEach(function(key){
-
- $(popup).on('click touchstart', key, function(event) {
-
- var ret = btnCallBack[key](event, close);
-
- });
-
- });
- }
- return popup;
-}
diff --git a/modules/pluggable/custom_date.php b/modules/pluggable/custom_date.php
deleted file mode 100644
index 3a46090..0000000
--- a/modules/pluggable/custom_date.php
+++ /dev/null
@@ -1,66 +0,0 @@
- 0 ){
-
- $etime = strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - $current_offset * 60 * 60 - $ptime;
-
- }else if( $current_offset < 0 ){
-
- $etime = strtotime( date_i18n( 'Y-m-d H:i:s' ) ) + $current_offset * 60 * 60 - $ptime;
-
- }else{
- $etime = strtotime( date_i18n( 'Y-m-d H:i:s' ) ) - $ptime;
- }
-
-
- if($etime < 1) return '刚刚';
-
- $interval = array (
- 12 * 30 * 24 * 60 * 60 => date('Y-m-d', $ptime),
- 30 * 24 * 60 * 60 => date('m-d', $ptime),
- 7 * 24 * 60 * 60 => date('m-d', $ptime),
- 24 * 60 * 60 => '天前',
- 60 * 60 => '小时前',
- 60 => '分钟前',
- 1 => '秒前'
- );
- foreach ($interval as $secs => $str) {
- if( $etime - ( 24 * 60 * 60 ) > 0 ){
- return $str;
- } else {
- $d = $etime / $secs;
- if ($d >= 1) {
- $r = round($d);
- return $r . $str;
- }
- }
-
- }
- }
-}
\ No newline at end of file
diff --git a/modules/pluggable/custom_share.php b/modules/pluggable/custom_share.php
deleted file mode 100644
index d3cd5be..0000000
--- a/modules/pluggable/custom_share.php
+++ /dev/null
@@ -1,258 +0,0 @@
-config = $nc_option['wechat_qq_share_custom_conf'];
-
- add_action( 'wp_enqueue_scripts', array( $this, 'mi_add_share_js' ) );
-
- add_action( 'wp_footer', array( $this, 'mi_add_share_info' ), 2333 );
-
- }
-
- function mi_add_share_js(){
- wp_enqueue_script( 'mi-share-js', '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js', array(), NC_OPTIMIZEUP_VERSION, 'all' );
- }
-
- function get_signature_url(){
- $protocol = is_ssl() ? 'https://' : 'http://';
- $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- $url = explode('#', $url);
- $url = $url[0];
-
- return $url;
- }
-
- //获取Access Token
- function get_access_token(){
-
- if( ($access_token = get_option('ws_access_token')) !== false && $access_token != '' && time() < $access_token['expire_time']){
- return $access_token['access_token'];
- }
-
- $api_url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='. $this->config['share_appid'] .'&secret='. $this->config[ 'appsecret' ];
- $response = wp_remote_get($api_url);
- if ( is_array( $response ) && ! is_wp_error($response) ){
- $result = json_decode($response['body']);
- } else {
- return false;
- }
-
- $access_token['access_token'] = !$result->errcode ? $result->access_token : '';
- $access_token['expire_time'] = !$result->errcode ? time() + intval( $result->expires_in ) : '';
- update_option( 'ws_access_token', $access_token );
-
- return $access_token['access_token'];
- }
-
- //获取JSAPI TICKET
- function get_jsapi_ticket(){
- if( ($jsapi_ticket = get_option('wx_jsapi_ticket')) !== false && $jsapi_ticket != '' && time() < $jsapi_ticket['expire_time']){
- return $jsapi_ticket['jsapi_ticket'];
- }
-
- if( ($access_token = $this->get_access_token()) === false ) return false;
- $api_url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='. $access_token .'&type=jsapi';
- $response = wp_remote_get($api_url);
- if ( is_array( $response ) && ! is_wp_error($response) ){
- $result = json_decode($response['body']);
- }
- else{
- return false;
- }
-
- $jsapi_ticket['jsapi_ticket'] = !$result->errcode ? $result->ticket : '';
- $jsapi_ticket['expire_time'] = !$result->errcode ? time() + intval( $result->expires_in ) : '';
- update_option( 'wx_jsapi_ticket', $jsapi_ticket );
-
- return $jsapi_ticket['jsapi_ticket'];
- }
-
- //生成随机字符串
- function generate_noncestr( $length = 16 ){
-
- $noncestr = '';
-
- $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
- for( $i = 0; $i < $length; $i++ ){
- $noncestr .= $chars[ mt_rand(0, strlen($chars) - 1) ];
- }
- return $noncestr;
- }
-
- //生成签名
- function generate_signature($jsapi_ticket, $noncestr, $timestamp, $url){
- $str = 'jsapi_ticket='. $jsapi_ticket .'&noncestr='. $noncestr .'×tamp='. $timestamp .'&url='. $url;
- return sha1($str);
- }
-
- function get_wx_config(){
-
- if( $this->config['share_appid'] && $this->config[ 'appsecret' ] && ( $jsapi_ticket = $this->get_jsapi_ticket() ) !== false ){
- $noncestr = $this->generate_noncestr();
- $timestamp = time();
- $signature_url = $this->get_signature_url();
- $signature = $this->generate_signature($jsapi_ticket, $noncestr, $timestamp, $signature_url);
-
- $config = array(
- 'noncestr' => $noncestr,
- 'timestamp' => $timestamp,
- 'signature' => $signature,
- );
- }else{
- $config = null;
- }
-
- return $config;
-
- }
-
- function get_share_info(){
-
- $info = array();
-
- if( is_single() || is_singular() ){
-
- global $post;
-
- if( has_post_thumbnail( $post->ID ) ){
-
- $post_thumbnail_src = get_post_thumbnail_id($post->ID);
- $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_src, 'full');
- $pic = $post_thumbnail_src[0];
-
- }else{
-
- $preg = '//i';
- preg_match_all($preg, apply_filters( 'the_content', $post->post_content ), $match);
-
- if( isset( $match[1][0] ) && !empty( $match[1][0] ) ){
-
- $pic = $match[1][0];
-
- }else{
-
- $pic = $this->config['share_img'];
-
- }
-
- }
-
- $pic = isset( $pic ) ? $pic : NC_BASE_URL . 'library/static/default.png';
-
-
-
- $info = array(
- 'title' => $this->config['share_title_in_single'] ? $this->config[ 'share_title' ] . $this->config[ 'share_title_in_single_line' ] . get_the_title() : get_the_title(),
- 'summary' => get_the_excerpt(),
- 'url' => get_permalink(),
- 'pic' => $pic,
- );
-
-
- }else{
-
- $pngdata = NC_BASE_URL . 'library/static/default.png';
-
- if( isset( $this->config[ 'share_img' ] ) && is_numeric( $this->config[ 'share_img' ] ) ){
- $att = wp_get_attachment_image_url( $this->config[ 'share_img' ], 'full' );
- }else if( isset( $this->config[ 'share_img' ] ) && !empty( $this->config[ 'share_img' ] ) ) {
- $att = $this->config[ 'share_img' ];
- }
-
- if( isset( $att ) ){
- $pic = $att;
- }else{
- $pic = null;
- }
-
- $info = array(
- 'title' => $this->config[ 'share_title' ] ? $this->config[ 'share_title' ] : get_bloginfo( 'name' ),
- 'summary' => $this->config[ 'share_summary' ] ? $this->config[ 'share_summary' ] :get_bloginfo( 'description' ),
- 'url' => $this->get_signature_url(),
- 'pic' => $pic ? $pic : $pngdata,
- );
-
-
- }
-
- return $info;
-
- }
-
- function mi_add_share_info(){
-
- $info = $this->get_share_info();
-
- $wxconfig = $this->get_wx_config();
- $wxappid = $this->config['share_appid'];
-
- if( $wxconfig && $wxappid ){
- $WXconfig = <<
-
- setShareInfo({
- title: '{$info['title']}',
- summary: '{$info['summary']}',
- pic: '{$info['pic']}',
- url: '{$info['url']}',
- {$WXconfig}
- });
-
-
-SCRIPT;
-
- echo $script;
-
- }
-
-
-}
-
-new MiCustomShare();
-
-endif;
diff --git a/modules/pluggable/load.php b/modules/pluggable/load.php
deleted file mode 100644
index 8a95c33..0000000
--- a/modules/pluggable/load.php
+++ /dev/null
@@ -1,23 +0,0 @@
-config = array(
- 'url' => get_permalink(),
- 'title' => get_the_title(),
- 'pic' => null,
- 'des' => wp_trim_words( get_the_excerpt(), 55, null ),
- );
-
- }
-
- function __set($property,$value){
- $this->$property = $value;
- }
-
- /**
- * [weibo Share]
- * @return [str] [ Share api link]
- */
- public function weibo() {
-
- $pic = isset($this->config['pic']) ? '&pic='.urlencode( $this->config['pic'] ) : '';
-
- if( isset( $this->config['des'] ) ){
- $text = urlencode( sprintf( '【%s】%s', $this->config['title'], $this->config['des']) );
- }else{
- $text = $this->config['title'];
- }
-
- $share_link = sprintf( '//service.weibo.com/share/share.php?url=%s&type=button&language=zh_cn&title=%s%s&searchPic=true', urlencode( $this->config['url'] ), $text , $pic );
-
- return $share_link;
-
- }
-
- /**
- * [qq Share]
- * @return [str] [ Share api link]
- */
- public function qq() {
-
- $pic = isset($this->config['pic']) ? '&pics='.urlencode( $this->config['pic'] ) : '';
-
- $des = isset($this->config['des']) ? '&summary='.urlencode($this->config['des']) : '';
-
- $share_link = sprintf( 'https://connect.qq.com/widget/shareqq/index.html?url=%s&title=%s%s%s', urlencode( $this->config['url'] ), urlencode($this->config['title']), $pic, $des );
-
- return $share_link;
-
-
- }
-
- /**
- * [weixin Share]
- * @return [str] [Share qrcode link]
- */
- public function weixin() {
-
- $share_link = NC_BASE_URL . 'modules/qrcode/qrcode.php?data='.urlencode( $this->config['url'] );
-
- return $share_link;
-
- }
-
- /**
- * facebook
- */
- public function facebook(){
- $share_link = sprintf( 'https://www.facebook.com/sharer.php?u=%s', urlencode( $this->config['url'] ) );
- return $share_link;
- }
-
- /**
- * twitter
- */
- public function twitter(){
- $share_link = sprintf( 'https://twitter.com/intent/tweet?url=%s', urlencode( $this->config['url'] ) );
- return $share_link;
- }
-
- /**
- * linkedin
- */
- public function linkedin(){
- $share_link = sprintf( 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s', urlencode( $this->config['url'] ), urlencode($this->config['title']), urlencode($this->config['des']) );
- return $share_link;
- }
-
-
-}
-
-endif;
-// $s = new MiShare();
-// $s->config = array( 'url' => 'https://www.baidu.com', 'title' => '标题', 'pic' => 'https://cdn.v2ex.com/gravatar/afa39accf8700cbbe7b13e1d01aa5b17', 'des' => '123');
-
-// echo $s->weixin();
-
diff --git a/modules/qrcode/phpqrcode.php b/modules/qrcode/phpqrcode.php
deleted file mode 100644
index ea8c08f..0000000
--- a/modules/qrcode/phpqrcode.php
+++ /dev/null
@@ -1,3312 +0,0 @@
-
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-/*
- * Version: 1.1.4
- * Build: 2010100721
- */
-
-
-
-//---- qrconst.php -----------------------------
-
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Common constants
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- // Encoding modes
-
- define('QR_MODE_NUL', -1);
- define('QR_MODE_NUM', 0);
- define('QR_MODE_AN', 1);
- define('QR_MODE_8', 2);
- define('QR_MODE_KANJI', 3);
- define('QR_MODE_STRUCTURE', 4);
-
- // Levels of error correction.
-
- define('QR_ECLEVEL_L', 0);
- define('QR_ECLEVEL_M', 1);
- define('QR_ECLEVEL_Q', 2);
- define('QR_ECLEVEL_H', 3);
-
- // Supported output formats
-
- define('QR_FORMAT_TEXT', 0);
- define('QR_FORMAT_PNG', 1);
-
- class qrstr {
- public static function set(&$srctab, $x, $y, $repl, $replLen = false) {
- $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
- }
- }
-
-
-
-//---- merged_config.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Config file, tuned-up for merged verion
- */
-
- define('QR_CACHEABLE', false); // use cache - more disk reads but less CPU power, masks and format templates are stored there
- define('QR_CACHE_DIR', false); // used when QR_CACHEABLE === true
- define('QR_LOG_DIR', false); // default error logs dir
-
- define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
- define('QR_FIND_FROM_RANDOM', 2); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
- define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
-
- define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
-
-
-
-
-//---- qrtools.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Toolset, handy and debug utilites.
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- class QRtools {
-
- //----------------------------------------------------------------------
- public static function binarize($frame)
- {
- $len = count($frame);
- foreach ($frame as &$frameLine) {
-
- for($i=0; $i<$len; $i++) {
- $frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0';
- }
- }
-
- return $frame;
- }
-
- //----------------------------------------------------------------------
- public static function tcpdfBarcodeArray($code, $mode = 'QR,L', $tcPdfVersion = '4.5.037')
- {
- $barcode_array = array();
-
- if (!is_array($mode))
- $mode = explode(',', $mode);
-
- $eccLevel = 'L';
-
- if (count($mode) > 1) {
- $eccLevel = $mode[1];
- }
-
- $qrTab = QRcode::text($code, false, $eccLevel);
- $size = count($qrTab);
-
- $barcode_array['num_rows'] = $size;
- $barcode_array['num_cols'] = $size;
- $barcode_array['bcode'] = array();
-
- foreach ($qrTab as $line) {
- $arrAdd = array();
- foreach(str_split($line) as $char)
- $arrAdd[] = ($char=='1')?1:0;
- $barcode_array['bcode'][] = $arrAdd;
- }
-
- return $barcode_array;
- }
-
- //----------------------------------------------------------------------
- public static function clearCache()
- {
- self::$frames = array();
- }
-
- //----------------------------------------------------------------------
- public static function buildCache()
- {
- QRtools::markTime('before_build_cache');
-
- $mask = new QRmask();
- for ($a=1; $a <= QRSPEC_VERSION_MAX; $a++) {
- $frame = QRspec::newFrame($a);
- if (QR_IMAGE) {
- $fileName = QR_CACHE_DIR.'frame_'.$a.'.png';
- QRimage::png(self::binarize($frame), $fileName, 1, 0);
- }
-
- $width = count($frame);
- $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
- for ($maskNo=0; $maskNo<8; $maskNo++)
- $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
- }
-
- QRtools::markTime('after_build_cache');
- }
-
- //----------------------------------------------------------------------
- public static function log($outfile, $err)
- {
- if (QR_LOG_DIR !== false) {
- if ($err != '') {
- if ($outfile !== false) {
- file_put_contents(QR_LOG_DIR.basename($outfile).'-errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND);
- } else {
- file_put_contents(QR_LOG_DIR.'errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND);
- }
- }
- }
- }
-
- //----------------------------------------------------------------------
- public static function dumpMask($frame)
- {
- $width = count($frame);
- for($y=0;$y<$width;$y++) {
- for($x=0;$x<$width;$x++) {
- echo ord($frame[$y][$x]).',';
- }
- }
- }
-
- //----------------------------------------------------------------------
- public static function markTime($markerId)
- {
- list($usec, $sec) = explode(" ", microtime());
- $time = ((float)$usec + (float)$sec);
-
- if (!isset($GLOBALS['qr_time_bench']))
- $GLOBALS['qr_time_bench'] = array();
-
- $GLOBALS['qr_time_bench'][$markerId] = $time;
- }
-
- //----------------------------------------------------------------------
- public static function timeBenchmark()
- {
- self::markTime('finish');
-
- $lastTime = 0;
- $startTime = 0;
- $p = 0;
-
- echo '
- BENCHMARK |
- ';
-
- foreach($GLOBALS['qr_time_bench'] as $markerId=>$thisTime) {
- if ($p > 0) {
- echo 'till '.$markerId.': | '.number_format($thisTime-$lastTime, 6).'s | ';
- } else {
- $startTime = $thisTime;
- }
-
- $p++;
- $lastTime = $thisTime;
- }
-
- echo '
- TOTAL: | '.number_format($lastTime-$startTime, 6).'s |
-
- ';
- }
-
- }
-
- //##########################################################################
-
- QRtools::markTime('start');
-
-
-
-
-//---- qrspec.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * QR Code specifications
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * The following data / specifications are taken from
- * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
- * or
- * "Automatic identification and data capture techniques --
- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- define('QRSPEC_VERSION_MAX', 40);
- define('QRSPEC_WIDTH_MAX', 177);
-
- define('QRCAP_WIDTH', 0);
- define('QRCAP_WORDS', 1);
- define('QRCAP_REMINDER', 2);
- define('QRCAP_EC', 3);
-
- class QRspec {
-
- public static $capacity = array(
- array( 0, 0, 0, array( 0, 0, 0, 0)),
- array( 21, 26, 0, array( 7, 10, 13, 17)), // 1
- array( 25, 44, 7, array( 10, 16, 22, 28)),
- array( 29, 70, 7, array( 15, 26, 36, 44)),
- array( 33, 100, 7, array( 20, 36, 52, 64)),
- array( 37, 134, 7, array( 26, 48, 72, 88)), // 5
- array( 41, 172, 7, array( 36, 64, 96, 112)),
- array( 45, 196, 0, array( 40, 72, 108, 130)),
- array( 49, 242, 0, array( 48, 88, 132, 156)),
- array( 53, 292, 0, array( 60, 110, 160, 192)),
- array( 57, 346, 0, array( 72, 130, 192, 224)), //10
- array( 61, 404, 0, array( 80, 150, 224, 264)),
- array( 65, 466, 0, array( 96, 176, 260, 308)),
- array( 69, 532, 0, array( 104, 198, 288, 352)),
- array( 73, 581, 3, array( 120, 216, 320, 384)),
- array( 77, 655, 3, array( 132, 240, 360, 432)), //15
- array( 81, 733, 3, array( 144, 280, 408, 480)),
- array( 85, 815, 3, array( 168, 308, 448, 532)),
- array( 89, 901, 3, array( 180, 338, 504, 588)),
- array( 93, 991, 3, array( 196, 364, 546, 650)),
- array( 97, 1085, 3, array( 224, 416, 600, 700)), //20
- array(101, 1156, 4, array( 224, 442, 644, 750)),
- array(105, 1258, 4, array( 252, 476, 690, 816)),
- array(109, 1364, 4, array( 270, 504, 750, 900)),
- array(113, 1474, 4, array( 300, 560, 810, 960)),
- array(117, 1588, 4, array( 312, 588, 870, 1050)), //25
- array(121, 1706, 4, array( 336, 644, 952, 1110)),
- array(125, 1828, 4, array( 360, 700, 1020, 1200)),
- array(129, 1921, 3, array( 390, 728, 1050, 1260)),
- array(133, 2051, 3, array( 420, 784, 1140, 1350)),
- array(137, 2185, 3, array( 450, 812, 1200, 1440)), //30
- array(141, 2323, 3, array( 480, 868, 1290, 1530)),
- array(145, 2465, 3, array( 510, 924, 1350, 1620)),
- array(149, 2611, 3, array( 540, 980, 1440, 1710)),
- array(153, 2761, 3, array( 570, 1036, 1530, 1800)),
- array(157, 2876, 0, array( 570, 1064, 1590, 1890)), //35
- array(161, 3034, 0, array( 600, 1120, 1680, 1980)),
- array(165, 3196, 0, array( 630, 1204, 1770, 2100)),
- array(169, 3362, 0, array( 660, 1260, 1860, 2220)),
- array(173, 3532, 0, array( 720, 1316, 1950, 2310)),
- array(177, 3706, 0, array( 750, 1372, 2040, 2430)) //40
- );
-
- //----------------------------------------------------------------------
- public static function getDataLength($version, $level)
- {
- return self::$capacity[$version][QRCAP_WORDS] - self::$capacity[$version][QRCAP_EC][$level];
- }
-
- //----------------------------------------------------------------------
- public static function getECCLength($version, $level)
- {
- return self::$capacity[$version][QRCAP_EC][$level];
- }
-
- //----------------------------------------------------------------------
- public static function getWidth($version)
- {
- return self::$capacity[$version][QRCAP_WIDTH];
- }
-
- //----------------------------------------------------------------------
- public static function getRemainder($version)
- {
- return self::$capacity[$version][QRCAP_REMINDER];
- }
-
- //----------------------------------------------------------------------
- public static function getMinimumVersion($size, $level)
- {
-
- for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) {
- $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level];
- if($words >= $size)
- return $i;
- }
-
- return -1;
- }
-
- //######################################################################
-
- public static $lengthTableBits = array(
- array(10, 12, 14),
- array( 9, 11, 13),
- array( 8, 16, 16),
- array( 8, 10, 12)
- );
-
- //----------------------------------------------------------------------
- public static function lengthIndicator($mode, $version)
- {
- if ($mode == QR_MODE_STRUCTURE)
- return 0;
-
- if ($version <= 9) {
- $l = 0;
- } else if ($version <= 26) {
- $l = 1;
- } else {
- $l = 2;
- }
-
- return self::$lengthTableBits[$mode][$l];
- }
-
- //----------------------------------------------------------------------
- public static function maximumWords($mode, $version)
- {
- if($mode == QR_MODE_STRUCTURE)
- return 3;
-
- if($version <= 9) {
- $l = 0;
- } else if($version <= 26) {
- $l = 1;
- } else {
- $l = 2;
- }
-
- $bits = self::$lengthTableBits[$mode][$l];
- $words = (1 << $bits) - 1;
-
- if($mode == QR_MODE_KANJI) {
- $words *= 2; // the number of bytes is required
- }
-
- return $words;
- }
-
- // Error correction code -----------------------------------------------
- // Table of the error correction code (Reed-Solomon block)
- // See Table 12-16 (pp.30-36), JIS X0510:2004.
-
- public static $eccTable = array(
- array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)),
- array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1
- array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)),
- array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)),
- array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)),
- array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5
- array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)),
- array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)),
- array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)),
- array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)),
- array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), //10
- array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)),
- array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)),
- array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)),
- array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)),
- array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), //15
- array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)),
- array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)),
- array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)),
- array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)),
- array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), //20
- array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)),
- array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)),
- array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)),
- array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)),
- array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), //25
- array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)),
- array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)),
- array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)),
- array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)),
- array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), //30
- array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)),
- array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)),
- array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)),
- array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)),
- array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), //35
- array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)),
- array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)),
- array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)),
- array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)),
- array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)),//40
- );
-
- //----------------------------------------------------------------------
- // CACHEABLE!!!
-
- public static function getEccSpec($version, $level, array &$spec)
- {
- if (count($spec) < 5) {
- $spec = array(0,0,0,0,0);
- }
-
- $b1 = self::$eccTable[$version][$level][0];
- $b2 = self::$eccTable[$version][$level][1];
- $data = self::getDataLength($version, $level);
- $ecc = self::getECCLength($version, $level);
-
- if($b2 == 0) {
- $spec[0] = $b1;
- $spec[1] = (int)($data / $b1);
- $spec[2] = (int)($ecc / $b1);
- $spec[3] = 0;
- $spec[4] = 0;
- } else {
- $spec[0] = $b1;
- $spec[1] = (int)($data / ($b1 + $b2));
- $spec[2] = (int)($ecc / ($b1 + $b2));
- $spec[3] = $b2;
- $spec[4] = $spec[1] + 1;
- }
- }
-
- // Alignment pattern ---------------------------------------------------
-
- // Positions of alignment patterns.
- // This array includes only the second and the third position of the
- // alignment patterns. Rest of them can be calculated from the distance
- // between them.
-
- // See Table 1 in Appendix E (pp.71) of JIS X0510:2004.
-
- public static $alignmentPattern = array(
- array( 0, 0),
- array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5
- array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10
- array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), //11-15
- array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), //16-20
- array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), //21-25
- array(30, 58), array(34, 62), array(26, 50), array(30, 54), array(26, 52), //26-30
- array(30, 56), array(34, 60), array(30, 58), array(34, 62), array(30, 54), //31-35
- array(24, 50), array(28, 54), array(32, 58), array(26, 54), array(30, 58), //35-40
- );
-
-
- /** --------------------------------------------------------------------
- * Put an alignment marker.
- * @param frame
- * @param width
- * @param ox,oy center coordinate of the pattern
- */
- public static function putAlignmentMarker(array &$frame, $ox, $oy)
- {
- $finder = array(
- "\xa1\xa1\xa1\xa1\xa1",
- "\xa1\xa0\xa0\xa0\xa1",
- "\xa1\xa0\xa1\xa0\xa1",
- "\xa1\xa0\xa0\xa0\xa1",
- "\xa1\xa1\xa1\xa1\xa1"
- );
-
- $yStart = $oy-2;
- $xStart = $ox-2;
-
- for($y=0; $y<5; $y++) {
- QRstr::set($frame, $xStart, $yStart+$y, $finder[$y]);
- }
- }
-
- //----------------------------------------------------------------------
- public static function putAlignmentPattern($version, &$frame, $width)
- {
- if($version < 2)
- return;
-
- $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0];
- if($d < 0) {
- $w = 2;
- } else {
- $w = (int)(($width - self::$alignmentPattern[$version][0]) / $d + 2);
- }
-
- if($w * $w - 3 == 1) {
- $x = self::$alignmentPattern[$version][0];
- $y = self::$alignmentPattern[$version][0];
- self::putAlignmentMarker($frame, $x, $y);
- return;
- }
-
- $cx = self::$alignmentPattern[$version][0];
- for($x=1; $x<$w - 1; $x++) {
- self::putAlignmentMarker($frame, 6, $cx);
- self::putAlignmentMarker($frame, $cx, 6);
- $cx += $d;
- }
-
- $cy = self::$alignmentPattern[$version][0];
- for($y=0; $y<$w-1; $y++) {
- $cx = self::$alignmentPattern[$version][0];
- for($x=0; $x<$w-1; $x++) {
- self::putAlignmentMarker($frame, $cx, $cy);
- $cx += $d;
- }
- $cy += $d;
- }
- }
-
- // Version information pattern -----------------------------------------
-
- // Version information pattern (BCH coded).
- // See Table 1 in Appendix D (pp.68) of JIS X0510:2004.
-
- // size: [QRSPEC_VERSION_MAX - 6]
-
- public static $versionPattern = array(
- 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d,
- 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9,
- 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75,
- 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64,
- 0x27541, 0x28c69
- );
-
- //----------------------------------------------------------------------
- public static function getVersionPattern($version)
- {
- if($version < 7 || $version > QRSPEC_VERSION_MAX)
- return 0;
-
- return self::$versionPattern[$version -7];
- }
-
- // Format information --------------------------------------------------
- // See calcFormatInfo in tests/test_qrspec.c (orginal qrencode c lib)
-
- public static $formatInfo = array(
- array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976),
- array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0),
- array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed),
- array(0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b)
- );
-
- public static function getFormatInfo($mask, $level)
- {
- if($mask < 0 || $mask > 7)
- return 0;
-
- if($level < 0 || $level > 3)
- return 0;
-
- return self::$formatInfo[$level][$mask];
- }
-
- // Frame ---------------------------------------------------------------
- // Cache of initial frames.
-
- public static $frames = array();
-
- /** --------------------------------------------------------------------
- * Put a finder pattern.
- * @param frame
- * @param width
- * @param ox,oy upper-left coordinate of the pattern
- */
- public static function putFinderPattern(&$frame, $ox, $oy)
- {
- $finder = array(
- "\xc1\xc1\xc1\xc1\xc1\xc1\xc1",
- "\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
- "\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
- "\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
- "\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
- "\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
- "\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
- );
-
- for($y=0; $y<7; $y++) {
- QRstr::set($frame, $ox, $oy+$y, $finder[$y]);
- }
- }
-
- //----------------------------------------------------------------------
- public static function createFrame($version)
- {
- $width = self::$capacity[$version][QRCAP_WIDTH];
- $frameLine = str_repeat ("\0", $width);
- $frame = array_fill(0, $width, $frameLine);
-
- // Finder pattern
- self::putFinderPattern($frame, 0, 0);
- self::putFinderPattern($frame, $width - 7, 0);
- self::putFinderPattern($frame, 0, $width - 7);
-
- // Separator
- $yOffset = $width - 7;
-
- for($y=0; $y<7; $y++) {
- $frame[$y][7] = "\xc0";
- $frame[$y][$width - 8] = "\xc0";
- $frame[$yOffset][7] = "\xc0";
- $yOffset++;
- }
-
- $setPattern = str_repeat("\xc0", 8);
-
- QRstr::set($frame, 0, 7, $setPattern);
- QRstr::set($frame, $width-8, 7, $setPattern);
- QRstr::set($frame, 0, $width - 8, $setPattern);
-
- // Format info
- $setPattern = str_repeat("\x84", 9);
- QRstr::set($frame, 0, 8, $setPattern);
- QRstr::set($frame, $width - 8, 8, $setPattern, 8);
-
- $yOffset = $width - 8;
-
- for($y=0; $y<8; $y++,$yOffset++) {
- $frame[$y][8] = "\x84";
- $frame[$yOffset][8] = "\x84";
- }
-
- // Timing pattern
-
- for($i=1; $i<$width-15; $i++) {
- $frame[6][7+$i] = chr(0x90 | ($i & 1));
- $frame[7+$i][6] = chr(0x90 | ($i & 1));
- }
-
- // Alignment pattern
- self::putAlignmentPattern($version, $frame, $width);
-
- // Version information
- if($version >= 7) {
- $vinf = self::getVersionPattern($version);
-
- $v = $vinf;
-
- for($x=0; $x<6; $x++) {
- for($y=0; $y<3; $y++) {
- $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
- $v = $v >> 1;
- }
- }
-
- $v = $vinf;
- for($y=0; $y<6; $y++) {
- for($x=0; $x<3; $x++) {
- $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
- $v = $v >> 1;
- }
- }
- }
-
- // and a little bit...
- $frame[$width - 8][8] = "\x81";
-
- return $frame;
- }
-
- //----------------------------------------------------------------------
- public static function debug($frame, $binary_mode = false)
- {
- if ($binary_mode) {
-
- foreach ($frame as &$frameLine) {
- $frameLine = join(' ', explode('0', $frameLine));
- $frameLine = join('██', explode('1', $frameLine));
- }
-
- ?>
-
-
';
- echo join(" ", $frame);
- echo '
';
-
- } else {
-
- foreach ($frame as &$frameLine) {
- $frameLine = join(' ', explode("\xc0", $frameLine));
- $frameLine = join('▒', explode("\xc1", $frameLine));
- $frameLine = join(' ', explode("\xa0", $frameLine));
- $frameLine = join('▒', explode("\xa1", $frameLine));
- $frameLine = join('◇', explode("\x84", $frameLine)); //format 0
- $frameLine = join('◆', explode("\x85", $frameLine)); //format 1
- $frameLine = join('☢', explode("\x81", $frameLine)); //special bit
- $frameLine = join(' ', explode("\x90", $frameLine)); //clock 0
- $frameLine = join('◷', explode("\x91", $frameLine)); //clock 1
- $frameLine = join(' ', explode("\x88", $frameLine)); //version
- $frameLine = join('▒', explode("\x89", $frameLine)); //version
- $frameLine = join('♦', explode("\x01", $frameLine));
- $frameLine = join('⋅', explode("\0", $frameLine));
- }
-
- ?>
-
- ";
- echo join(" ", $frame);
- echo "";
-
- }
- }
-
- //----------------------------------------------------------------------
- public static function serial($frame)
- {
- return gzcompress(join("\n", $frame), 9);
- }
-
- //----------------------------------------------------------------------
- public static function unserial($code)
- {
- return explode("\n", gzuncompress($code));
- }
-
- //----------------------------------------------------------------------
- public static function newFrame($version)
- {
- if($version < 1 || $version > QRSPEC_VERSION_MAX)
- return null;
-
- if(!isset(self::$frames[$version])) {
-
- $fileName = QR_CACHE_DIR.'frame_'.$version.'.dat';
-
- if (QR_CACHEABLE) {
- if (file_exists($fileName)) {
- self::$frames[$version] = self::unserial(file_get_contents($fileName));
- } else {
- self::$frames[$version] = self::createFrame($version);
- file_put_contents($fileName, self::serial(self::$frames[$version]));
- }
- } else {
- self::$frames[$version] = self::createFrame($version);
- }
- }
-
- if(is_null(self::$frames[$version]))
- return null;
-
- return self::$frames[$version];
- }
-
- //----------------------------------------------------------------------
- public static function rsBlockNum($spec) { return $spec[0] + $spec[3]; }
- public static function rsBlockNum1($spec) { return $spec[0]; }
- public static function rsDataCodes1($spec) { return $spec[1]; }
- public static function rsEccCodes1($spec) { return $spec[2]; }
- public static function rsBlockNum2($spec) { return $spec[3]; }
- public static function rsDataCodes2($spec) { return $spec[4]; }
- public static function rsEccCodes2($spec) { return $spec[2]; }
- public static function rsDataLength($spec) { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); }
- public static function rsEccLength($spec) { return ($spec[0] + $spec[3]) * $spec[2]; }
-
- }
-
-
-
-//---- qrimage.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Image output of code using GD2
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- define('QR_IMAGE', true);
-
- class QRimage {
-
- //----------------------------------------------------------------------
- public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE)
- {
- $image = self::image($frame, $pixelPerPoint, $outerFrame);
-
- if ($filename === false) {
- Header("Content-type: image/png");
- ImagePng($image);
- } else {
- if($saveandprint===TRUE){
- ImagePng($image, $filename);
- header("Content-type: image/png");
- ImagePng($image);
- }else{
- ImagePng($image, $filename);
- }
- }
-
- ImageDestroy($image);
- }
-
- //----------------------------------------------------------------------
- public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85)
- {
- $image = self::image($frame, $pixelPerPoint, $outerFrame);
-
- if ($filename === false) {
- Header("Content-type: image/jpeg");
- ImageJpeg($image, null, $q);
- } else {
- ImageJpeg($image, $filename, $q);
- }
-
- ImageDestroy($image);
- }
-
- //----------------------------------------------------------------------
- private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4)
- {
- $h = count($frame);
- $w = strlen($frame[0]);
-
- $imgW = $w + 2*$outerFrame;
- $imgH = $h + 2*$outerFrame;
-
- $base_image =ImageCreate($imgW, $imgH);
-
- $col[0] = ImageColorAllocate($base_image,255,255,255);
- $col[1] = ImageColorAllocate($base_image,0,0,0);
-
- imagefill($base_image, 0, 0, $col[0]);
-
- for($y=0; $y<$h; $y++) {
- for($x=0; $x<$w; $x++) {
- if ($frame[$y][$x] == '1') {
- ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]);
- }
- }
- }
-
- $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
- ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
- ImageDestroy($base_image);
-
- return $target_image;
- }
- }
-
-
-
-//---- qrinput.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Input encoding class
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- define('STRUCTURE_HEADER_BITS', 20);
- define('MAX_STRUCTURED_SYMBOLS', 16);
-
- class QRinputItem {
-
- public $mode;
- public $size;
- public $data;
- public $bstream;
-
- public function __construct($mode, $size, $data, $bstream = null)
- {
- $setData = array_slice($data, 0, $size);
-
- if (count($setData) < $size) {
- $setData = array_merge($setData, array_fill(0,$size-count($setData),0));
- }
-
- if(!QRinput::check($mode, $size, $setData)) {
- throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData));
- return null;
- }
-
- $this->mode = $mode;
- $this->size = $size;
- $this->data = $setData;
- $this->bstream = $bstream;
- }
-
- //----------------------------------------------------------------------
- public function encodeModeNum($version)
- {
- try {
-
- $words = (int)($this->size / 3);
- $bs = new QRbitstream();
-
- $val = 0x1;
- $bs->appendNum(4, $val);
- $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
-
- for($i=0; $i<$words; $i++) {
- $val = (ord($this->data[$i*3 ]) - ord('0')) * 100;
- $val += (ord($this->data[$i*3+1]) - ord('0')) * 10;
- $val += (ord($this->data[$i*3+2]) - ord('0'));
- $bs->appendNum(10, $val);
- }
-
- if($this->size - $words * 3 == 1) {
- $val = ord($this->data[$words*3]) - ord('0');
- $bs->appendNum(4, $val);
- } else if($this->size - $words * 3 == 2) {
- $val = (ord($this->data[$words*3 ]) - ord('0')) * 10;
- $val += (ord($this->data[$words*3+1]) - ord('0'));
- $bs->appendNum(7, $val);
- }
-
- $this->bstream = $bs;
- return 0;
-
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function encodeModeAn($version)
- {
- try {
- $words = (int)($this->size / 2);
- $bs = new QRbitstream();
-
- $bs->appendNum(4, 0x02);
- $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size);
-
- for($i=0; $i<$words; $i++) {
- $val = (int)QRinput::lookAnTable(ord($this->data[$i*2 ])) * 45;
- $val += (int)QRinput::lookAnTable(ord($this->data[$i*2+1]));
-
- $bs->appendNum(11, $val);
- }
-
- if($this->size & 1) {
- $val = QRinput::lookAnTable(ord($this->data[$words * 2]));
- $bs->appendNum(6, $val);
- }
-
- $this->bstream = $bs;
- return 0;
-
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function encodeMode8($version)
- {
- try {
- $bs = new QRbitstream();
-
- $bs->appendNum(4, 0x4);
- $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size);
-
- for($i=0; $i<$this->size; $i++) {
- $bs->appendNum(8, ord($this->data[$i]));
- }
-
- $this->bstream = $bs;
- return 0;
-
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function encodeModeKanji($version)
- {
- try {
-
- $bs = new QRbitrtream();
-
- $bs->appendNum(4, 0x8);
- $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2));
-
- for($i=0; $i<$this->size; $i+=2) {
- $val = (ord($this->data[$i]) << 8) | ord($this->data[$i+1]);
- if($val <= 0x9ffc) {
- $val -= 0x8140;
- } else {
- $val -= 0xc140;
- }
-
- $h = ($val >> 8) * 0xc0;
- $val = ($val & 0xff) + $h;
-
- $bs->appendNum(13, $val);
- }
-
- $this->bstream = $bs;
- return 0;
-
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function encodeModeStructure()
- {
- try {
- $bs = new QRbitstream();
-
- $bs->appendNum(4, 0x03);
- $bs->appendNum(4, ord($this->data[1]) - 1);
- $bs->appendNum(4, ord($this->data[0]) - 1);
- $bs->appendNum(8, ord($this->data[2]));
-
- $this->bstream = $bs;
- return 0;
-
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function estimateBitStreamSizeOfEntry($version)
- {
- $bits = 0;
-
- if($version == 0)
- $version = 1;
-
- switch($this->mode) {
- case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break;
- case QR_MODE_AN: $bits = QRinput::estimateBitsModeAn($this->size); break;
- case QR_MODE_8: $bits = QRinput::estimateBitsMode8($this->size); break;
- case QR_MODE_KANJI: $bits = QRinput::estimateBitsModeKanji($this->size);break;
- case QR_MODE_STRUCTURE: return STRUCTURE_HEADER_BITS;
- default:
- return 0;
- }
-
- $l = QRspec::lengthIndicator($this->mode, $version);
- $m = 1 << $l;
- $num = (int)(($this->size + $m - 1) / $m);
-
- $bits += $num * (4 + $l);
-
- return $bits;
- }
-
- //----------------------------------------------------------------------
- public function encodeBitStream($version)
- {
- try {
-
- unset($this->bstream);
- $words = QRspec::maximumWords($this->mode, $version);
-
- if($this->size > $words) {
-
- $st1 = new QRinputItem($this->mode, $words, $this->data);
- $st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words));
-
- $st1->encodeBitStream($version);
- $st2->encodeBitStream($version);
-
- $this->bstream = new QRbitstream();
- $this->bstream->append($st1->bstream);
- $this->bstream->append($st2->bstream);
-
- unset($st1);
- unset($st2);
-
- } else {
-
- $ret = 0;
-
- switch($this->mode) {
- case QR_MODE_NUM: $ret = $this->encodeModeNum($version); break;
- case QR_MODE_AN: $ret = $this->encodeModeAn($version); break;
- case QR_MODE_8: $ret = $this->encodeMode8($version); break;
- case QR_MODE_KANJI: $ret = $this->encodeModeKanji($version);break;
- case QR_MODE_STRUCTURE: $ret = $this->encodeModeStructure(); break;
-
- default:
- break;
- }
-
- if($ret < 0)
- return -1;
- }
-
- return $this->bstream->size();
-
- } catch (Exception $e) {
- return -1;
- }
- }
- };
-
- //##########################################################################
-
- class QRinput {
-
- public $items;
-
- private $version;
- private $level;
-
- //----------------------------------------------------------------------
- public function __construct($version = 0, $level = QR_ECLEVEL_L)
- {
- if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) {
- throw new Exception('Invalid version no');
- return NULL;
- }
-
- $this->version = $version;
- $this->level = $level;
- }
-
- //----------------------------------------------------------------------
- public function getVersion()
- {
- return $this->version;
- }
-
- //----------------------------------------------------------------------
- public function setVersion($version)
- {
- if($version < 0 || $version > QRSPEC_VERSION_MAX) {
- throw new Exception('Invalid version no');
- return -1;
- }
-
- $this->version = $version;
-
- return 0;
- }
-
- //----------------------------------------------------------------------
- public function getErrorCorrectionLevel()
- {
- return $this->level;
- }
-
- //----------------------------------------------------------------------
- public function setErrorCorrectionLevel($level)
- {
- if($level > QR_ECLEVEL_H) {
- throw new Exception('Invalid ECLEVEL');
- return -1;
- }
-
- $this->level = $level;
-
- return 0;
- }
-
- //----------------------------------------------------------------------
- public function appendEntry(QRinputItem $entry)
- {
- $this->items[] = $entry;
- }
-
- //----------------------------------------------------------------------
- public function append($mode, $size, $data)
- {
- try {
- $entry = new QRinputItem($mode, $size, $data);
- $this->items[] = $entry;
- return 0;
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
-
- public function insertStructuredAppendHeader($size, $index, $parity)
- {
- if( $size > MAX_STRUCTURED_SYMBOLS ) {
- throw new Exception('insertStructuredAppendHeader wrong size');
- }
-
- if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) {
- throw new Exception('insertStructuredAppendHeader wrong index');
- }
-
- $buf = array($size, $index, $parity);
-
- try {
- $entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf);
- array_unshift($this->items, $entry);
- return 0;
- } catch (Exception $e) {
- return -1;
- }
- }
-
- //----------------------------------------------------------------------
- public function calcParity()
- {
- $parity = 0;
-
- foreach($this->items as $item) {
- if($item->mode != QR_MODE_STRUCTURE) {
- for($i=$item->size-1; $i>=0; $i--) {
- $parity ^= $item->data[$i];
- }
- }
- }
-
- return $parity;
- }
-
- //----------------------------------------------------------------------
- public static function checkModeNum($size, $data)
- {
- for($i=0; $i<$size; $i++) {
- if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
- return false;
- }
- }
-
- return true;
- }
-
- //----------------------------------------------------------------------
- public static function estimateBitsModeNum($size)
- {
- $w = (int)$size / 3;
- $bits = $w * 10;
-
- switch($size - $w * 3) {
- case 1:
- $bits += 4;
- break;
- case 2:
- $bits += 7;
- break;
- default:
- break;
- }
-
- return $bits;
- }
-
- //----------------------------------------------------------------------
- public static $anTable = array(
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
- -1, 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, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
- );
-
- //----------------------------------------------------------------------
- public static function lookAnTable($c)
- {
- return (($c > 127)?-1:self::$anTable[$c]);
- }
-
- //----------------------------------------------------------------------
- public static function checkModeAn($size, $data)
- {
- for($i=0; $i<$size; $i++) {
- if (self::lookAnTable(ord($data[$i])) == -1) {
- return false;
- }
- }
-
- return true;
- }
-
- //----------------------------------------------------------------------
- public static function estimateBitsModeAn($size)
- {
- $w = (int)($size / 2);
- $bits = $w * 11;
-
- if($size & 1) {
- $bits += 6;
- }
-
- return $bits;
- }
-
- //----------------------------------------------------------------------
- public static function estimateBitsMode8($size)
- {
- return $size * 8;
- }
-
- //----------------------------------------------------------------------
- public function estimateBitsModeKanji($size)
- {
- return (int)(($size / 2) * 13);
- }
-
- //----------------------------------------------------------------------
- public static function checkModeKanji($size, $data)
- {
- if($size & 1)
- return false;
-
- for($i=0; $i<$size; $i+=2) {
- $val = (ord($data[$i]) << 8) | ord($data[$i+1]);
- if( $val < 0x8140
- || ($val > 0x9ffc && $val < 0xe040)
- || $val > 0xebbf) {
- return false;
- }
- }
-
- return true;
- }
-
- /***********************************************************************
- * Validation
- **********************************************************************/
-
- public static function check($mode, $size, $data)
- {
- if($size <= 0)
- return false;
-
- switch($mode) {
- case QR_MODE_NUM: return self::checkModeNum($size, $data); break;
- case QR_MODE_AN: return self::checkModeAn($size, $data); break;
- case QR_MODE_KANJI: return self::checkModeKanji($size, $data); break;
- case QR_MODE_8: return true; break;
- case QR_MODE_STRUCTURE: return true; break;
-
- default:
- break;
- }
-
- return false;
- }
-
-
- //----------------------------------------------------------------------
- public function estimateBitStreamSize($version)
- {
- $bits = 0;
-
- foreach($this->items as $item) {
- $bits += $item->estimateBitStreamSizeOfEntry($version);
- }
-
- return $bits;
- }
-
- //----------------------------------------------------------------------
- public function estimateVersion()
- {
- $version = 0;
- $prev = 0;
- do {
- $prev = $version;
- $bits = $this->estimateBitStreamSize($prev);
- $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
- if ($version < 0) {
- return -1;
- }
- } while ($version > $prev);
-
- return $version;
- }
-
- //----------------------------------------------------------------------
- public static function lengthOfCode($mode, $version, $bits)
- {
- $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
- switch($mode) {
- case QR_MODE_NUM:
- $chunks = (int)($payload / 10);
- $remain = $payload - $chunks * 10;
- $size = $chunks * 3;
- if($remain >= 7) {
- $size += 2;
- } else if($remain >= 4) {
- $size += 1;
- }
- break;
- case QR_MODE_AN:
- $chunks = (int)($payload / 11);
- $remain = $payload - $chunks * 11;
- $size = $chunks * 2;
- if($remain >= 6)
- $size++;
- break;
- case QR_MODE_8:
- $size = (int)($payload / 8);
- break;
- case QR_MODE_KANJI:
- $size = (int)(($payload / 13) * 2);
- break;
- case QR_MODE_STRUCTURE:
- $size = (int)($payload / 8);
- break;
- default:
- $size = 0;
- break;
- }
-
- $maxsize = QRspec::maximumWords($mode, $version);
- if($size < 0) $size = 0;
- if($size > $maxsize) $size = $maxsize;
-
- return $size;
- }
-
- //----------------------------------------------------------------------
- public function createBitStream()
- {
- $total = 0;
-
- foreach($this->items as $item) {
- $bits = $item->encodeBitStream($this->version);
-
- if($bits < 0)
- return -1;
-
- $total += $bits;
- }
-
- return $total;
- }
-
- //----------------------------------------------------------------------
- public function convertData()
- {
- $ver = $this->estimateVersion();
- if($ver > $this->getVersion()) {
- $this->setVersion($ver);
- }
-
- for(;;) {
- $bits = $this->createBitStream();
-
- if($bits < 0)
- return -1;
-
- $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
- if($ver < 0) {
- throw new Exception('WRONG VERSION');
- return -1;
- } else if($ver > $this->getVersion()) {
- $this->setVersion($ver);
- } else {
- break;
- }
- }
-
- return 0;
- }
-
- //----------------------------------------------------------------------
- public function appendPaddingBit(&$bstream)
- {
- $bits = $bstream->size();
- $maxwords = QRspec::getDataLength($this->version, $this->level);
- $maxbits = $maxwords * 8;
-
- if ($maxbits == $bits) {
- return 0;
- }
-
- if ($maxbits - $bits < 5) {
- return $bstream->appendNum($maxbits - $bits, 0);
- }
-
- $bits += 4;
- $words = (int)(($bits + 7) / 8);
-
- $padding = new QRbitstream();
- $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
-
- if($ret < 0)
- return $ret;
-
- $padlen = $maxwords - $words;
-
- if($padlen > 0) {
-
- $padbuf = array();
- for($i=0; $i<$padlen; $i++) {
- $padbuf[$i] = ($i&1)?0x11:0xec;
- }
-
- $ret = $padding->appendBytes($padlen, $padbuf);
-
- if($ret < 0)
- return $ret;
-
- }
-
- $ret = $bstream->append($padding);
-
- return $ret;
- }
-
- //----------------------------------------------------------------------
- public function mergeBitStream()
- {
- if($this->convertData() < 0) {
- return null;
- }
-
- $bstream = new QRbitstream();
-
- foreach($this->items as $item) {
- $ret = $bstream->append($item->bstream);
- if($ret < 0) {
- return null;
- }
- }
-
- return $bstream;
- }
-
- //----------------------------------------------------------------------
- public function getBitStream()
- {
-
- $bstream = $this->mergeBitStream();
-
- if($bstream == null) {
- return null;
- }
-
- $ret = $this->appendPaddingBit($bstream);
- if($ret < 0) {
- return null;
- }
-
- return $bstream;
- }
-
- //----------------------------------------------------------------------
- public function getByteStream()
- {
- $bstream = $this->getBitStream();
- if($bstream == null) {
- return null;
- }
-
- return $bstream->toByte();
- }
- }
-
-
-
-
-
-
-//---- qrbitstream.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Bitstream class
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- class QRbitstream {
-
- public $data = array();
-
- //----------------------------------------------------------------------
- public function size()
- {
- return count($this->data);
- }
-
- //----------------------------------------------------------------------
- public function allocate($setLength)
- {
- $this->data = array_fill(0, $setLength, 0);
- return 0;
- }
-
- //----------------------------------------------------------------------
- public static function newFromNum($bits, $num)
- {
- $bstream = new QRbitstream();
- $bstream->allocate($bits);
-
- $mask = 1 << ($bits - 1);
- for($i=0; $i<$bits; $i++) {
- if($num & $mask) {
- $bstream->data[$i] = 1;
- } else {
- $bstream->data[$i] = 0;
- }
- $mask = $mask >> 1;
- }
-
- return $bstream;
- }
-
- //----------------------------------------------------------------------
- public static function newFromBytes($size, $data)
- {
- $bstream = new QRbitstream();
- $bstream->allocate($size * 8);
- $p=0;
-
- for($i=0; $i<$size; $i++) {
- $mask = 0x80;
- for($j=0; $j<8; $j++) {
- if($data[$i] & $mask) {
- $bstream->data[$p] = 1;
- } else {
- $bstream->data[$p] = 0;
- }
- $p++;
- $mask = $mask >> 1;
- }
- }
-
- return $bstream;
- }
-
- //----------------------------------------------------------------------
- public function append(QRbitstream $arg)
- {
- if (is_null($arg)) {
- return -1;
- }
-
- if($arg->size() == 0) {
- return 0;
- }
-
- if($this->size() == 0) {
- $this->data = $arg->data;
- return 0;
- }
-
- $this->data = array_values(array_merge($this->data, $arg->data));
-
- return 0;
- }
-
- //----------------------------------------------------------------------
- public function appendNum($bits, $num)
- {
- if ($bits == 0)
- return 0;
-
- $b = QRbitstream::newFromNum($bits, $num);
-
- if(is_null($b))
- return -1;
-
- $ret = $this->append($b);
- unset($b);
-
- return $ret;
- }
-
- //----------------------------------------------------------------------
- public function appendBytes($size, $data)
- {
- if ($size == 0)
- return 0;
-
- $b = QRbitstream::newFromBytes($size, $data);
-
- if(is_null($b))
- return -1;
-
- $ret = $this->append($b);
- unset($b);
-
- return $ret;
- }
-
- //----------------------------------------------------------------------
- public function toByte()
- {
-
- $size = $this->size();
-
- if($size == 0) {
- return array();
- }
-
- $data = array_fill(0, (int)(($size + 7) / 8), 0);
- $bytes = (int)($size / 8);
-
- $p = 0;
-
- for($i=0; $i<$bytes; $i++) {
- $v = 0;
- for($j=0; $j<8; $j++) {
- $v = $v << 1;
- $v |= $this->data[$p];
- $p++;
- }
- $data[$i] = $v;
- }
-
- if($size & 7) {
- $v = 0;
- for($j=0; $j<($size & 7); $j++) {
- $v = $v << 1;
- $v |= $this->data[$p];
- $p++;
- }
- $data[$bytes] = $v;
- }
-
- return $data;
- }
-
- }
-
-
-
-
-//---- qrsplit.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Input splitting classes
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * The following data / specifications are taken from
- * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
- * or
- * "Automatic identification and data capture techniques --
- * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- class QRsplit {
-
- public $dataStr = '';
- public $input;
- public $modeHint;
-
- //----------------------------------------------------------------------
- public function __construct($dataStr, $input, $modeHint)
- {
- $this->dataStr = $dataStr;
- $this->input = $input;
- $this->modeHint = $modeHint;
- }
-
- //----------------------------------------------------------------------
- public static function isdigitat($str, $pos)
- {
- if ($pos >= strlen($str))
- return false;
-
- return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
- }
-
- //----------------------------------------------------------------------
- public static function isalnumat($str, $pos)
- {
- if ($pos >= strlen($str))
- return false;
-
- return (QRinput::lookAnTable(ord($str[$pos])) >= 0);
- }
-
- //----------------------------------------------------------------------
- public function identifyMode($pos)
- {
- if ($pos >= strlen($this->dataStr))
- return QR_MODE_NUL;
-
- $c = $this->dataStr[$pos];
-
- if(self::isdigitat($this->dataStr, $pos)) {
- return QR_MODE_NUM;
- } else if(self::isalnumat($this->dataStr, $pos)) {
- return QR_MODE_AN;
- } else if($this->modeHint == QR_MODE_KANJI) {
-
- if ($pos+1 < strlen($this->dataStr))
- {
- $d = $this->dataStr[$pos+1];
- $word = (ord($c) << 8) | ord($d);
- if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
- return QR_MODE_KANJI;
- }
- }
- }
-
- return QR_MODE_8;
- }
-
- //----------------------------------------------------------------------
- public function eatNum()
- {
- $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
-
- $p = 0;
- while(self::isdigitat($this->dataStr, $p)) {
- $p++;
- }
-
- $run = $p;
- $mode = $this->identifyMode($p);
-
- if($mode == QR_MODE_8) {
- $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
- + QRinput::estimateBitsMode8(1) // + 4 + l8
- - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
- if($dif > 0) {
- return $this->eat8();
- }
- }
- if($mode == QR_MODE_AN) {
- $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
- + QRinput::estimateBitsModeAn(1) // + 4 + la
- - QRinput::estimateBitsModeAn($run + 1);// - 4 - la
- if($dif > 0) {
- return $this->eatAn();
- }
- }
-
- $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
- if($ret < 0)
- return -1;
-
- return $run;
- }
-
- //----------------------------------------------------------------------
- public function eatAn()
- {
- $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
- $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
-
- $p = 0;
-
- while(self::isalnumat($this->dataStr, $p)) {
- if(self::isdigitat($this->dataStr, $p)) {
- $q = $p;
- while(self::isdigitat($this->dataStr, $q)) {
- $q++;
- }
-
- $dif = QRinput::estimateBitsModeAn($p) // + 4 + la
- + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
- - QRinput::estimateBitsModeAn($q); // - 4 - la
-
- if($dif < 0) {
- break;
- } else {
- $p = $q;
- }
- } else {
- $p++;
- }
- }
-
- $run = $p;
-
- if(!self::isalnumat($this->dataStr, $p)) {
- $dif = QRinput::estimateBitsModeAn($run) + 4 + $la
- + QRinput::estimateBitsMode8(1) // + 4 + l8
- - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
- if($dif > 0) {
- return $this->eat8();
- }
- }
-
- $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
- if($ret < 0)
- return -1;
-
- return $run;
- }
-
- //----------------------------------------------------------------------
- public function eatKanji()
- {
- $p = 0;
-
- while($this->identifyMode($p) == QR_MODE_KANJI) {
- $p += 2;
- }
-
- $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
- if($ret < 0)
- return -1;
-
- return $run;
- }
-
- //----------------------------------------------------------------------
- public function eat8()
- {
- $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
- $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
-
- $p = 1;
- $dataStrLen = strlen($this->dataStr);
-
- while($p < $dataStrLen) {
-
- $mode = $this->identifyMode($p);
- if($mode == QR_MODE_KANJI) {
- break;
- }
- if($mode == QR_MODE_NUM) {
- $q = $p;
- while(self::isdigitat($this->dataStr, $q)) {
- $q++;
- }
- $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
- + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
- - QRinput::estimateBitsMode8($q); // - 4 - l8
- if($dif < 0) {
- break;
- } else {
- $p = $q;
- }
- } else if($mode == QR_MODE_AN) {
- $q = $p;
- while(self::isalnumat($this->dataStr, $q)) {
- $q++;
- }
- $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
- + QRinput::estimateBitsModeAn($q - $p) + 4 + $la
- - QRinput::estimateBitsMode8($q); // - 4 - l8
- if($dif < 0) {
- break;
- } else {
- $p = $q;
- }
- } else {
- $p++;
- }
- }
-
- $run = $p;
- $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
-
- if($ret < 0)
- return -1;
-
- return $run;
- }
-
- //----------------------------------------------------------------------
- public function splitString()
- {
- while (strlen($this->dataStr) > 0)
- {
- if($this->dataStr == '')
- return 0;
-
- $mode = $this->identifyMode(0);
-
- switch ($mode) {
- case QR_MODE_NUM: $length = $this->eatNum(); break;
- case QR_MODE_AN: $length = $this->eatAn(); break;
- case QR_MODE_KANJI:
- if ($hint == QR_MODE_KANJI)
- $length = $this->eatKanji();
- else $length = $this->eat8();
- break;
- default: $length = $this->eat8(); break;
-
- }
-
- if($length == 0) return 0;
- if($length < 0) return -1;
-
- $this->dataStr = substr($this->dataStr, $length);
- }
- }
-
- //----------------------------------------------------------------------
- public function toUpper()
- {
- $stringLen = strlen($this->dataStr);
- $p = 0;
-
- while ($p<$stringLen) {
- $mode = self::identifyMode(substr($this->dataStr, $p), $this->modeHint);
- if($mode == QR_MODE_KANJI) {
- $p += 2;
- } else {
- if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) {
- $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32);
- }
- $p++;
- }
- }
-
- return $this->dataStr;
- }
-
- //----------------------------------------------------------------------
- public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true)
- {
- if(is_null($string) || $string == '\0' || $string == '') {
- throw new Exception('empty string!!!');
- }
-
- $split = new QRsplit($string, $input, $modeHint);
-
- if(!$casesensitive)
- $split->toUpper();
-
- return $split->splitString();
- }
- }
-
-
-
-//---- qrrscode.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Reed-Solomon error correction support
- *
- * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
- * (libfec is released under the GNU Lesser General Public License.)
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- class QRrsItem {
-
- public $mm; // Bits per symbol
- public $nn; // Symbols per block (= (1<= $this->nn) {
- $x -= $this->nn;
- $x = ($x >> $this->mm) + ($x & $this->nn);
- }
-
- return $x;
- }
-
- //----------------------------------------------------------------------
- public static function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
- {
- // Common code for intializing a Reed-Solomon control block (char or int symbols)
- // Copyright 2004 Phil Karn, KA9Q
- // May be used under the terms of the GNU Lesser General Public License (LGPL)
-
- $rs = null;
-
- // Check parameter ranges
- if($symsize < 0 || $symsize > 8) return $rs;
- if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs;
- if($prim <= 0 || $prim >= (1<<$symsize)) return $rs;
- if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values!
- if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding
-
- $rs = new QRrsItem();
- $rs->mm = $symsize;
- $rs->nn = (1<<$symsize)-1;
- $rs->pad = $pad;
-
- $rs->alpha_to = array_fill(0, $rs->nn+1, 0);
- $rs->index_of = array_fill(0, $rs->nn+1, 0);
-
- // PHP style macro replacement ;)
- $NN =& $rs->nn;
- $A0 =& $NN;
-
- // Generate Galois field lookup tables
- $rs->index_of[0] = $A0; // log(zero) = -inf
- $rs->alpha_to[$A0] = 0; // alpha**-inf = 0
- $sr = 1;
-
- for($i=0; $i<$rs->nn; $i++) {
- $rs->index_of[$sr] = $i;
- $rs->alpha_to[$i] = $sr;
- $sr <<= 1;
- if($sr & (1<<$symsize)) {
- $sr ^= $gfpoly;
- }
- $sr &= $rs->nn;
- }
-
- if($sr != 1){
- // field generator polynomial is not primitive!
- $rs = NULL;
- return $rs;
- }
-
- /* Form RS code generator polynomial from its roots */
- $rs->genpoly = array_fill(0, $nroots+1, 0);
-
- $rs->fcr = $fcr;
- $rs->prim = $prim;
- $rs->nroots = $nroots;
- $rs->gfpoly = $gfpoly;
-
- /* Find prim-th root of 1, used in decoding */
- for($iprim=1;($iprim % $prim) != 0;$iprim += $rs->nn)
- ; // intentional empty-body loop!
-
- $rs->iprim = (int)($iprim / $prim);
- $rs->genpoly[0] = 1;
-
- for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) {
- $rs->genpoly[$i+1] = 1;
-
- // Multiply rs->genpoly[] by @**(root + x)
- for ($j = $i; $j > 0; $j--) {
- if ($rs->genpoly[$j] != 0) {
- $rs->genpoly[$j] = $rs->genpoly[$j-1] ^ $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[$j]] + $root)];
- } else {
- $rs->genpoly[$j] = $rs->genpoly[$j-1];
- }
- }
- // rs->genpoly[0] can never be zero
- $rs->genpoly[0] = $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[0]] + $root)];
- }
-
- // convert rs->genpoly[] to index form for quicker encoding
- for ($i = 0; $i <= $nroots; $i++)
- $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]];
-
- return $rs;
- }
-
- //----------------------------------------------------------------------
- public function encode_rs_char($data, &$parity)
- {
- $MM =& $this->mm;
- $NN =& $this->nn;
- $ALPHA_TO =& $this->alpha_to;
- $INDEX_OF =& $this->index_of;
- $GENPOLY =& $this->genpoly;
- $NROOTS =& $this->nroots;
- $FCR =& $this->fcr;
- $PRIM =& $this->prim;
- $IPRIM =& $this->iprim;
- $PAD =& $this->pad;
- $A0 =& $NN;
-
- $parity = array_fill(0, $NROOTS, 0);
-
- for($i=0; $i< ($NN-$NROOTS-$PAD); $i++) {
-
- $feedback = $INDEX_OF[$data[$i] ^ $parity[0]];
- if($feedback != $A0) {
- // feedback term is non-zero
-
- // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
- // always be for the polynomials constructed by init_rs()
- $feedback = $this->modnn($NN - $GENPOLY[$NROOTS] + $feedback);
-
- for($j=1;$j<$NROOTS;$j++) {
- $parity[$j] ^= $ALPHA_TO[$this->modnn($feedback + $GENPOLY[$NROOTS-$j])];
- }
- }
-
- // Shift
- array_shift($parity);
- if($feedback != $A0) {
- array_push($parity, $ALPHA_TO[$this->modnn($feedback + $GENPOLY[0])]);
- } else {
- array_push($parity, 0);
- }
- }
- }
- }
-
- //##########################################################################
-
- class QRrs {
-
- public static $items = array();
-
- //----------------------------------------------------------------------
- public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
- {
- foreach(self::$items as $rs) {
- if($rs->pad != $pad) continue;
- if($rs->nroots != $nroots) continue;
- if($rs->mm != $symsize) continue;
- if($rs->gfpoly != $gfpoly) continue;
- if($rs->fcr != $fcr) continue;
- if($rs->prim != $prim) continue;
-
- return $rs;
- }
-
- $rs = QRrsItem::init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad);
- array_unshift(self::$items, $rs);
-
- return $rs;
- }
- }
-
-
-
-//---- qrmask.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Masking
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- define('N1', 3);
- define('N2', 3);
- define('N3', 40);
- define('N4', 10);
-
- class QRmask {
-
- public $runLength = array();
-
- //----------------------------------------------------------------------
- public function __construct()
- {
- $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0);
- }
-
- //----------------------------------------------------------------------
- public function writeFormatInformation($width, &$frame, $mask, $level)
- {
- $blacks = 0;
- $format = QRspec::getFormatInfo($mask, $level);
-
- for($i=0; $i<8; $i++) {
- if($format & 1) {
- $blacks += 2;
- $v = 0x85;
- } else {
- $v = 0x84;
- }
-
- $frame[8][$width - 1 - $i] = chr($v);
- if($i < 6) {
- $frame[$i][8] = chr($v);
- } else {
- $frame[$i + 1][8] = chr($v);
- }
- $format = $format >> 1;
- }
-
- for($i=0; $i<7; $i++) {
- if($format & 1) {
- $blacks += 2;
- $v = 0x85;
- } else {
- $v = 0x84;
- }
-
- $frame[$width - 7 + $i][8] = chr($v);
- if($i == 0) {
- $frame[8][7] = chr($v);
- } else {
- $frame[8][6 - $i] = chr($v);
- }
-
- $format = $format >> 1;
- }
-
- return $blacks;
- }
-
- //----------------------------------------------------------------------
- public function mask0($x, $y) { return ($x+$y)&1; }
- public function mask1($x, $y) { return ($y&1); }
- public function mask2($x, $y) { return ($x%3); }
- public function mask3($x, $y) { return ($x+$y)%3; }
- public function mask4($x, $y) { return (((int)($y/2))+((int)($x/3)))&1; }
- public function mask5($x, $y) { return (($x*$y)&1)+($x*$y)%3; }
- public function mask6($x, $y) { return ((($x*$y)&1)+($x*$y)%3)&1; }
- public function mask7($x, $y) { return ((($x*$y)%3)+(($x+$y)&1))&1; }
-
- //----------------------------------------------------------------------
- private function generateMaskNo($maskNo, $width, $frame)
- {
- $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
-
- for($y=0; $y<$width; $y++) {
- for($x=0; $x<$width; $x++) {
- if(ord($frame[$y][$x]) & 0x80) {
- $bitMask[$y][$x] = 0;
- } else {
- $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
- $bitMask[$y][$x] = ($maskFunc == 0)?1:0;
- }
-
- }
- }
-
- return $bitMask;
- }
-
- //----------------------------------------------------------------------
- public static function serial($bitFrame)
- {
- $codeArr = array();
-
- foreach ($bitFrame as $line)
- $codeArr[] = join('', $line);
-
- return gzcompress(join("\n", $codeArr), 9);
- }
-
- //----------------------------------------------------------------------
- public static function unserial($code)
- {
- $codeArr = array();
-
- $codeLines = explode("\n", gzuncompress($code));
- foreach ($codeLines as $line)
- $codeArr[] = str_split($line);
-
- return $codeArr;
- }
-
- //----------------------------------------------------------------------
- public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false)
- {
- $b = 0;
- $bitMask = array();
-
- $fileName = QR_CACHE_DIR.'mask_'.$maskNo.DIRECTORY_SEPARATOR.'mask_'.$width.'_'.$maskNo.'.dat';
-
- if (QR_CACHEABLE) {
- if (file_exists($fileName)) {
- $bitMask = self::unserial(file_get_contents($fileName));
- } else {
- $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
- if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo))
- mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
- file_put_contents($fileName, self::serial($bitMask));
- }
- } else {
- $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
- }
-
- if ($maskGenOnly)
- return;
-
- $d = $s;
-
- for($y=0; $y<$width; $y++) {
- for($x=0; $x<$width; $x++) {
- if($bitMask[$y][$x] == 1) {
- $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
- }
- $b += (int)(ord($d[$y][$x]) & 1);
- }
- }
-
- return $b;
- }
-
- //----------------------------------------------------------------------
- public function makeMask($width, $frame, $maskNo, $level)
- {
- $masked = array_fill(0, $width, str_repeat("\0", $width));
- $this->makeMaskNo($maskNo, $width, $frame, $masked);
- $this->writeFormatInformation($width, $masked, $maskNo, $level);
-
- return $masked;
- }
-
- //----------------------------------------------------------------------
- public function calcN1N3($length)
- {
- $demerit = 0;
-
- for($i=0; $i<$length; $i++) {
-
- if($this->runLength[$i] >= 5) {
- $demerit += (N1 + ($this->runLength[$i] - 5));
- }
- if($i & 1) {
- if(($i >= 3) && ($i < ($length-2)) && ($this->runLength[$i] % 3 == 0)) {
- $fact = (int)($this->runLength[$i] / 3);
- if(($this->runLength[$i-2] == $fact) &&
- ($this->runLength[$i-1] == $fact) &&
- ($this->runLength[$i+1] == $fact) &&
- ($this->runLength[$i+2] == $fact)) {
- if(($this->runLength[$i-3] < 0) || ($this->runLength[$i-3] >= (4 * $fact))) {
- $demerit += N3;
- } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) {
- $demerit += N3;
- }
- }
- }
- }
- }
- return $demerit;
- }
-
- //----------------------------------------------------------------------
- public function evaluateSymbol($width, $frame)
- {
- $head = 0;
- $demerit = 0;
-
- for($y=0; $y<$width; $y++) {
- $head = 0;
- $this->runLength[0] = 1;
-
- $frameY = $frame[$y];
-
- if ($y>0)
- $frameYM = $frame[$y-1];
-
- for($x=0; $x<$width; $x++) {
- if(($x > 0) && ($y > 0)) {
- $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
- $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
-
- if(($b22 | ($w22 ^ 1))&1) {
- $demerit += N2;
- }
- }
- if(($x == 0) && (ord($frameY[$x]) & 1)) {
- $this->runLength[0] = -1;
- $head = 1;
- $this->runLength[$head] = 1;
- } else if($x > 0) {
- if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
- $head++;
- $this->runLength[$head] = 1;
- } else {
- $this->runLength[$head]++;
- }
- }
- }
-
- $demerit += $this->calcN1N3($head+1);
- }
-
- for($x=0; $x<$width; $x++) {
- $head = 0;
- $this->runLength[0] = 1;
-
- for($y=0; $y<$width; $y++) {
- if($y == 0 && (ord($frame[$y][$x]) & 1)) {
- $this->runLength[0] = -1;
- $head = 1;
- $this->runLength[$head] = 1;
- } else if($y > 0) {
- if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
- $head++;
- $this->runLength[$head] = 1;
- } else {
- $this->runLength[$head]++;
- }
- }
- }
-
- $demerit += $this->calcN1N3($head+1);
- }
-
- return $demerit;
- }
-
-
- //----------------------------------------------------------------------
- public function mask($width, $frame, $level)
- {
- $minDemerit = PHP_INT_MAX;
- $bestMaskNum = 0;
- $bestMask = array();
-
- $checked_masks = array(0,1,2,3,4,5,6,7);
-
- if (QR_FIND_FROM_RANDOM !== false) {
-
- $howManuOut = 8-(QR_FIND_FROM_RANDOM % 9);
- for ($i = 0; $i < $howManuOut; $i++) {
- $remPos = rand (0, count($checked_masks)-1);
- unset($checked_masks[$remPos]);
- $checked_masks = array_values($checked_masks);
- }
-
- }
-
- $bestMask = $frame;
-
- foreach($checked_masks as $i) {
- $mask = array_fill(0, $width, str_repeat("\0", $width));
-
- $demerit = 0;
- $blacks = 0;
- $blacks = $this->makeMaskNo($i, $width, $frame, $mask);
- $blacks += $this->writeFormatInformation($width, $mask, $i, $level);
- $blacks = (int)(100 * $blacks / ($width * $width));
- $demerit = (int)((int)(abs($blacks - 50) / 5) * N4);
- $demerit += $this->evaluateSymbol($width, $mask);
-
- if($demerit < $minDemerit) {
- $minDemerit = $demerit;
- $bestMask = $mask;
- $bestMaskNum = $i;
- }
- }
-
- return $bestMask;
- }
-
- //----------------------------------------------------------------------
- }
-
-
-
-
-//---- qrencode.php -----------------------------
-
-
-
-
-/*
- * PHP QR Code encoder
- *
- * Main encoder classes.
- *
- * Based on libqrencode C library distributed under LGPL 2.1
- * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi
- *
- * PHP QR Code is distributed under LGPL 3
- * Copyright (C) 2010 Dominik Dzienia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- class QRrsblock {
- public $dataLength;
- public $data = array();
- public $eccLength;
- public $ecc = array();
-
- public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs)
- {
- $rs->encode_rs_char($data, $ecc);
-
- $this->dataLength = $dl;
- $this->data = $data;
- $this->eccLength = $el;
- $this->ecc = $ecc;
- }
- };
-
- //##########################################################################
-
- class QRrawcode {
- public $version;
- public $datacode = array();
- public $ecccode = array();
- public $blocks;
- public $rsblocks = array(); //of RSblock
- public $count;
- public $dataLength;
- public $eccLength;
- public $b1;
-
- //----------------------------------------------------------------------
- public function __construct(QRinput $input)
- {
- $spec = array(0,0,0,0,0);
-
- $this->datacode = $input->getByteStream();
- if(is_null($this->datacode)) {
- throw new Exception('null imput string');
- }
-
- QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec);
-
- $this->version = $input->getVersion();
- $this->b1 = QRspec::rsBlockNum1($spec);
- $this->dataLength = QRspec::rsDataLength($spec);
- $this->eccLength = QRspec::rsEccLength($spec);
- $this->ecccode = array_fill(0, $this->eccLength, 0);
- $this->blocks = QRspec::rsBlockNum($spec);
-
- $ret = $this->init($spec);
- if($ret < 0) {
- throw new Exception('block alloc error');
- return null;
- }
-
- $this->count = 0;
- }
-
- //----------------------------------------------------------------------
- public function init(array $spec)
- {
- $dl = QRspec::rsDataCodes1($spec);
- $el = QRspec::rsEccCodes1($spec);
- $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
-
-
- $blockNo = 0;
- $dataPos = 0;
- $eccPos = 0;
- for($i=0; $iecccode,$eccPos);
- $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
- $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
-
- $dataPos += $dl;
- $eccPos += $el;
- $blockNo++;
- }
-
- if(QRspec::rsBlockNum2($spec) == 0)
- return 0;
-
- $dl = QRspec::rsDataCodes2($spec);
- $el = QRspec::rsEccCodes2($spec);
- $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
-
- if($rs == NULL) return -1;
-
- for($i=0; $iecccode,$eccPos);
- $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
- $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
-
- $dataPos += $dl;
- $eccPos += $el;
- $blockNo++;
- }
-
- return 0;
- }
-
- //----------------------------------------------------------------------
- public function getCode()
- {
- $ret;
-
- if($this->count < $this->dataLength) {
- $row = $this->count % $this->blocks;
- $col = $this->count / $this->blocks;
- if($col >= $this->rsblocks[0]->dataLength) {
- $row += $this->b1;
- }
- $ret = $this->rsblocks[$row]->data[$col];
- } else if($this->count < $this->dataLength + $this->eccLength) {
- $row = ($this->count - $this->dataLength) % $this->blocks;
- $col = ($this->count - $this->dataLength) / $this->blocks;
- $ret = $this->rsblocks[$row]->ecc[$col];
- } else {
- return 0;
- }
- $this->count++;
-
- return $ret;
- }
- }
-
- //##########################################################################
-
- class QRcode {
-
- public $version;
- public $width;
- public $data;
-
- //----------------------------------------------------------------------
- public function encodeMask(QRinput $input, $mask)
- {
- if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
- throw new Exception('wrong version');
- }
- if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
- throw new Exception('wrong level');
- }
-
- $raw = new QRrawcode($input);
-
- QRtools::markTime('after_raw');
-
- $version = $raw->version;
- $width = QRspec::getWidth($version);
- $frame = QRspec::newFrame($version);
-
- $filler = new FrameFiller($width, $frame);
- if(is_null($filler)) {
- return NULL;
- }
-
- // inteleaved data and ecc codes
- for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) {
- $code = $raw->getCode();
- $bit = 0x80;
- for($j=0; $j<8; $j++) {
- $addr = $filler->next();
- $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
- $bit = $bit >> 1;
- }
- }
-
- QRtools::markTime('after_filler');
-
- unset($raw);
-
- // remainder bits
- $j = QRspec::getRemainder($version);
- for($i=0; $i<$j; $i++) {
- $addr = $filler->next();
- $filler->setFrameAt($addr, 0x02);
- }
-
- $frame = $filler->frame;
- unset($filler);
-
-
- // masking
- $maskObj = new QRmask();
- if($mask < 0) {
-
- if (QR_FIND_BEST_MASK) {
- $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
- } else {
- $masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel());
- }
- } else {
- $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
- }
-
- if($masked == NULL) {
- return NULL;
- }
-
- QRtools::markTime('after_mask');
-
- $this->version = $version;
- $this->width = $width;
- $this->data = $masked;
-
- return $this;
- }
-
- //----------------------------------------------------------------------
- public function encodeInput(QRinput $input)
- {
- return $this->encodeMask($input, -1);
- }
-
- //----------------------------------------------------------------------
- public function encodeString8bit($string, $version, $level)
- {
- if(string == NULL) {
- throw new Exception('empty string!');
- return NULL;
- }
-
- $input = new QRinput($version, $level);
- if($input == NULL) return NULL;
-
- $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
- if($ret < 0) {
- unset($input);
- return NULL;
- }
- return $this->encodeInput($input);
- }
-
- //----------------------------------------------------------------------
- public function encodeString($string, $version, $level, $hint, $casesensitive)
- {
-
- if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
- throw new Exception('bad hint');
- return NULL;
- }
-
- $input = new QRinput($version, $level);
- if($input == NULL) return NULL;
-
- $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
- if($ret < 0) {
- return NULL;
- }
-
- return $this->encodeInput($input);
- }
-
- //----------------------------------------------------------------------
- public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false)
- {
- $enc = QRencode::factory($level, $size, $margin);
- return $enc->encodePNG($text, $outfile, $saveandprint=false);
- }
-
- //----------------------------------------------------------------------
- public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
- {
- $enc = QRencode::factory($level, $size, $margin);
- return $enc->encode($text, $outfile);
- }
-
- //----------------------------------------------------------------------
- public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
- {
- $enc = QRencode::factory($level, $size, $margin);
- return $enc->encodeRAW($text, $outfile);
- }
- }
-
- //##########################################################################
-
- class FrameFiller {
-
- public $width;
- public $frame;
- public $x;
- public $y;
- public $dir;
- public $bit;
-
- //----------------------------------------------------------------------
- public function __construct($width, &$frame)
- {
- $this->width = $width;
- $this->frame = $frame;
- $this->x = $width - 1;
- $this->y = $width - 1;
- $this->dir = -1;
- $this->bit = -1;
- }
-
- //----------------------------------------------------------------------
- public function setFrameAt($at, $val)
- {
- $this->frame[$at['y']][$at['x']] = chr($val);
- }
-
- //----------------------------------------------------------------------
- public function getFrameAt($at)
- {
- return ord($this->frame[$at['y']][$at['x']]);
- }
-
- //----------------------------------------------------------------------
- public function next()
- {
- do {
-
- if($this->bit == -1) {
- $this->bit = 0;
- return array('x'=>$this->x, 'y'=>$this->y);
- }
-
- $x = $this->x;
- $y = $this->y;
- $w = $this->width;
-
- if($this->bit == 0) {
- $x--;
- $this->bit++;
- } else {
- $x++;
- $y += $this->dir;
- $this->bit--;
- }
-
- if($this->dir < 0) {
- if($y < 0) {
- $y = 0;
- $x -= 2;
- $this->dir = 1;
- if($x == 6) {
- $x--;
- $y = 9;
- }
- }
- } else {
- if($y == $w) {
- $y = $w - 1;
- $x -= 2;
- $this->dir = -1;
- if($x == 6) {
- $x--;
- $y -= 8;
- }
- }
- }
- if($x < 0 || $y < 0) return null;
-
- $this->x = $x;
- $this->y = $y;
-
- } while(ord($this->frame[$y][$x]) & 0x80);
-
- return array('x'=>$x, 'y'=>$y);
- }
-
- } ;
-
- //##########################################################################
-
- class QRencode {
-
- public $casesensitive = true;
- public $eightbit = false;
-
- public $version = 0;
- public $size = 3;
- public $margin = 4;
-
- public $structured = 0; // not supported yet
-
- public $level = QR_ECLEVEL_L;
- public $hint = QR_MODE_8;
-
- //----------------------------------------------------------------------
- public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4)
- {
- $enc = new QRencode();
- $enc->size = $size;
- $enc->margin = $margin;
-
- switch ($level.'') {
- case '0':
- case '1':
- case '2':
- case '3':
- $enc->level = $level;
- break;
- case 'l':
- case 'L':
- $enc->level = QR_ECLEVEL_L;
- break;
- case 'm':
- case 'M':
- $enc->level = QR_ECLEVEL_M;
- break;
- case 'q':
- case 'Q':
- $enc->level = QR_ECLEVEL_Q;
- break;
- case 'h':
- case 'H':
- $enc->level = QR_ECLEVEL_H;
- break;
- }
-
- return $enc;
- }
-
- //----------------------------------------------------------------------
- public function encodeRAW($intext, $outfile = false)
- {
- $code = new QRcode();
-
- if($this->eightbit) {
- $code->encodeString8bit($intext, $this->version, $this->level);
- } else {
- $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
- }
-
- return $code->data;
- }
-
- //----------------------------------------------------------------------
- public function encode($intext, $outfile = false)
- {
- $code = new QRcode();
-
- if($this->eightbit) {
- $code->encodeString8bit($intext, $this->version, $this->level);
- } else {
- $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
- }
-
- QRtools::markTime('after_encode');
-
- if ($outfile!== false) {
- file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
- } else {
- return QRtools::binarize($code->data);
- }
- }
-
- //----------------------------------------------------------------------
- public function encodePNG($intext, $outfile = false,$saveandprint=false)
- {
- try {
-
- ob_start();
- $tab = $this->encode($intext);
- $err = ob_get_contents();
- ob_end_clean();
-
- if ($err != '')
- QRtools::log($outfile, $err);
-
- $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
-
- QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
-
- } catch (Exception $e) {
-
- QRtools::log($outfile, $e->getMessage());
-
- }
- }
- }
-
-
diff --git a/modules/qrcode/qrcode.php b/modules/qrcode/qrcode.php
deleted file mode 100644
index 5a19034..0000000
--- a/modules/qrcode/qrcode.php
+++ /dev/null
@@ -1,5 +0,0 @@
- |