diff --git a/README.md b/README.md index 4af7536..7647834 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,11 @@ 1 vài helper cơ bản khi sử dụng với CodeIgniter 3. -Có thể đưa vào nhiều bộ code hay framework khác, tuy nhiên có 1 số function require framework `CodeIgniter`, tuy nhiên không ảnh hưởng tới hiệu suất sử dụng +Có thể đưa vào nhiều bộ code hay framework khác, tuy nhiên có 1 số function require framework `CodeIgniter`, tuy nhiên +không ảnh hưởng tới hiệu suất sử dụng -Trong trường hợp tích hợp gói này vào các framework, source khác ngoài `CodeIgniter`, bạn cần cài kèm thêm gói `nguyenanhung/polyfill-codeigniter-built-in` để sử dụng tốt nhất +Trong trường hợp tích hợp gói này vào các framework, source khác ngoài `CodeIgniter`, bạn cần cài kèm thêm +gói `nguyenanhung/polyfill-codeigniter-built-in` để sử dụng tốt nhất 1 vài framework tôi cũng thường dùng với gói này là @@ -88,23 +90,40 @@ Dưới đây là danh sách các Helper được hỗ trợ trong bộ thư vi ### Assets Helper -- [x] Helper Function: `assets_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets` trong thư mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng sau các file CSS, JS -- [x] Helper Function: `static_url` - Hàm lấy ra Static Resource Url, điều kiện tồn tại cấu hình `config_item('static_url')` trong config của website. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào +- [x] Helper Function: `assets_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets` trong thư mục `public/`. + Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng sau các file + CSS, JS +- [x] Helper Function: `static_url` - Hàm lấy ra Static Resource Url, điều kiện tồn tại cấu + hình `config_item('static_url')` trong config của website. Trong trường hợp trong file `config.php` tồn tại + biến `assets_version` sẽ tự động thêm version vào đằng sau các file CSS, JS -- [x] Helper Function: `templates_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `templates` trong thư mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng sau các file CSS, +- [x] Helper Function: `templates_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `templates` trong thư + mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng + sau các file CSS, JS -- [x] Helper Function: `editor_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets/editors/` trong thư mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng sau các file +- [x] Helper Function: `editor_url` - Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets/editors/` trong thư + mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng + sau các file CSS, JS -- [x] Helper Function: `favicon_url`- Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets/favicon/` trong thư mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng sau các file +- [x] Helper Function: `favicon_url`- Hàm lấy ra Assets Url, điều kiện tồn tại thư mục `assets/favicon/` trong thư + mục `public/`. Trong trường hợp trong file `config.php` tồn tại biến `assets_version` sẽ tự động thêm version vào đằng + sau các file CSS, JS - [x] Helper Function: `favicon_html_tag`- Hàm lấy ra đoạn HTML thể hiện Favicon dựa vào URL folder favicon đầu vào -- [x] Helper Function: `storage_url` - Need config `storage_url` item in config.php file. VD: `$config['storage_url'] = 'https://storage.nguyenanhung.com/';` -- [x] Helper Function: `go_url` - Need config `go_url` item in `config.php` file. VD: `$config['go_url'] = 'https://go.nguyenanhung.com/';` -- [x] Helper Function: `assets_mobile` - Lấy ra đường dẫn assets của giao diện mobile (thực tế ít dùng, duy trì cho các dự án cũ) -- [x] Helper Function: `assets_themes` - Lấy ra đường dẫn assets của giao diện pc (thực tế ít dùng, duy trì cho các dự án cũ) -- [x] Helper Function: `assets_themes_dashboard` - Lấy ra đường dẫn assets của giao diện dashboard (thực tế ít dùng, duy trì cho các dự án cũ) -- [x] Helper Function: `assets_themes_comingsoon` - Lấy ra đường dẫn assets của giao diện coming soon (thực tế ít dùng, duy trì cho các dự án cũ) -- [x] Helper Function: `assets_themes_error` - Lấy ra đường dẫn assets của giao diện error (thực tế ít dùng, duy trì cho các dự án cũ) +- [x] Helper Function: `storage_url` - Need config `storage_url` item in config.php file. + VD: `$config['storage_url'] = 'https://storage.nguyenanhung.com/';` +- [x] Helper Function: `go_url` - Need config `go_url` item in `config.php` file. + VD: `$config['go_url'] = 'https://go.nguyenanhung.com/';` +- [x] Helper Function: `assets_mobile` - Lấy ra đường dẫn assets của giao diện mobile (thực tế ít dùng, duy trì cho các + dự án cũ) +- [x] Helper Function: `assets_themes` - Lấy ra đường dẫn assets của giao diện pc (thực tế ít dùng, duy trì cho các dự + án cũ) +- [x] Helper Function: `assets_themes_dashboard` - Lấy ra đường dẫn assets của giao diện dashboard (thực tế ít dùng, duy + trì cho các dự án cũ) +- [x] Helper Function: `assets_themes_comingsoon` - Lấy ra đường dẫn assets của giao diện coming soon (thực tế ít dùng, + duy trì cho các dự án cũ) +- [x] Helper Function: `assets_themes_error` - Lấy ra đường dẫn assets của giao diện error (thực tế ít dùng, duy trì cho + các dự án cũ) - [x] Helper Function: `cdn_js_url` - Resource JS, CSS từ CDN của Cloudflare - [x] Helper Function: `google_fonts_url` - Resource Google Font - [x] Helper Function: `bootstrapcdn_url` - Resource CDN từ Bootstrap @@ -133,7 +152,8 @@ Dưới đây là danh sách các Helper được hỗ trợ trong bộ thư vi ### Database Helper -- [x] Helper Function: `generate_list_id_with_parent_id ` - Tạo 1 list các ID, trong đó chứa các tập con phụ thuộc của ID đó. VD: Dùng trong trường hợp muốn hiển thị nội dung của category cha và các category con trong cùng 1 page content +- [x] Helper Function: `generate_list_id_with_parent_id ` - Tạo 1 list các ID, trong đó chứa các tập con phụ thuộc của + ID đó. VD: Dùng trong trường hợp muốn hiển thị nội dung của category cha và các category con trong cùng 1 page content ### Date Helper @@ -164,7 +184,8 @@ Các hàm này dùng debug ### Facebook Helper - [x] Helper Function: `widget_facebook_div_init` - Hàm tạo ra `
` -- [x] Helper Function: `widget_facebook_script_init` - Hạm tạo ra đoạn script init trong trường hợp cần nhúng JS Facebook +- [x] Helper Function: `widget_facebook_script_init` - Hạm tạo ra đoạn script init trong trường hợp cần nhúng JS + Facebook - [x] Helper Function: `widget_facebook_comments` - Hàm tạo ra khung comment facebook - [x] Helper Function: `widget_facebook_share_button` - Hàm tạo ra nút share facebook - [x] Helper Function: `widget_facebook_like_button` - Hàm tạo ra nút like facebook @@ -176,7 +197,8 @@ Các hàm này dùng debug - [x] Helper Function: `genarateFileIndex` - Tự động tạo nội dung file `index.html` - [x] Helper Function: `genarateFileHtaccess` - Tự động tạo nội dung file `.htaccess` - [x] Helper Function: `genarateFileReadme` - Tự động tạo nội dung file `README.md` -- [x] Helper Function: `makeNewFolder` - Hàm tạo 1 thư mục mới và genre sẵn trong đó 3 file: `README.md`, `index.html`, `.htaccess` +- [x] Helper Function: `makeNewFolder` - Hàm tạo 1 thư mục mới và genre sẵn trong đó 3 file: `README.md`, `index.html` + , `.htaccess` - [x] Helper Function: `new_folder` - Chức năng tương tự với hàm `makeNewFolder` - [x] Helper Function: `scan_folder` - Quét và lấy ra danh sách các thông tin dữ liệu trong folder - [x] Helper Function: `getAllFileSizeInFolder` - Get all File size in Folder @@ -204,16 +226,19 @@ Các hàm này dùng debug ### Image Helper - [x] Helper Function: `google_image_resize` - Resize Image sử dụng Google Gadget Proxy -- [x] Helper Function: `google_image_proxy_dns_prefetch` - Hàm cung cấp DNS Prefetch trong trường hợp sử dụng `google_image_resize` +- [x] Helper Function: `google_image_proxy_dns_prefetch` - Hàm cung cấp DNS Prefetch trong trường hợp sử + dụng `google_image_resize` - [x] Helper Function: `wordpress_proxy` - Resize & Cache Image sử dụng WordPress Proxy -- [x] Helper Function: `wordpress_proxy_dns_prefetch` - Hàm cung cấp DNS Prefetch trong trường hợp sử dụng `wordpress_proxy` +- [x] Helper Function: `wordpress_proxy_dns_prefetch` - Hàm cung cấp DNS Prefetch trong trường hợp sử + dụng `wordpress_proxy` - [x] Helper Function: `bear_framework_image_url` - Hàm format Image Url - dành riêng cho BEAR framework - [x] Helper Function: `create_image_thumbnail` - Hàm create thumbnail - dành riêng cho BEAR framework ### IP Helper - [x] Helper Function: `getIPAddress` - Hàm lấy ra địa chỉ IP thực tế của người dùng -- [x] Helper Function: `getIPAddressByHaProxy` - Hàm lấy ra địa chỉ IP thực tế của người dùng nhưng ở server có chạy Ha Proxy, thông qua biến `HTTP_X_FORWARDED_FOR` +- [x] Helper Function: `getIPAddressByHaProxy` - Hàm lấy ra địa chỉ IP thực tế của người dùng nhưng ở server có chạy Ha + Proxy, thông qua biến `HTTP_X_FORWARDED_FOR` - [x] Helper Function: `validateIP` - Hàm validate 1 string có phải IP ko. TRUE nếu đó là IP - [x] Helper Function: `validateIPV4` - Hàm validate 1 string có phải IP v4 ko. TRUE nếu đó là IP - [x] Helper Function: `validateIPV6` - Hàm validate 1 string có phải IP v6 ko. TRUE nếu đó là IP @@ -221,7 +246,8 @@ Các hàm này dùng debug ### Meta Helper -- [x] Helper Function: `setupMetaDnsPrefetch` - Hàm hỗ trợ gen ra 1 đoạn HTML Dns Prefetch tương tự `` +- [x] Helper Function: `setupMetaDnsPrefetch` - Hàm hỗ trợ gen ra 1 đoạn HTML Dns Prefetch tương + tự `` ### Money Helper @@ -233,13 +259,15 @@ Helper này sử dụng gói `hidehalo/nanoid-php` để gen ra 1 mã random Id Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truyền thống -Để sử dụng được gói này, cần cài packages `nguyenanhung/nanoid-helper` bằng lệnh `composer require nguyenanhung/nanoid-helper` +Để sử dụng được gói này, cần cài packages `nguyenanhung/nanoid-helper` bằng +lệnh `composer require nguyenanhung/nanoid-helper` - [x] Helper Function: `randomNanoId` ### Number Helper -- [x] Helper Function: `convertNumberToWords` - Tác dụng convert 1 số thành chữ, ví dụ `123` thành `One Hundred Twenty Three` +- [x] Helper Function: `convertNumberToWords` - Tác dụng convert 1 số thành chữ, ví dụ `123` + thành `One Hundred Twenty Three` ### Paging Helper @@ -258,12 +286,14 @@ Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truy - [x] Helper Function: `sendSimpleGetRequest` - Tiến hành thực thi 1 request đơn giản sử dụng CURL với phương thức GET - [x] Helper Function: `sendSimpleRestfulExecuteRequest` - Thực thi 1 simple request tới Restful API sử dụng CURL -- [x] Helper Function: `bear_post_async_request` - Make an asynchronous POST request - Thực hiện yêu cầu POST không đồng bộ trong nội bộ site mà không cần chờ phản hồi => Không ảnh hưởng, không trì hoãn tiến trình đang chạy +- [x] Helper Function: `bear_post_async_request` - Make an asynchronous POST request - Thực hiện yêu cầu POST không đồng + bộ trong nội bộ site mà không cần chờ phản hồi => Không ảnh hưởng, không trì hoãn tiến trình đang chạy - [x] Helper Function: `get_http_response_code` - Get HTTP Response Code with `get_headers` ### Security Helper -- [x] Helper Function: `xssValidation` - Validation dữ liệu đầu vào có bị dính lỗi XSS hay không. Hàm này không có tác dụng escape, nếu muốn, hãy cài thêm packages `nguyenanhung/security` +- [x] Helper Function: `xssValidation` - Validation dữ liệu đầu vào có bị dính lỗi XSS hay không. Hàm này không có tác + dụng escape, nếu muốn, hãy cài thêm packages `nguyenanhung/security` ### Sentry Helper @@ -278,15 +308,19 @@ Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truy - [x] Helper Function: `str_after` - Return the part of a string after a given value. - [x] Helper Function: `str_before` - Get the part of a string before a given value. - [x] Helper Function: `str_limit_words` - Limit the number of words in a string. Put value of $end to the string end. -- [x] Helper Function: `str_limit_characters` - Limit the number of characters in a string. Put value of $end to the string end. +- [x] Helper Function: `str_limit_characters` - Limit the number of characters in a string. Put value of $end to the + string end. - [x] Helper Function: `str_contains` - Tests if a string contains a given element - [x] Helper Function: `str_ignore_contains` - Tests if a string contains a given element. Ignore case sensitivity. - [x] Helper Function: `str_starts_with` - Determine if a given string starts with a given substring. -- [x] Helper Function: `str_ignore_starts_with` - Determine if a given string starts with a given substring. Ignore case sensitivity. +- [x] Helper Function: `str_ignore_starts_with` - Determine if a given string starts with a given substring. Ignore case + sensitivity. - [x] Helper Function: `str_ends_with` - Determine if a given string ends with a given substring. -- [x] Helper Function: `str_ignore_ends_with` - Determine if a given string ends with a given substring. Ignore case sensitivity. +- [x] Helper Function: `str_ignore_ends_with` - Determine if a given string ends with a given substring. Ignore case + sensitivity. - [x] Helper Function: `str_after_last` - Return the part of a string after the last occurrence of a given search value. -- [x] Helper Function: `hide_characters` - Convert `nguyenanhung` to `ngxyexanxunx`, acts as a very simple and predictable character encoding function but is necessary to hide something simple +- [x] Helper Function: `hide_characters` - Convert `nguyenanhung` to `ngxyexanxunx`, acts as a very simple and + predictable character encoding function but is necessary to hide something simple ### Text Helper @@ -324,7 +358,8 @@ Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truy - [x] Helper Function: `images_url` - Hàm customize dành riêng cho framework CodeIgniter - [x] Helper Function: `audio_url` - Hàm customize dành riêng cho framework CodeIgniter - [x] Helper Function: `append_params_into_url` - Append parameters to URL -- [x] Helper Function: `append_query_string_to_current_url` - Get current URL including query string - Hàm customize dành riêng cho framework CodeIgniter +- [x] Helper Function: `append_query_string_to_current_url` - Get current URL including query string - Hàm customize + dành riêng cho framework CodeIgniter ### UUID Helper @@ -336,10 +371,14 @@ Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truy ### Video Embed Helper -- [x] Helper Function: `convert_video_embed_vimeo` - Convert Video URL to Embed Vimeo (ít dùng, lưu tại đây vì còn nhiều project cũ đang sử dụng) -- [x] Helper Function: `convert_video_embed_dailymotion` - Convert Video URL to Embed DailyMotion (ít dùng, lưu tại đây vì còn nhiều project cũ đang sử dụng) -- [x] Helper Function: `convert_video_embed_youtube` - Convert Video URL to Embed YouTube (ít dùng, lưu tại đây vì còn nhiều project cũ đang sử dụng) -- [x] Helper Function: `convert_video_v_embed_youtube` - Convert Video URL to Embed YouTube (ít dùng, lưu tại đây vì còn nhiều project cũ đang sử dụng) +- [x] Helper Function: `convert_video_embed_vimeo` - Convert Video URL to Embed Vimeo (ít dùng, lưu tại đây vì còn nhiều + project cũ đang sử dụng) +- [x] Helper Function: `convert_video_embed_dailymotion` - Convert Video URL to Embed DailyMotion (ít dùng, lưu tại đây + vì còn nhiều project cũ đang sử dụng) +- [x] Helper Function: `convert_video_embed_youtube` - Convert Video URL to Embed YouTube (ít dùng, lưu tại đây vì còn + nhiều project cũ đang sử dụng) +- [x] Helper Function: `convert_video_v_embed_youtube` - Convert Video URL to Embed YouTube (ít dùng, lưu tại đây vì còn + nhiều project cũ đang sử dụng) - [x] Helper Function: `youtube_image_thumbnail` - Convert YoutubeID to Youtube Thumbnail URL ### XML Helper @@ -382,7 +421,8 @@ Class cung cấp 1 số phương thức giúp xử lý hình ảnh - [x] Method `wordpressProxy` - Tạo URL Resize sử dụng WordPress Proxy - [x] Method `wordpressProxyDnsPrefetch` - Setup DNS Prefetch cho WordPress Proxy, nhằm tăng tốc độ truy vấn - [x] Method `createThumbnail` - Hàm tạo Thumbnail, để sử dụng cần cài thêm gói `nguyenanhung/image` -- [x] Method `createThumbnailWithCodeIgniterCache` - Hàm tạo Thumbnail kết hợp thư viện Cache của CodeIgniter, để sử dụng cần cài thêm gói `nguyenanhung/image` +- [x] Method `createThumbnailWithCodeIgniterCache` - Hàm tạo Thumbnail kết hợp thư viện Cache của CodeIgniter, để sử + dụng cần cài thêm gói `nguyenanhung/image` ## Maintainer & Supporter diff --git a/composer.json b/composer.json index cb18d4e..c0e64bd 100644 --- a/composer.json +++ b/composer.json @@ -1,97 +1,97 @@ { - "name": "nguyenanhung/codeigniter-basic-helper", - "type": "library", - "description": "CodeIgniter - Basic Helper", - "keywords": [ - "php", - "codeigniter", - "codeigniter3", - "codeigniter-helper", - "codeigniter-library", - "codeigniter-startapp", - "helper", - "library" - ], - "homepage": "https://github.com/nguyenanhung/codeigniter-basic-helper", - "license": "GPL-3.0", - "authors": [ - { - "name": "Nguyen An Hung", - "email": "dev@nguyenanhung.com", - "homepage": "https://nguyenanhung.com", - "role": "Developer" - } - ], - "require": { - "php": ">=5.6", - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "nguyenanhung/html-helper": "^2.0 || ^1.0", - "nguyenanhung/mobile-helper": "^2.0 || ^1.0", - "nguyenanhung/image-helper": "^2.0 || ^1.0", - "nguyenanhung/basic-miscellaneous-helper": "^2.0 || ^1.0" - }, - "require-dev": { - "nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0", - "nguyenanhung/nanoid-helper": "^2.0 || ^1.0", - "nguyenanhung/json-helper": "^2.0 || ^1.0", - "nguyenanhung/image": "^3.0 || ^2.0 || ^1.0", - "nguyenanhung/codeigniter-framework": ">= 3.1" - }, - "autoload": { - "psr-4": { - "nguyenanhung\\CodeIgniter\\BasicHelper\\": "src/" - }, - "files": [ - "helpers/alphaid_helper.php", - "helpers/array_helper.php", - "helpers/assets_helper.php", - "helpers/blogspot_helper.php", - "helpers/byte_helper.php", - "helpers/chart_render.php", - "helpers/common_helper.php", - "helpers/database_helper.php", - "helpers/date_helper.php", - "helpers/debug_helper.php", - "helpers/download_helper.php", - "helpers/env_helper.php", - "helpers/escape_helper.php", - "helpers/facebook_helper.php", - "helpers/file_helper.php", - "helpers/form_helper.php", - "helpers/gravatar_helper.php", - "helpers/html_helper.php", - "helpers/image_helper.php", - "helpers/ip_helper.php", - "helpers/meta_helper.php", - "helpers/japan_helper.php", - "helpers/money_helper.php", - "helpers/nanoid_helper.php", - "helpers/number_helper.php", - "helpers/paging_helper.php", - "helpers/placeholder_helper.php", - "helpers/request_helper.php", - "helpers/security_helper.php", - "helpers/sentry_helper.php", - "helpers/string_helper.php", - "helpers/text_helper.php", - "helpers/tinyurl_helper.php", - "helpers/url_helper.php", - "helpers/uuid_helper.php", - "helpers/video_embed_helper.php", - "helpers/vn_province_helper.php", - "helpers/xml_helper.php" - ] - }, - "suggest": { - "ext-curl": "Need support CURL", - "ext-json": "Need support JSON", - "nguyenanhung/helpers": "Awesome Helpers - Powerful Library, Helpers and Tools", - "nguyenanhung/image": "Need support for Image Service", - "nguyenanhung/nanoid-helper": "Need support for helper function randomNanoId()", - "nguyenanhung/json-helper": "Need support for JSON", - "nguyenanhung/mobile-helper": "Need support for Mobile Support", - "sentry/sdk": "Need support for Logging with Sentry" - } + "name": "nguyenanhung/codeigniter-basic-helper", + "type": "library", + "description": "CodeIgniter - Basic Helper", + "keywords": [ + "php", + "codeigniter", + "codeigniter3", + "codeigniter-helper", + "codeigniter-library", + "codeigniter-startapp", + "helper", + "library" + ], + "homepage": "https://github.com/nguyenanhung/codeigniter-basic-helper", + "license": "GPL-3.0", + "authors": [ + { + "name": "Nguyen An Hung", + "email": "dev@nguyenanhung.com", + "homepage": "https://nguyenanhung.com", + "role": "Developer" + } + ], + "require": { + "php": ">=5.6", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "nguyenanhung/html-helper": "^2.0 || ^1.0", + "nguyenanhung/mobile-helper": "^2.0 || ^1.0", + "nguyenanhung/image-helper": "^2.0 || ^1.0", + "nguyenanhung/basic-miscellaneous-helper": "^2.0 || ^1.0" + }, + "require-dev": { + "nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0", + "nguyenanhung/nanoid-helper": "^2.0 || ^1.0", + "nguyenanhung/json-helper": "^2.0 || ^1.0", + "nguyenanhung/image": "^3.0 || ^2.0 || ^1.0", + "nguyenanhung/codeigniter-framework": ">= 3.1" + }, + "autoload": { + "psr-4": { + "nguyenanhung\\CodeIgniter\\BasicHelper\\": "src/" + }, + "files": [ + "helpers/alphaid_helper.php", + "helpers/array_helper.php", + "helpers/assets_helper.php", + "helpers/blogspot_helper.php", + "helpers/byte_helper.php", + "helpers/chart_render.php", + "helpers/common_helper.php", + "helpers/database_helper.php", + "helpers/date_helper.php", + "helpers/debug_helper.php", + "helpers/download_helper.php", + "helpers/env_helper.php", + "helpers/escape_helper.php", + "helpers/facebook_helper.php", + "helpers/file_helper.php", + "helpers/form_helper.php", + "helpers/gravatar_helper.php", + "helpers/html_helper.php", + "helpers/image_helper.php", + "helpers/ip_helper.php", + "helpers/meta_helper.php", + "helpers/japan_helper.php", + "helpers/money_helper.php", + "helpers/nanoid_helper.php", + "helpers/number_helper.php", + "helpers/paging_helper.php", + "helpers/placeholder_helper.php", + "helpers/request_helper.php", + "helpers/security_helper.php", + "helpers/sentry_helper.php", + "helpers/string_helper.php", + "helpers/text_helper.php", + "helpers/tinyurl_helper.php", + "helpers/url_helper.php", + "helpers/uuid_helper.php", + "helpers/video_embed_helper.php", + "helpers/vn_province_helper.php", + "helpers/xml_helper.php" + ] + }, + "suggest": { + "ext-curl": "Need support CURL", + "ext-json": "Need support JSON", + "nguyenanhung/helpers": "Awesome Helpers - Powerful Library, Helpers and Tools", + "nguyenanhung/image": "Need support for Image Service", + "nguyenanhung/nanoid-helper": "Need support for helper function randomNanoId()", + "nguyenanhung/json-helper": "Need support for JSON", + "nguyenanhung/mobile-helper": "Need support for Mobile Support", + "sentry/sdk": "Need support for Logging with Sentry" + } } diff --git a/helpers/alphaid_helper.php b/helpers/alphaid_helper.php index 456d2b0..165b9ad 100644 --- a/helpers/alphaid_helper.php +++ b/helpers/alphaid_helper.php @@ -8,122 +8,122 @@ * Date: 09/11/2021 * Time: 08:52 */ -if ( ! function_exists('generateAlphaId')) { - /** - * Translates a number to a short alphanumeric version - * - * Translated any number up to 9007199254740992 - * to a shorter version in letters e.g.: - * 9007199254740989 --> PpQXn7COf - * - * specifying the second argument true, it will - * translate back e.g.: - * PpQXn7COf --> 9007199254740989 - * - * this function is based on any2dec && dec2any by - * fragmer[at]mail[dot]ru - * see: http://nl3.php.net/manual/en/function.base-convert.php#52450 - * - * If you want the alphaID to be at least 3 letter long, use the - * $pad_up = 3 argument - * - * In most cases this is better than totally random ID generators - * because this can easily avoid duplicate ID's. - * For example if you correlate the alpha ID to an auto incrementing ID - * in your database, you're done. - * - * The reverse is done because it makes it slightly more cryptic, - * but it also makes it easier to spread lots of IDs in different - * directories on your filesystem. Example: - * $part1 = substr($alpha_id,0,1); - * $part2 = substr($alpha_id,1,1); - * $part3 = substr($alpha_id,2,strlen($alpha_id)); - * $destindir = "/".$part1."/".$part2."/".$part3; - * // by reversing, directories are more evenly spread out. The - * // first 26 directories already occupy 26 main levels - * - * more info on limitation: - * - http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/165372 - * - * if you really need this for bigger numbers you probably have to look - * at things like: http://theserverpages.com/php/manual/en/ref.bc.php - * or: http://theserverpages.com/php/manual/en/ref.gmp.php - * but I haven't really dugg into this. If you have more info on those - * matters feel free to leave a comment. - * - * @param mixed $in String or long input to translate - * @param bool $to_num Reverses translation when true - * @param mixed $pad_up Number or boolean padds the result up to a specified length - * @param mixed $passKey Supplying a password makes it harder to calculate the original ID - * - * @return string string or long - * @author Kevin van Zonneveld';
+ array_map(static function ($var) {
+ var_dump($var);
+ }, func_get_args());
+ die;
+ }
}
-if ( ! function_exists('ddd')) {
- function ddd($str)
- {
- echo "";
- var_dump($str);
- echo "
";
- die;
- }
+if (!function_exists('ddd')) {
+ function ddd($str)
+ {
+ echo "";
+ var_dump($str);
+ echo "
";
+ die;
+ }
}
-if ( ! function_exists('dump')) {
- function dump($str = '')
- {
- echo "";
- print_r($str);
- echo "
";
- }
+if (!function_exists('dump')) {
+ function dump($str = '')
+ {
+ echo "";
+ print_r($str);
+ echo "
";
+ }
}
diff --git a/helpers/download_helper.php b/helpers/download_helper.php
index a8dca70..213757d 100644
--- a/helpers/download_helper.php
+++ b/helpers/download_helper.php
@@ -8,100 +8,100 @@
* Date: 17/05/2023
* Time: 11:02
*/
-if ( ! function_exists('download_file_chunked')) {
- function download_file_chunked($path)
- {
- $file_name = basename($path);
+if (!function_exists('download_file_chunked')) {
+ function download_file_chunked($path)
+ {
+ $file_name = basename($path);
- // get the file's mime type to send the correct content type header
- //$finfo = finfo_open(FILEINFO_MIME_TYPE); //For remote file, it may not work
- //$mime_type = finfo_file($finfo, $path); //For remote file, it may not work
- $mime_type = mime_type($file_name);
+ // get the file's mime type to send the correct content type header
+ //$finfo = finfo_open(FILEINFO_MIME_TYPE); //For remote file, it may not work
+ //$mime_type = finfo_file($finfo, $path); //For remote file, it may not work
+ $mime_type = mime_type($file_name);
- $attachment = (mb_strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) ? "" : " attachment"; // IE 5.5 fix.
+ $attachment = (mb_strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) ? "" : " attachment"; // IE 5.5 fix.
- // send the headers
- header("Content-Type: $mime_type");
- header('Content-Transfer-Encoding: binary');
- //header('Content-Length: ' . filesize($path)); //PHP Warning: filesize(): stat failed for remote file
- //header("Content-Disposition: attachment; filename=$file_name;");
- header("Content-Disposition: $attachment; filename=$file_name;");
+ // send the headers
+ header("Content-Type: $mime_type");
+ header('Content-Transfer-Encoding: binary');
+ //header('Content-Length: ' . filesize($path)); //PHP Warning: filesize(): stat failed for remote file
+ //header("Content-Disposition: attachment; filename=$file_name;");
+ header("Content-Disposition: $attachment; filename=$file_name;");
- $options = array(
- "ssl" => array(
- "verify_peer" => false,
- "verify_peer_name" => false,
- ),
- );
+ $options = array(
+ "ssl" => array(
+ "verify_peer" => false,
+ "verify_peer_name" => false,
+ ),
+ );
- $context = stream_context_create($options);
+ $context = stream_context_create($options);
- //$handle = fopen($path, 'rb');
- $handle = fopen($path, 'rb', false, $context);
+ //$handle = fopen($path, 'rb');
+ $handle = fopen($path, 'rb', false, $context);
- ob_end_clean();//output buffering is disabled, so you won't hit your memory limit
+ ob_end_clean();//output buffering is disabled, so you won't hit your memory limit
- $buffer = '';
- $chunkSize = 1024 * 1024;
+ $buffer = '';
+ $chunkSize = 1024 * 1024;
- //$newfname = basename($path);
- //$newf = fopen ($newfname, "wb");
+ //$newfname = basename($path);
+ //$newf = fopen ($newfname, "wb");
- ob_start();
- while ( ! feof($handle)) {
- $buffer = fread($handle, $chunkSize);
- echo $buffer;
- ob_flush();
- flush();
- //fwrite($newf, $buffer, $chunkSize);
- }
+ ob_start();
+ while (!feof($handle)) {
+ $buffer = fread($handle, $chunkSize);
+ echo $buffer;
+ ob_flush();
+ flush();
+ //fwrite($newf, $buffer, $chunkSize);
+ }
- fclose($handle);
+ fclose($handle);
- //fclose($newf);
+ //fclose($newf);
- exit;
- }
+ exit;
+ }
}
-if ( ! function_exists('download_large_file')) {
- function download_large_file($path)
- {
- // the file name of the download, change this if needed
- $file_name = basename($path);
+if (!function_exists('download_large_file')) {
+ function download_large_file($path)
+ {
+ // the file name of the download, change this if needed
+ $file_name = basename($path);
- // get the file's mime type to send the correct content type header
- //$finfo = finfo_open(FILEINFO_MIME_TYPE); //For remote file, it may not work
- //$mime_type = finfo_file($finfo, $path); //For remote file, it may not work
- $mime_type = mime_type($file_name);
+ // get the file's mime type to send the correct content type header
+ //$finfo = finfo_open(FILEINFO_MIME_TYPE); //For remote file, it may not work
+ //$mime_type = finfo_file($finfo, $path); //For remote file, it may not work
+ $mime_type = mime_type($file_name);
- $attachment = (mb_strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) ? "" : " attachment"; // IE 5.5 fix.
+ $attachment = (mb_strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) ? "" : " attachment"; // IE 5.5 fix.
- // send the headers
- header("Content-Type: $mime_type");
- //header('Content-Length: ' . filesize($path)); //PHP Warning: filesize(): stat failed for remote file
- //header("Content-Disposition: attachment; filename=$file_name;");
- header("Content-Disposition: $attachment; filename=$file_name;");
+ // send the headers
+ header("Content-Type: $mime_type");
+ //header('Content-Length: ' . filesize($path)); //PHP Warning: filesize(): stat failed for remote file
+ //header("Content-Disposition: attachment; filename=$file_name;");
+ header("Content-Disposition: $attachment; filename=$file_name;");
- //Disable SSL verification
- $options = array(
- "ssl" => array(
- "verify_peer" => false,
- "verify_peer_name" => false,
- ),
- );
+ //Disable SSL verification
+ $options = array(
+ "ssl" => array(
+ "verify_peer" => false,
+ "verify_peer_name" => false,
+ ),
+ );
- $context = stream_context_create($options);
+ $context = stream_context_create($options);
- // stream the file
- //$fp = fopen($path, 'rb');
- $fp = fopen($path, 'rb', false, $context);
+ // stream the file
+ //$fp = fopen($path, 'rb');
+ $fp = fopen($path, 'rb', false, $context);
- ob_end_clean();//output buffering is disabled, so you won't hit your memory limit
+ ob_end_clean();//output buffering is disabled, so you won't hit your memory limit
- fpassthru($fp);
+ fpassthru($fp);
- fclose($fp);
+ fclose($fp);
- exit;
- }
+ exit;
+ }
}
diff --git a/helpers/env_helper.php b/helpers/env_helper.php
index 2f34997..cc07294 100644
--- a/helpers/env_helper.php
+++ b/helpers/env_helper.php
@@ -8,38 +8,38 @@
* Date: 30/07/2022
* Time: 15:47
*/
-if ( ! function_exists('bear_get_env')) {
- /**
- * Function bear_get_env
- *
- * @param $a
- *
- * @return array|false|mixed|string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 30/07/2022 51:23
- */
- function bear_get_env($a)
- {
- if ( ! is_array($a)) {
- $a = array($a);
- }
+if (!function_exists('bear_get_env')) {
+ /**
+ * Function bear_get_env
+ *
+ * @param $a
+ *
+ * @return array|false|mixed|string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 30/07/2022 51:23
+ */
+ function bear_get_env($a)
+ {
+ if (!is_array($a)) {
+ $a = array($a);
+ }
- foreach ($a as $b) {
- if (isset($_SERVER[$b])) {
- return $_SERVER[$b];
- }
- if (isset($_ENV[$b])) {
- return $_ENV[$b];
- }
- if (@getenv($b)) {
- return @getenv($b);
- }
- if (function_exists('apache_getenv') && apache_getenv($b, true)) {
- return apache_getenv($b, true);
- }
- }
+ foreach ($a as $b) {
+ if (isset($_SERVER[$b])) {
+ return $_SERVER[$b];
+ }
+ if (isset($_ENV[$b])) {
+ return $_ENV[$b];
+ }
+ if (@getenv($b)) {
+ return @getenv($b);
+ }
+ if (function_exists('apache_getenv') && apache_getenv($b, true)) {
+ return apache_getenv($b, true);
+ }
+ }
- return '';
- }
+ return '';
+ }
}
diff --git a/helpers/escape_helper.php b/helpers/escape_helper.php
index d90e5de..7810799 100644
--- a/helpers/escape_helper.php
+++ b/helpers/escape_helper.php
@@ -8,15 +8,15 @@
* Date: 09/02/2023
* Time: 22:25
*/
-if ( ! function_exists('bear_framework_basic_clean_str')) {
- function bear_framework_basic_clean_str($str = '')
- {
- if (empty($str)) {
- return $str;
- }
- $str = trim($str);
- $str = strip_tags($str);
- $str = htmlspecialchars($str, ENT_QUOTES | ENT_HTML5 | ENT_XHTML, 'UTF-8');
- return trim($str);
- }
+if (!function_exists('bear_framework_basic_clean_str')) {
+ function bear_framework_basic_clean_str($str = '')
+ {
+ if (empty($str)) {
+ return $str;
+ }
+ $str = trim($str);
+ $str = strip_tags($str);
+ $str = htmlspecialchars($str, ENT_QUOTES | ENT_HTML5 | ENT_XHTML, 'UTF-8');
+ return trim($str);
+ }
}
diff --git a/helpers/facebook_helper.php b/helpers/facebook_helper.php
index b3c9d6a..4b50cc9 100644
--- a/helpers/facebook_helper.php
+++ b/helpers/facebook_helper.php
@@ -8,112 +8,112 @@
* Date: 21/07/2022
* Time: 11:43
*/
-if ( ! function_exists('widget_facebook_comments')) {
- /**
- * Function widget_facebook_comments
- *
- * @param string $url
- * @param string $width
- * @param int $num_posts
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 21/07/2022 48:16
- */
- function widget_facebook_comments($url = '', $width = '', $num_posts = 5)
- {
- return '';
- }
+if (!function_exists('widget_facebook_comments')) {
+ /**
+ * Function widget_facebook_comments
+ *
+ * @param string $url
+ * @param string $width
+ * @param int $num_posts
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 21/07/2022 48:16
+ */
+ function widget_facebook_comments($url = '', $width = '', $num_posts = 5)
+ {
+ return '';
+ }
}
-if ( ! function_exists('widget_facebook_share_button')) {
- /**
- * Function widget_facebook_share_button
- *
- * @param string $url
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 21/07/2022 45:46
- */
- function widget_facebook_share_button($url = '')
- {
- return '';
- }
+if (!function_exists('widget_facebook_share_button')) {
+ /**
+ * Function widget_facebook_share_button
+ *
+ * @param string $url
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 21/07/2022 45:46
+ */
+ function widget_facebook_share_button($url = '')
+ {
+ return '';
+ }
}
-if ( ! function_exists('widget_facebook_like_button')) {
- /**
- * Function widget_facebook_like_button
- *
- * @param string $url
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 21/07/2022 45:46
- */
- function widget_facebook_like_button($url = '')
- {
- return '';
- }
+if (!function_exists('widget_facebook_like_button')) {
+ /**
+ * Function widget_facebook_like_button
+ *
+ * @param string $url
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 21/07/2022 45:46
+ */
+ function widget_facebook_like_button($url = '')
+ {
+ return '';
+ }
}
-if ( ! function_exists('widget_facebook_save_button')) {
- /**
- * Function widget_facebook_save_button
- *
- * @param string $url
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 21/07/2022 45:46
- */
- function widget_facebook_save_button($url = '')
- {
- return '';
- }
+if (!function_exists('widget_facebook_save_button')) {
+ /**
+ * Function widget_facebook_save_button
+ *
+ * @param string $url
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 21/07/2022 45:46
+ */
+ function widget_facebook_save_button($url = '')
+ {
+ return '';
+ }
}
-if ( ! function_exists('widget_facebook_script_init')) {
- /**
- * Function widget_facebook_script_init
- *
- * @param string $appId
- * @param string $version
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 21/07/2022 50:42
- */
- function widget_facebook_script_init($appId = '', $version = 'v14.0')
- {
- if (empty($version)) {
- $version = 'v14.0';
- }
- $url = 'https://connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=' . trim($version) . '&appId=' . trim(
- $appId
- ) . '&autoLogAppEvents=1';
- return '';
- }
+if (!function_exists('widget_facebook_script_init')) {
+ /**
+ * Function widget_facebook_script_init
+ *
+ * @param string $appId
+ * @param string $version
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 21/07/2022 50:42
+ */
+ function widget_facebook_script_init($appId = '', $version = 'v14.0')
+ {
+ if (empty($version)) {
+ $version = 'v14.0';
+ }
+ $url = 'https://connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=' . trim($version) . '&appId=' . trim(
+ $appId
+ ) . '&autoLogAppEvents=1';
+ return '';
+ }
}
-if ( ! function_exists('widget_facebook_div_init')) {
- /**
- * Function widget_facebook_div_init
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 30/07/2022 18:56
- */
- function widget_facebook_div_init()
- {
- return '';
- }
+if (!function_exists('widget_facebook_div_init')) {
+ /**
+ * Function widget_facebook_div_init
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 30/07/2022 18:56
+ */
+ function widget_facebook_div_init()
+ {
+ return '';
+ }
}
diff --git a/helpers/file_helper.php b/helpers/file_helper.php
index 9914836..055bc3e 100644
--- a/helpers/file_helper.php
+++ b/helpers/file_helper.php
@@ -8,402 +8,402 @@
* Date: 09/11/2021
* Time: 09:20
*/
-if ( ! function_exists('write_file')) {
- /**
- * Write File
- *
- * Writes data to the file specified in the path.
- * Creates a new file if non-existent.
- *
- * @param string $path File path
- * @param string $data Data to write
- * @param string $mode fopen() mode (default: 'wb')
- *
- * @return bool
- */
- function write_file($path, $data, $mode = 'wb')
- {
- if ( ! $fp = @fopen($path, $mode)) {
- return false;
- }
-
- flock($fp, LOCK_EX);
-
- for ($result = $written = 0, $length = mb_strlen($data); $written < $length; $written += $result) {
- if (($result = fwrite($fp, mb_substr($data, $written))) === false) {
- break;
- }
- }
-
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return is_int($result);
- }
+if (!function_exists('write_file')) {
+ /**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creates a new file if non-existent.
+ *
+ * @param string $path File path
+ * @param string $data Data to write
+ * @param string $mode fopen() mode (default: 'wb')
+ *
+ * @return bool
+ */
+ function write_file($path, $data, $mode = 'wb')
+ {
+ if (!$fp = @fopen($path, $mode)) {
+ return false;
+ }
+
+ flock($fp, LOCK_EX);
+
+ for ($result = $written = 0, $length = mb_strlen($data); $written < $length; $written += $result) {
+ if (($result = fwrite($fp, mb_substr($data, $written))) === false) {
+ break;
+ }
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return is_int($result);
+ }
}
-if ( ! function_exists('delete_files')) {
- /**
- * Delete Files
- *
- * Deletes all files contained in the supplied directory path.
- * Files must be writable or owned by the system in order to be deleted.
- * If the second parameter is set to TRUE, any directories contained
- * within the supplied base directory will be nuked as well.
- *
- * @param string $path File path
- * @param bool $del_dir Whether to delete any directories found in the path
- * @param bool $htdocs Whether to skip deleting .htaccess and index page files
- * @param int $_level Current directory depth level (default: 0; internal use only)
- *
- * @return bool
- */
- function delete_files($path, $del_dir = false, $htdocs = false, $_level = 0)
- {
- // Trim the trailing slash
- $path = rtrim($path, '/\\');
-
- if ( ! $current_dir = @opendir($path)) {
- return false;
- }
-
- while (false !== ($filename = @readdir($current_dir))) {
- if ($filename !== '.' && $filename !== '..') {
- $filepath = $path . DIRECTORY_SEPARATOR . $filename;
-
- if (is_dir($filepath) && ! is_link($filepath)) {
- delete_files($filepath, $del_dir, $htdocs, $_level + 1);
- } elseif ($htdocs !== true || ! preg_match(
- '/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i',
- $filename
- )) {
- @unlink($filepath);
- }
- }
- }
-
- closedir($current_dir);
-
- if (($del_dir === true && $_level > 0)) {
- return @rmdir($path);
- }
-
- return true;
- }
+if (!function_exists('delete_files')) {
+ /**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any directories contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @param string $path File path
+ * @param bool $del_dir Whether to delete any directories found in the path
+ * @param bool $htdocs Whether to skip deleting .htaccess and index page files
+ * @param int $_level Current directory depth level (default: 0; internal use only)
+ *
+ * @return bool
+ */
+ function delete_files($path, $del_dir = false, $htdocs = false, $_level = 0)
+ {
+ // Trim the trailing slash
+ $path = rtrim($path, '/\\');
+
+ if (!$current_dir = @opendir($path)) {
+ return false;
+ }
+
+ while (false !== ($filename = @readdir($current_dir))) {
+ if ($filename !== '.' && $filename !== '..') {
+ $filepath = $path . DIRECTORY_SEPARATOR . $filename;
+
+ if (is_dir($filepath) && !is_link($filepath)) {
+ delete_files($filepath, $del_dir, $htdocs, $_level + 1);
+ } elseif ($htdocs !== true || !preg_match(
+ '/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i',
+ $filename
+ )) {
+ @unlink($filepath);
+ }
+ }
+ }
+
+ closedir($current_dir);
+
+ if (($del_dir === true && $_level > 0)) {
+ return @rmdir($path);
+ }
+
+ return true;
+ }
}
-if ( ! function_exists('formatSizeUnits')) {
- /**
- * Function formatSizeUnits
- *
- * @param $bytes
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/11/2021 20:31
- */
- function formatSizeUnits($bytes)
- {
- if ($bytes >= 1073741824) {
- $bytes = number_format($bytes / 1073741824, 2) . ' GB';
- } elseif ($bytes >= 1048576) {
- $bytes = number_format($bytes / 1048576, 2) . ' MB';
- } elseif ($bytes >= 1024) {
- $bytes = number_format($bytes / 1024, 2) . ' KB';
- } elseif ($bytes > 1) {
- $bytes .= ' bytes';
- } elseif ($bytes === 1) {
- $bytes .= ' byte';
- } else {
- $bytes = '0 bytes';
- }
-
- return $bytes;
- }
+if (!function_exists('formatSizeUnits')) {
+ /**
+ * Function formatSizeUnits
+ *
+ * @param $bytes
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/11/2021 20:31
+ */
+ function formatSizeUnits($bytes)
+ {
+ if ($bytes >= 1073741824) {
+ $bytes = number_format($bytes / 1073741824, 2) . ' GB';
+ } elseif ($bytes >= 1048576) {
+ $bytes = number_format($bytes / 1048576, 2) . ' MB';
+ } elseif ($bytes >= 1024) {
+ $bytes = number_format($bytes / 1024, 2) . ' KB';
+ } elseif ($bytes > 1) {
+ $bytes .= ' bytes';
+ } elseif ($bytes === 1) {
+ $bytes .= ' byte';
+ } else {
+ $bytes = '0 bytes';
+ }
+
+ return $bytes;
+ }
}
-if ( ! function_exists('genarateFileIndex')) {
- /**
- * Function genarateFileIndex
- *
- * @param string $file_path
- * @param string $file_name
- *
- * @return bool
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/11/2021 55:13
- */
- function genarateFileIndex($file_path = '', $file_name = 'index.html')
- {
- if (function_exists('log_message') && function_exists('write_file')) {
- if ($file_path !== '') {
- if (is_dir($file_path) === false) {
- if ( ! mkdir($file_path) && ! is_dir($file_path)) {
- throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
- }
- log_message('debug', 'Genarate new Folder: ' . $file_path);
- }
- // SET file location
- $file_location = $file_path . '/' . $file_name;
- // Tạo file index.html nếu chưa có
- if (file_exists($file_location) === false) {
- $file_content = "\n\n\n403 Forbidden \n\n\nDirectory access is forbidden.
\n\n";
- write_file($file_location, $file_content);
- log_message('debug', 'Genarate new file Index.html in Location ' . $file_location);
-
- return true;
- }
- log_message('debug', 'File Index.html Exists in Location ' . $file_location);
-
- return false;
- }
- log_message('debug', 'Genarate File Index.html failed');
-
- return false;
- }
-
- return false;
- }
+if (!function_exists('genarateFileIndex')) {
+ /**
+ * Function genarateFileIndex
+ *
+ * @param string $file_path
+ * @param string $file_name
+ *
+ * @return bool
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/11/2021 55:13
+ */
+ function genarateFileIndex($file_path = '', $file_name = 'index.html')
+ {
+ if (function_exists('log_message') && function_exists('write_file')) {
+ if ($file_path !== '') {
+ if (is_dir($file_path) === false) {
+ if (!mkdir($file_path) && !is_dir($file_path)) {
+ throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
+ }
+ log_message('debug', 'Genarate new Folder: ' . $file_path);
+ }
+ // SET file location
+ $file_location = $file_path . '/' . $file_name;
+ // Tạo file index.html nếu chưa có
+ if (file_exists($file_location) === false) {
+ $file_content = "\n\n\n403 Forbidden \n\n\nDirectory access is forbidden.
\n\n";
+ write_file($file_location, $file_content);
+ log_message('debug', 'Genarate new file Index.html in Location ' . $file_location);
+
+ return true;
+ }
+ log_message('debug', 'File Index.html Exists in Location ' . $file_location);
+
+ return false;
+ }
+ log_message('debug', 'Genarate File Index.html failed');
+
+ return false;
+ }
+
+ return false;
+ }
}
-if ( ! function_exists('genarateFileHtaccess')) {
- /**
- * Function genarateFileHtaccess
- *
- * @param string $file_path
- * @param string $file_name
- *
- * @return bool
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/11/2021 55:51
- */
- function genarateFileHtaccess($file_path = '', $file_name = '.htaccess')
- {
- if (function_exists('log_message') && function_exists('write_file')) {
- if ($file_path !== '') {
- // SET file Path
- if (is_dir($file_path) === false) {
- if ( ! mkdir($file_path) && ! is_dir($file_path)) {
- throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
- }
- log_message('debug', 'Genarate new Folder: ' . $file_path);
- }
- $file_location = $file_path . '/' . $file_name;
- // Tạo file .htaccess nếu chưa có
- if (file_exists($file_location) === false) {
- $file_content = "RewriteEngine On\nOptions -Indexes\nAddType text/plain php3 php4 php5 php cgi asp aspx html css js";
- write_file($file_location, $file_content);
- log_message('debug', 'Genarate new file .htaccess in Location ' . $file_location);
-
- return true;
- }
- log_message('debug', 'File .htaccess Exists in Location ' . $file_location);
-
- return false;
- }
- log_message('debug', 'Genarate File .htaccess failed');
-
- return false;
- }
-
- return false;
- }
+if (!function_exists('genarateFileHtaccess')) {
+ /**
+ * Function genarateFileHtaccess
+ *
+ * @param string $file_path
+ * @param string $file_name
+ *
+ * @return bool
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/11/2021 55:51
+ */
+ function genarateFileHtaccess($file_path = '', $file_name = '.htaccess')
+ {
+ if (function_exists('log_message') && function_exists('write_file')) {
+ if ($file_path !== '') {
+ // SET file Path
+ if (is_dir($file_path) === false) {
+ if (!mkdir($file_path) && !is_dir($file_path)) {
+ throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
+ }
+ log_message('debug', 'Genarate new Folder: ' . $file_path);
+ }
+ $file_location = $file_path . '/' . $file_name;
+ // Tạo file .htaccess nếu chưa có
+ if (file_exists($file_location) === false) {
+ $file_content = "RewriteEngine On\nOptions -Indexes\nAddType text/plain php3 php4 php5 php cgi asp aspx html css js";
+ write_file($file_location, $file_content);
+ log_message('debug', 'Genarate new file .htaccess in Location ' . $file_location);
+
+ return true;
+ }
+ log_message('debug', 'File .htaccess Exists in Location ' . $file_location);
+
+ return false;
+ }
+ log_message('debug', 'Genarate File .htaccess failed');
+
+ return false;
+ }
+
+ return false;
+ }
}
-if ( ! function_exists('genarateFileReadme')) {
- /**
- * Function genarateFileReadme
- *
- * @param string $file_path
- * @param string $file_name
- *
- * @return bool
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/15/2021 58:14
- */
- function genarateFileReadme($file_path = '', $file_name = 'README.md')
- {
- if (function_exists('log_message') && function_exists('write_file')) {
- if ($file_path !== '') {
- if (is_dir($file_path) === false) {
- if ( ! mkdir($file_path) && ! is_dir($file_path)) {
- throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
- }
- log_message('debug', 'Genarate new Folder: ' . $file_path);
- }
- $file_location = $file_path . '/' . $file_name;
- // Tạo file .htaccess nếu chưa có
- if (file_exists($file_location) === false) {
- $file_content = "# README";
- write_file($file_location, $file_content);
- log_message('debug', 'Genarate new file ' . $file_name . ' in Location ' . $file_location);
-
- return true;
- }
- log_message('debug', 'File ' . $file_name . ' Exists in Location ' . $file_location);
-
- return false;
- }
- log_message('debug', 'Genarate File ' . $file_name . ' failed');
-
- return false;
- }
-
- return false;
- }
+if (!function_exists('genarateFileReadme')) {
+ /**
+ * Function genarateFileReadme
+ *
+ * @param string $file_path
+ * @param string $file_name
+ *
+ * @return bool
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/15/2021 58:14
+ */
+ function genarateFileReadme($file_path = '', $file_name = 'README.md')
+ {
+ if (function_exists('log_message') && function_exists('write_file')) {
+ if ($file_path !== '') {
+ if (is_dir($file_path) === false) {
+ if (!mkdir($file_path) && !is_dir($file_path)) {
+ throw new RuntimeException(sprintf('Directory "%s" was not created', $file_path));
+ }
+ log_message('debug', 'Genarate new Folder: ' . $file_path);
+ }
+ $file_location = $file_path . '/' . $file_name;
+ // Tạo file .htaccess nếu chưa có
+ if (file_exists($file_location) === false) {
+ $file_content = "# README";
+ write_file($file_location, $file_content);
+ log_message('debug', 'Genarate new file ' . $file_name . ' in Location ' . $file_location);
+
+ return true;
+ }
+ log_message('debug', 'File ' . $file_name . ' Exists in Location ' . $file_location);
+
+ return false;
+ }
+ log_message('debug', 'Genarate File ' . $file_name . ' failed');
+
+ return false;
+ }
+
+ return false;
+ }
}
-if ( ! function_exists('makeNewFolder')) {
- /**
- * Function makeNewFolder
- *
- * @param string $folderPath
- *
- * @return bool
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/11/2021 57:33
- */
- function makeNewFolder($folderPath = '')
- {
- if (empty($folderPath)) {
- return false;
- }
- if (is_dir($folderPath) === false) {
- if ( ! mkdir($folderPath) && ! is_dir($folderPath)) {
- throw new RuntimeException(sprintf('Directory "%s" was not created', $folderPath));
- }
- genarateFileIndex($folderPath);
- genarateFileHtaccess($folderPath);
- genarateFileReadme($folderPath);
-
- return true;
- }
-
- return false;
- }
+if (!function_exists('makeNewFolder')) {
+ /**
+ * Function makeNewFolder
+ *
+ * @param string $folderPath
+ *
+ * @return bool
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/11/2021 57:33
+ */
+ function makeNewFolder($folderPath = '')
+ {
+ if (empty($folderPath)) {
+ return false;
+ }
+ if (is_dir($folderPath) === false) {
+ if (!mkdir($folderPath) && !is_dir($folderPath)) {
+ throw new RuntimeException(sprintf('Directory "%s" was not created', $folderPath));
+ }
+ genarateFileIndex($folderPath);
+ genarateFileHtaccess($folderPath);
+ genarateFileReadme($folderPath);
+
+ return true;
+ }
+
+ return false;
+ }
}
-if ( ! function_exists('new_folder')) {
- /**
- * Function new_folder
- *
- * @param string $folder
- *
- * @return bool
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/11/2021 58:13
- */
- function new_folder($folder = '')
- {
- return makeNewFolder($folder);
- }
+if (!function_exists('new_folder')) {
+ /**
+ * Function new_folder
+ *
+ * @param string $folder
+ *
+ * @return bool
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/11/2021 58:13
+ */
+ function new_folder($folder = '')
+ {
+ return makeNewFolder($folder);
+ }
}
-if ( ! function_exists('scan_folder')) {
- /**
- * Function scan_folder - Quét và lấy ra danh sách các thông tin dữ liệu trong folder
- *
- * @param $path
- * @param $ignoreFiles
- *
- * @return array|false
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/12/2022 26:58
- */
- function scan_folder($path, $ignoreFiles = array())
- {
- try {
- if (is_dir($path)) {
- $data = array_diff(scandir($path), array_merge(array('.', '..', '.DS_Store'), $ignoreFiles));
- natsort($data);
-
- return $data;
- }
-
- return array();
- } catch (Exception $ex) {
- if (function_exists('log_message')) {
- log_message('error', __get_error_message__($ex));
- log_message('error', __get_error_trace__($ex));
- }
- return array();
- }
- }
+if (!function_exists('scan_folder')) {
+ /**
+ * Function scan_folder - Quét và lấy ra danh sách các thông tin dữ liệu trong folder
+ *
+ * @param $path
+ * @param $ignoreFiles
+ *
+ * @return array|false
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/12/2022 26:58
+ */
+ function scan_folder($path, $ignoreFiles = array())
+ {
+ try {
+ if (is_dir($path)) {
+ $data = array_diff(scandir($path), array_merge(array('.', '..', '.DS_Store'), $ignoreFiles));
+ natsort($data);
+
+ return $data;
+ }
+
+ return array();
+ } catch (Exception $ex) {
+ if (function_exists('log_message')) {
+ log_message('error', __get_error_message__($ex));
+ log_message('error', __get_error_trace__($ex));
+ }
+ return array();
+ }
+ }
}
-if ( ! function_exists('getAllFileSizeInFolder')) {
- /**
- * Function getAllFileSizeInFolder - Get all File size in Folder
- *
- * @param $path
- *
- * @return float
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/12/2022 24:09
- */
- function getAllFileSizeInFolder($path)
- {
- $size = 0;
- // Kiểm tra thư mục có tồn tại hay không
- if (file_exists($path) && is_dir($path)) {
- // Quét tất cả các file trong thư mục
- $result = scandir($path);
-
- // Lọc ra các thư mục hiện tại (.) và các thư mục cha (..)
- $files = array_diff($result, array('.', '..'));
-
- if (count($files) > 0) {
- // Lặp qua mảng đã trả lại
- foreach ($files as $file) {
- if (is_file("$path/$file")) {
- // tính tổng size
- $size += filesize($path . '/' . $file);
- } elseif (is_dir("$path/$file")) {
- // Gọi đệ quy hàm nếu tìm thấy thư mục
- getAllFileInFolder("$path/$file");
- }
- }
- }
- }
-
- return round($size / 1024 / 1024, 2);
- }
+if (!function_exists('getAllFileSizeInFolder')) {
+ /**
+ * Function getAllFileSizeInFolder - Get all File size in Folder
+ *
+ * @param $path
+ *
+ * @return float
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/12/2022 24:09
+ */
+ function getAllFileSizeInFolder($path)
+ {
+ $size = 0;
+ // Kiểm tra thư mục có tồn tại hay không
+ if (file_exists($path) && is_dir($path)) {
+ // Quét tất cả các file trong thư mục
+ $result = scandir($path);
+
+ // Lọc ra các thư mục hiện tại (.) và các thư mục cha (..)
+ $files = array_diff($result, array('.', '..'));
+
+ if (count($files) > 0) {
+ // Lặp qua mảng đã trả lại
+ foreach ($files as $file) {
+ if (is_file("$path/$file")) {
+ // tính tổng size
+ $size += filesize($path . '/' . $file);
+ } elseif (is_dir("$path/$file")) {
+ // Gọi đệ quy hàm nếu tìm thấy thư mục
+ getAllFileInFolder("$path/$file");
+ }
+ }
+ }
+ }
+
+ return round($size / 1024 / 1024, 2);
+ }
}
-if ( ! function_exists('getAllFileInFolder')) {
- /**
- * Function getAllFileInFolder - Get all File in Folder
- *
- * @param $path
- *
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/12/2022 23:53
- */
- function getAllFileInFolder($path)
- {
- // Kiểm tra thư mục có tồn tại hay không
- if (file_exists($path) && is_dir($path)) {
- // Quét tất cả các file trong thư mục
- $result = scandir($path);
-
- // Lọc ra các thư mục hiện tại (.) và các thư mục cha (..)
- $files = array_diff($result, array('.', '..'));
-
- if (count($files) > 0) {
- // Lặp qua mảng đã trả lại
- foreach ($files as $file) {
- if (is_file("$path/$file")) {
- // Hiển thị tên File
- echo $file . "
";
- } elseif (is_dir("$path/$file")) {
- // Gọi đệ quy hàm nếu tìm thấy thư mục
- getAllFileInFolder("$path/$file");
- }
- }
- } else {
- echo "ERROR: File not Found.";
- }
- } else {
- echo "ERROR: Folder not Found.";
- }
- }
+if (!function_exists('getAllFileInFolder')) {
+ /**
+ * Function getAllFileInFolder - Get all File in Folder
+ *
+ * @param $path
+ *
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/12/2022 23:53
+ */
+ function getAllFileInFolder($path)
+ {
+ // Kiểm tra thư mục có tồn tại hay không
+ if (file_exists($path) && is_dir($path)) {
+ // Quét tất cả các file trong thư mục
+ $result = scandir($path);
+
+ // Lọc ra các thư mục hiện tại (.) và các thư mục cha (..)
+ $files = array_diff($result, array('.', '..'));
+
+ if (count($files) > 0) {
+ // Lặp qua mảng đã trả lại
+ foreach ($files as $file) {
+ if (is_file("$path/$file")) {
+ // Hiển thị tên File
+ echo $file . "
";
+ } elseif (is_dir("$path/$file")) {
+ // Gọi đệ quy hàm nếu tìm thấy thư mục
+ getAllFileInFolder("$path/$file");
+ }
+ }
+ } else {
+ echo "ERROR: File not Found.";
+ }
+ } else {
+ echo "ERROR: Folder not Found.";
+ }
+ }
}
diff --git a/helpers/form_helper.php b/helpers/form_helper.php
index 26a0061..775d73b 100644
--- a/helpers/form_helper.php
+++ b/helpers/form_helper.php
@@ -8,30 +8,30 @@
* Date: 24/02/2023
* Time: 00:00
*/
-if ( ! function_exists('join_value_multiple')) {
- /**
- * Join value multiple
- *
- * @param $str
- *
- * @return string
- */
- function join_value_multiple($str)
- {
- $num = count($str);
- $max = $num - 1;
- $string = "";
+if (!function_exists('join_value_multiple')) {
+ /**
+ * Join value multiple
+ *
+ * @param $str
+ *
+ * @return string
+ */
+ function join_value_multiple($str)
+ {
+ $num = count($str);
+ $max = $num - 1;
+ $string = "";
- for ($i = 0; $i < $num; $i++) {
- $string = $i < $max ? $string . $str[$i] . ',' : $string . $str[$i];
- }
+ for ($i = 0; $i < $num; $i++) {
+ $string = $i < $max ? $string . $str[$i] . ',' : $string . $str[$i];
+ }
- unset($i);
+ unset($i);
- if ($string === '') {
- return '0';
- }
+ if ($string === '') {
+ return '0';
+ }
- return $string;
- }
+ return $string;
+ }
}
diff --git a/helpers/gravatar_helper.php b/helpers/gravatar_helper.php
index fef23d9..36203e2 100644
--- a/helpers/gravatar_helper.php
+++ b/helpers/gravatar_helper.php
@@ -8,53 +8,53 @@
* Date: 20/01/2023
* Time: 00:30
*/
-if ( ! function_exists('bear_framework_gravatar_init')) {
- /**
- * Function bear_framework_gravatar_init
- *
- * @param $username
- *
- * @return mixed|string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 20/01/2023 36:48
- */
- function bear_framework_gravatar_init($username = 'nguyenanhung')
- {
- if ( ! function_exists('config_item') || ! function_exists('get_instance')) {
- return '';
- }
+if (!function_exists('bear_framework_gravatar_init')) {
+ /**
+ * Function bear_framework_gravatar_init
+ *
+ * @param $username
+ *
+ * @return mixed|string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 20/01/2023 36:48
+ */
+ function bear_framework_gravatar_init($username = 'nguyenanhung')
+ {
+ if (!function_exists('config_item') || !function_exists('get_instance')) {
+ return '';
+ }
- $url = 'https://vi.gravatar.com/' . trim($username) . '.json';
- $file = md5($url);
+ $url = 'https://vi.gravatar.com/' . trim($username) . '.json';
+ $file = md5($url);
- $cms = &get_instance();
- $cms->load->driver('cache', array('adapter' => 'file', 'backup' => 'dummy'));
- if ( ! $res = $cms->cache->get($file)) {
- $respond = sendSimpleGetRequest($url);
- $res = json_decode($respond, false);
- $cms->cache->save($file, $res, 86400);
- }
+ $cms = &get_instance();
+ $cms->load->driver('cache', array('adapter' => 'file', 'backup' => 'dummy'));
+ if (!$res = $cms->cache->get($file)) {
+ $respond = sendSimpleGetRequest($url);
+ $res = json_decode($respond, false);
+ $cms->cache->save($file, $res, 86400);
+ }
- return $res;
- }
+ return $res;
+ }
}
-if ( ! function_exists('bear_framework_show_gravatar')) {
- /**
- * Function bear_framework_show_gravatar
- *
- * @param $username
- * @param $size
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 20/01/2023 37:08
- */
- function bear_framework_show_gravatar($username = 'nguyenanhung', $size = 300)
- {
- return bear_framework_gravatar_init($username)->entry[0]->thumbnailUrl . '?' . http_build_query(
- array('size' => $size)
- );
- }
+if (!function_exists('bear_framework_show_gravatar')) {
+ /**
+ * Function bear_framework_show_gravatar
+ *
+ * @param $username
+ * @param $size
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 20/01/2023 37:08
+ */
+ function bear_framework_show_gravatar($username = 'nguyenanhung', $size = 300)
+ {
+ return bear_framework_gravatar_init($username)->entry[0]->thumbnailUrl . '?' . http_build_query(
+ array('size' => $size)
+ );
+ }
}
diff --git a/helpers/html_helper.php b/helpers/html_helper.php
index f23b82b..3e56479 100644
--- a/helpers/html_helper.php
+++ b/helpers/html_helper.php
@@ -8,168 +8,168 @@
* Date: 09/11/2021
* Time: 08:59
*/
-if ( ! function_exists('meta_dns_prefetch')) {
- /**
- * Function meta_dns_prefetch
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 31:33
- */
- function meta_dns_prefetch()
- {
- return "\n\n\n\n\n\n";
- }
+if (!function_exists('meta_dns_prefetch')) {
+ /**
+ * Function meta_dns_prefetch
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/10/2020 31:33
+ */
+ function meta_dns_prefetch()
+ {
+ return "\n\n\n\n\n\n";
+ }
}
-if ( ! function_exists('meta_property')) {
- /**
- * Function meta_property
- *
- * @param string|array $property
- * @param string $content
- * @param string $type
- * @param string $newline
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 31:45
- */
- function meta_property($property = '', $content = '', $type = 'property', $newline = "\n")
- {
- // Since we allow the data to be passes as a string, a simple array
- // or a multidimensional one, we need to do a little prepping.
- if ( ! is_array($property)) {
- $property = array(
- array(
- 'property' => $property,
- 'content' => $content,
- 'type' => $type,
- 'newline' => $newline
- )
- );
- } elseif (isset($property['property'])) {
- // Turn single array into multidimensional
- $property = array($property);
- }
- $str = '';
- foreach ($property as $meta) {
- $type = (isset($meta['type']) && $meta['type'] !== 'property') ? 'itemprop' : 'property';
- $property = isset($meta['property']) ? $meta['property'] : '';
- $content = isset($meta['content']) ? $meta['content'] : '';
- $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
- $str .= '' . $newline;
- }
+if (!function_exists('meta_property')) {
+ /**
+ * Function meta_property
+ *
+ * @param string|array $property
+ * @param string $content
+ * @param string $type
+ * @param string $newline
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/10/2020 31:45
+ */
+ function meta_property($property = '', $content = '', $type = 'property', $newline = "\n")
+ {
+ // Since we allow the data to be passes as a string, a simple array
+ // or a multidimensional one, we need to do a little prepping.
+ if (!is_array($property)) {
+ $property = array(
+ array(
+ 'property' => $property,
+ 'content' => $content,
+ 'type' => $type,
+ 'newline' => $newline
+ )
+ );
+ } elseif (isset($property['property'])) {
+ // Turn single array into multidimensional
+ $property = array($property);
+ }
+ $str = '';
+ foreach ($property as $meta) {
+ $type = (isset($meta['type']) && $meta['type'] !== 'property') ? 'itemprop' : 'property';
+ $property = isset($meta['property']) ? $meta['property'] : '';
+ $content = isset($meta['content']) ? $meta['content'] : '';
+ $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
+ $str .= '' . $newline;
+ }
- return $str;
- }
+ return $str;
+ }
}
-if ( ! function_exists('tachPage')) {
- /**
- * Function tachPage
- *
- * @param $input
- *
- * @return mixed
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 31:55
- */
- function tachPage($input)
- {
- if (empty($input)) {
- return $input;
- }
- preg_match('/(.*)-c(.*).html/U', $input, $output);
+if (!function_exists('tachPage')) {
+ /**
+ * Function tachPage
+ *
+ * @param $input
+ *
+ * @return mixed
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/10/2020 31:55
+ */
+ function tachPage($input)
+ {
+ if (empty($input)) {
+ return $input;
+ }
+ preg_match('/(.*)-c(.*).html/U', $input, $output);
- return $output[1];
- }
+ return $output[1];
+ }
}
-if ( ! function_exists('stripHtmlTag')) {
- /**
- * Function stripHtmlTag
- *
- * @param $str
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 32:06
- */
- function stripHtmlTag($str)
- {
- if (empty($str)) {
- return $str;
- }
- $regEx = '/([^<]*<\s*[a-z](?:[0-9]|[a-z]{0,9}))(?:(?:\s*[a-z\-]{2,14}\s*=\s*(?:"[^"]*"|\'[^\']*\'))*)(\s*\/?>[^<]*)/i';
- $chunks = preg_split($regEx, $str, -1, PREG_SPLIT_DELIM_CAPTURE);
- $chunkCount = count($chunks);
- $strippedString = '';
- for ($n = 1; $n < $chunkCount; $n++) {
- $strippedString .= $chunks[$n];
- }
+if (!function_exists('stripHtmlTag')) {
+ /**
+ * Function stripHtmlTag
+ *
+ * @param $str
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/10/2020 32:06
+ */
+ function stripHtmlTag($str)
+ {
+ if (empty($str)) {
+ return $str;
+ }
+ $regEx = '/([^<]*<\s*[a-z](?:[0-9]|[a-z]{0,9}))(?:(?:\s*[a-z\-]{2,14}\s*=\s*(?:"[^"]*"|\'[^\']*\'))*)(\s*\/?>[^<]*)/i';
+ $chunks = preg_split($regEx, $str, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $chunkCount = count($chunks);
+ $strippedString = '';
+ for ($n = 1; $n < $chunkCount; $n++) {
+ $strippedString .= $chunks[$n];
+ }
- return $strippedString;
- }
+ return $strippedString;
+ }
}
-if ( ! function_exists('strip_only_tags')) {
- /**
- * Function strip_only_tags
- *
- * @param $str
- * @param $tags
- * @param bool $stripContent
- *
- * @return string|string[]|null
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 32:14
- */
- function strip_only_tags($str, $tags, $stripContent = false)
- {
- if (empty($str)) {
- return $str;
- }
+if (!function_exists('strip_only_tags')) {
+ /**
+ * Function strip_only_tags
+ *
+ * @param $str
+ * @param $tags
+ * @param bool $stripContent
+ *
+ * @return string|string[]|null
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 12/10/2020 32:14
+ */
+ function strip_only_tags($str, $tags, $stripContent = false)
+ {
+ if (empty($str)) {
+ return $str;
+ }
- $content = '';
+ $content = '';
- if ( ! is_array($tags)) {
- $tags = (mb_strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
- if (end($tags) === '') {
- array_pop($tags);
- }
- }
+ if (!is_array($tags)) {
+ $tags = (mb_strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
+ if (end($tags) === '') {
+ array_pop($tags);
+ }
+ }
- foreach ($tags as $tag) {
- if ($stripContent) {
- $content = '(.+' . $tag . '(>|\s[^>]*>)|)';
- }
+ foreach ($tags as $tag) {
+ if ($stripContent) {
+ $content = '(.+' . $tag . '(>|\s[^>]*>)|)';
+ }
- $str = preg_replace('#?' . $tag . '(>|\s[^>]*>)' . $content . '#is', '', $str);
- }
+ $str = preg_replace('#?' . $tag . '(>|\s[^>]*>)' . $content . '#is', '', $str);
+ }
- return $str;
- }
+ return $str;
+ }
}
-if ( ! function_exists('tracking_google_analytics')) {
- /**
- * Function tracking_google_analytics
- *
- * @param string $analytics_id
- * @param string $analytics_mode
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 12/10/2020 32:22
- */
- function tracking_google_analytics($analytics_id = '', $analytics_mode = 'auto')
- {
- if (empty($analytics_id)) {
- return $analytics_id;
- }
- $html = "";
- return trim($html);
- }
+ return trim($html);
+ }
}
-if ( ! function_exists('tracking_google_gtag_analytics_default')) {
- /**
- * Function tracking_google_gtag_analytics_default
- *
- * @param string $ID
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 30/07/2022 15:59
- */
- function tracking_google_gtag_analytics_default($ID = '')
- {
- if (empty($ID)) {
- return $ID;
- }
- $html = "" . PHP_EOL;
- $html .= "" . PHP_EOL;
- $html .= "" . PHP_EOL;
+ $html .= "";
- return $html;
- }
+ return $html;
+ }
}
-if ( ! function_exists('html_tag')) {
- /**
- * Create a XHTML tag
- *
- * @param string $tag The tag name
- * @param array|string $attr The tag attributes
- * @param string|bool $content The content to place in the tag, or false for no closing tag
- *
- * @return string
- */
- function html_tag($tag, $attr = array(), $content = false)
- {
- // list of void elements (tags that can not have content)
- static $void_elements = array(
- // html4
- "area",
- "base",
- "br",
- "col",
- "hr",
- "img",
- "input",
- "link",
- "meta",
- "param",
- // html5
- "command",
- "embed",
- "keygen",
- "source",
- "track",
- "wbr",
- // html5.1
- "menuitem",
- );
+if (!function_exists('html_tag')) {
+ /**
+ * Create a XHTML tag
+ *
+ * @param string $tag The tag name
+ * @param array|string $attr The tag attributes
+ * @param string|bool $content The content to place in the tag, or false for no closing tag
+ *
+ * @return string
+ */
+ function html_tag($tag, $attr = array(), $content = false)
+ {
+ // list of void elements (tags that can not have content)
+ static $void_elements = array(
+ // html4
+ "area",
+ "base",
+ "br",
+ "col",
+ "hr",
+ "img",
+ "input",
+ "link",
+ "meta",
+ "param",
+ // html5
+ "command",
+ "embed",
+ "keygen",
+ "source",
+ "track",
+ "wbr",
+ // html5.1
+ "menuitem",
+ );
- // construct the HTML
- $html = '<' . $tag;
- $html .= ( ! empty($attr)) ? ' ' . (is_array($attr) ? arrayToAttributes($attr) : $attr) : '';
+ // construct the HTML
+ $html = '<' . $tag;
+ $html .= (!empty($attr)) ? ' ' . (is_array($attr) ? arrayToAttributes($attr) : $attr) : '';
- // a void element?
- if (in_array(mb_strtolower($tag), $void_elements)) {
- // these can not have content
- $html .= ' />';
- } else {
- // add the content and close the tag
- $html .= '>' . $content . '' . $tag . '>';
- }
+ // a void element?
+ if (in_array(mb_strtolower($tag), $void_elements)) {
+ // these can not have content
+ $html .= ' />';
+ } else {
+ // add the content and close the tag
+ $html .= '>' . $content . '' . $tag . '>';
+ }
- return $html;
- }
+ return $html;
+ }
}
-if ( ! function_exists('bear_framework_show_jsonld_script')) {
- function bear_framework_show_jsonld_script($content)
- {
- $content = trim($content);
- if (empty($content)) {
- return $content;
- }
- $start = '';
- return $start . PHP_EOL . $content . PHP_EOL . $end;
- }
+if (!function_exists('bear_framework_show_jsonld_script')) {
+ function bear_framework_show_jsonld_script($content)
+ {
+ $content = trim($content);
+ if (empty($content)) {
+ return $content;
+ }
+ $start = '';
+ return $start . PHP_EOL . $content . PHP_EOL . $end;
+ }
}
diff --git a/helpers/image_helper.php b/helpers/image_helper.php
index a57b2e3..edac71b 100644
--- a/helpers/image_helper.php
+++ b/helpers/image_helper.php
@@ -8,145 +8,145 @@
* Date: 08/07/2021
* Time: 01:07
*/
-if ( ! function_exists('google_image_resize')) {
- /**
- * Function google_image_resize
- *
- * @param string $url
- * @param int|null $width
- * @param int|null $height
- * @param string|null $server
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 07/27/2021 37:48
- */
- function google_image_resize($url = '', $width = 100, $height = null, $server = 'images1')
- {
- return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::googleGadgetsProxy($url, $width, $height, $server);
- }
+if (!function_exists('google_image_resize')) {
+ /**
+ * Function google_image_resize
+ *
+ * @param string $url
+ * @param int|null $width
+ * @param int|null $height
+ * @param string|null $server
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 07/27/2021 37:48
+ */
+ function google_image_resize($url = '', $width = 100, $height = null, $server = 'images1')
+ {
+ return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::googleGadgetsProxy($url, $width, $height, $server);
+ }
}
-if ( ! function_exists('google_image_proxy_dns_prefetch')) {
- /**
- * Function google_image_proxy_dns_prefetch
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/15/2021 36:03
- */
- function google_image_proxy_dns_prefetch()
- {
- return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::googleGadgetsProxyDnsPrefetch();
- }
+if (!function_exists('google_image_proxy_dns_prefetch')) {
+ /**
+ * Function google_image_proxy_dns_prefetch
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/15/2021 36:03
+ */
+ function google_image_proxy_dns_prefetch()
+ {
+ return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::googleGadgetsProxyDnsPrefetch();
+ }
}
-if ( ! function_exists('wordpress_proxy')) {
- /**
- * Function wordpress_proxy
- *
- * @param string $imageUrl
- * @param string $server
- * @param int|string|null $width
- * @param int|string|null $height
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 07/27/2021 38:04
- */
- function wordpress_proxy($imageUrl = '', $server = 'i3', $width = null, $height = null)
- {
- return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::wordpressProxy($imageUrl, $server, $width, $height);
- }
+if (!function_exists('wordpress_proxy')) {
+ /**
+ * Function wordpress_proxy
+ *
+ * @param string $imageUrl
+ * @param string $server
+ * @param int|string|null $width
+ * @param int|string|null $height
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 07/27/2021 38:04
+ */
+ function wordpress_proxy($imageUrl = '', $server = 'i3', $width = null, $height = null)
+ {
+ return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::wordpressProxy($imageUrl, $server, $width, $height);
+ }
}
-if ( ! function_exists('wordpress_proxy_dns_prefetch')) {
- /**
- * Function wordpress_proxy_dns_prefetch
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 09/15/2021 36:15
- */
- function wordpress_proxy_dns_prefetch()
- {
- return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::wordpressProxyDnsPrefetch();
- }
+if (!function_exists('wordpress_proxy_dns_prefetch')) {
+ /**
+ * Function wordpress_proxy_dns_prefetch
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 09/15/2021 36:15
+ */
+ function wordpress_proxy_dns_prefetch()
+ {
+ return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::wordpressProxyDnsPrefetch();
+ }
}
-if ( ! function_exists('bear_framework_image_url')) {
- /**
- * Function bear_framework_image_url
- *
- * @param $input
- * @param $server
- * @param $base
- *
- * @return string
- * @author : 713uk13m
- * @copyright: 713uk13m
- * @time : 15/06/2022 54:18
- */
- function bear_framework_image_url($input = '', $server = '', $base = 'live')
- {
- return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::formatImageUrl($input, $server, $base);
- }
+if (!function_exists('bear_framework_image_url')) {
+ /**
+ * Function bear_framework_image_url
+ *
+ * @param $input
+ * @param $server
+ * @param $base
+ *
+ * @return string
+ * @author : 713uk13m
+ * @copyright: 713uk13m
+ * @time : 15/06/2022 54:18
+ */
+ function bear_framework_image_url($input = '', $server = '', $base = 'live')
+ {
+ return nguyenanhung\CodeIgniter\BasicHelper\ImageHelper::formatImageUrl($input, $server, $base);
+ }
}
-if ( ! function_exists('bear_framework_create_image_thumbnail')) {
- /**
- * Function bear_framework_create_image_thumbnail
- *
- * @param $url
- * @param $width
- * @param $height
- *
- * @return string|null
- * @author : 713uk13m