Compare commits
1 Commits
main2
...
6ec5ab0c8d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ec5ab0c8d |
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Global API Headers Configuration
|
|
||||||
*/
|
|
||||||
|
|
||||||
$API_HEADERS = [
|
|
||||||
'Content-Type: application/json; charset=utf-8',
|
|
||||||
'Access-Control-Allow-Origin: *',
|
|
||||||
'Access-Control-Allow-Methods: GET, POST, OPTIONS',
|
|
||||||
'Access-Control-Allow-Headers: Content-Type, Authorization',
|
|
||||||
'X-Powered-By: SiliconPin Tools'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply headers helper
|
|
||||||
*/
|
|
||||||
function applyApiHeaders(array $headers)
|
|
||||||
{
|
|
||||||
foreach ($headers as $header) {
|
|
||||||
header($header);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
$BASE_URL = 'http://localhost:2050';
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 60 MiB |
@@ -1,261 +0,0 @@
|
|||||||
CHANGELOG
|
|
||||||
=========
|
|
||||||
|
|
||||||
1.13.1 (2025-11-21)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* First PIE release. No other changes.
|
|
||||||
|
|
||||||
1.13.0 (2025-11-20)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* A redundant `filesize()` call in the reader's constructor was removed.
|
|
||||||
Pull request by Pavel Djundik. GitHub #189.
|
|
||||||
|
|
||||||
1.12.1 (2025-05-05)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* The C extension now checks that the database metadata lookup was
|
|
||||||
successful.
|
|
||||||
|
|
||||||
1.12.0 (2024-11-14)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* Improve the error handling when the user tries to open a directory
|
|
||||||
with the pure PHP reader.
|
|
||||||
* Improve the typehints on arrays in the PHPDocs.
|
|
||||||
|
|
||||||
1.11.1 (2023-12-01)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* Resolve warnings when compiling the C extension.
|
|
||||||
* Fix various type issues detected by PHPStan level. Pull request by
|
|
||||||
LauraTaylorUK. GitHub #160.
|
|
||||||
|
|
||||||
1.11.0 (2021-10-18)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* Replace runtime define of a constant to facilitate opcache preloading.
|
|
||||||
Reported by vedadkajtaz. GitHub #134.
|
|
||||||
* Resolve minor issue found by the Clang static analyzer in the C
|
|
||||||
extension.
|
|
||||||
|
|
||||||
1.10.1 (2021-04-14)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* Fix a `TypeError` exception in the pure PHP reader when using large
|
|
||||||
databases on 32-bit PHP builds with the `bcmath` extension. Reported
|
|
||||||
by dodo1708. GitHub #124.
|
|
||||||
|
|
||||||
1.10.0 (2021-02-09)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* When using the pure PHP reader, unsigned integers up to PHP_MAX_INT
|
|
||||||
will now be integers in PHP rather than strings. Previously integers
|
|
||||||
greater than 2^24 on 32-bit platforms and 2^56 on 64-bit platforms
|
|
||||||
would be strings due to the use of `gmp` or `bcmath` to decode them.
|
|
||||||
Reported by Alejandro Celaya. GitHub #119.
|
|
||||||
|
|
||||||
1.9.0 (2021-01-07)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* The `maxminddb` extension is now buildable on Windows. Pull request
|
|
||||||
by Jan Ehrhardt. GitHub #115.
|
|
||||||
|
|
||||||
1.8.0 (2020-10-01)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Fixes for PHP 8.0. Pull Request by Remi Collet. GitHub #108.
|
|
||||||
|
|
||||||
1.7.0 (2020-08-07)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* IMPORTANT: PHP 7.2 or greater is now required.
|
|
||||||
* The extension no longer depends on the pure PHP classes in
|
|
||||||
`maxmind-db/reader`. You can use it independently.
|
|
||||||
* Type hints have been added to both the pure PHP implementation
|
|
||||||
and the extension.
|
|
||||||
* The `metadata` method on the reader now returns a new copy of the
|
|
||||||
metadata object rather than the actual object used by the reader.
|
|
||||||
* Work around PHP `is_readable()` bug. Reported by Ben Roberts. GitHub
|
|
||||||
#92.
|
|
||||||
* This is the first release of the extension as a PECL package.
|
|
||||||
GitHub #34.
|
|
||||||
|
|
||||||
1.6.0 (2019-12-19)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* 1.5.0 and 1.5.1 contained a possible memory corruptions when using
|
|
||||||
`getWithPrefixLen`. This has been fixed. Reported by proton-ab.
|
|
||||||
GitHub #96.
|
|
||||||
* The `composer.json` file now conflicts with all versions of the
|
|
||||||
`maxminddb` C extension less than the Composer version. This is to
|
|
||||||
reduce the chance of having an older, conflicting version of the
|
|
||||||
extension installed. You will need to upgrade the extension before
|
|
||||||
running `composer update`. Pull request by Benoît Burnichon. GitHub
|
|
||||||
#97.
|
|
||||||
|
|
||||||
1.5.1 (2019-12-12)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Minor performance improvements.
|
|
||||||
* Make tests pass with older versions of libmaxminddb. PR by Remi
|
|
||||||
Collet. GitHub #90.
|
|
||||||
* Test enhancements. PR by Chun-Sheng, Li. GitHub #91.
|
|
||||||
|
|
||||||
1.5.0 (2019-09-30)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* PHP 5.6 or greater is now required.
|
|
||||||
* The C extension now supports PHP 8. Pull request by John Boehr.
|
|
||||||
GitHub #87.
|
|
||||||
* A new method, `getWithPrefixLen`, was added to the `Reader` class.
|
|
||||||
This method returns an array containing the record and the prefix
|
|
||||||
length for that record. GitHub #89.
|
|
||||||
|
|
||||||
1.4.1 (2019-01-04)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* The `maxminddb` extension now returns a string when a `uint32`
|
|
||||||
value is greater than `LONG_MAX`. Previously, the value would
|
|
||||||
overflow. This generally only affects 32-bit machines. Reported
|
|
||||||
by Remi Collet. GitHub #79.
|
|
||||||
* For `uint64` values, the `maxminddb` extension now returns an
|
|
||||||
integer rather than a string when the value is less than or equal
|
|
||||||
to `LONG_MAX`. This more closely matches the behavior of the pure
|
|
||||||
PHP reader.
|
|
||||||
|
|
||||||
1.4.0 (2018-11-20)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* The `maxminddb` extension now has the arginfo when using reflection.
|
|
||||||
PR by Remi Collet. GitHub #75.
|
|
||||||
* The `maxminddb` extension now provides `MINFO()` function that
|
|
||||||
displays the extension version and the libmaxminddb version. PR by
|
|
||||||
Remi Collet. GitHub #74.
|
|
||||||
* The `maxminddb` `configure` script now uses `pkg-config` when
|
|
||||||
available to get libmaxmindb build info. PR by Remi Collet.
|
|
||||||
GitHub #73.
|
|
||||||
* The pure PHP reader now correctly decodes integers on 32-bit platforms.
|
|
||||||
Previously, large integers would overflow. Reported by Remi Collet.
|
|
||||||
GitHub #77.
|
|
||||||
* There are small performance improvements for the pure PHP reader.
|
|
||||||
|
|
||||||
1.3.0 (2018-02-21)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* IMPORTANT: The `maxminddb` extension now obeys `open_basedir`. If
|
|
||||||
`open_basedir` is set, you _must_ store the database within the
|
|
||||||
specified directory. Placing the file outside of this directory
|
|
||||||
will result in an exception. Please test your integration before
|
|
||||||
upgrading the extension. This does not affect the pure PHP
|
|
||||||
implementation, which has always had this restriction. Reported
|
|
||||||
by Benoît Burnichon. GitHub #61.
|
|
||||||
* A custom `autoload.php` file is provided for installations without
|
|
||||||
Composer. GitHub #56.
|
|
||||||
|
|
||||||
1.2.0 (2017-10-27)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* PHP 5.4 or greater is now required.
|
|
||||||
* The `Reader` class for the `maxminddb` extension is no longer final.
|
|
||||||
This was change to match the behavior of the pure PHP class.
|
|
||||||
Reported and fixed by venyii. GitHub #52 & #54.
|
|
||||||
|
|
||||||
1.1.3 (2017-01-19)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Fix incorrect version in `ext/php_maxminddb.h`. GitHub #48.
|
|
||||||
|
|
||||||
1.1.2 (2016-11-22)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Searching for database metadata only occurs within the last 128KB
|
|
||||||
(128 * 1024 bytes) of the file, speeding detection of corrupt
|
|
||||||
datafiles. Reported by Eric Teubert. GitHub #42.
|
|
||||||
* Suggest relevant extensions when installing with Composer. GitHub #37.
|
|
||||||
|
|
||||||
1.1.1 (2016-09-15)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Development files were added to the `.gitattributes` as `export-ignore` so
|
|
||||||
that they are not part of the Composer release. Pull request by Michele
|
|
||||||
Locati. GitHub #39.
|
|
||||||
|
|
||||||
1.1.0 (2016-01-04)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* The MaxMind DB extension now supports PHP 7. Pull request by John Boehr.
|
|
||||||
GitHub #27.
|
|
||||||
|
|
||||||
1.0.3 (2015-03-13)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* All uses of `strlen` were removed. This should prevent issues in situations
|
|
||||||
where the function is overloaded or otherwise broken.
|
|
||||||
|
|
||||||
1.0.2 (2015-01-19)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Previously the MaxMind DB extension would cause a segfault if the Reader
|
|
||||||
object's destructor was called without first having called the constructor.
|
|
||||||
(Reported by Matthias Saou & Juan Peri. GitHub #20.)
|
|
||||||
|
|
||||||
1.0.1 (2015-01-12)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* In the last several releases, the version number in the extension was
|
|
||||||
incorrect. This release is being done to correct it. No other code changes
|
|
||||||
are included.
|
|
||||||
|
|
||||||
1.0.0 (2014-09-22)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* First production release.
|
|
||||||
* In the pure PHP reader, a string length test after `fread()` was replaced
|
|
||||||
with the difference between the start pointer and the end pointer. This
|
|
||||||
provided a 15% speed increase.
|
|
||||||
|
|
||||||
0.3.3 (2014-09-15)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Clarified behavior of 128-bit type in documentation.
|
|
||||||
* Updated phpunit and fixed some test breakage from the newer version.
|
|
||||||
|
|
||||||
0.3.2 (2014-09-10)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Fixed invalid reference to global class RuntimeException from namespaced
|
|
||||||
code. Fixed by Steven Don. GitHub issue #15.
|
|
||||||
* Additional documentation of `Metadata` class as well as misc. documentation
|
|
||||||
cleanup.
|
|
||||||
|
|
||||||
0.3.1 (2014-05-01)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* The API now works when `mbstring.func_overload` is set.
|
|
||||||
* BCMath is no longer required. If the decoder encounters a big integer,
|
|
||||||
it will try to use GMP and then BCMath. If both of those fail, it will
|
|
||||||
throw an exception. No databases released by MaxMind currently use big
|
|
||||||
integers.
|
|
||||||
* The API now officially supports HHVM when using the pure PHP reader.
|
|
||||||
|
|
||||||
0.3.0 (2014-02-19)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* This API is now licensed under the Apache License, Version 2.0.
|
|
||||||
* The code for the C extension was cleaned up, fixing several potential
|
|
||||||
issues.
|
|
||||||
|
|
||||||
0.2.0 (2013-10-21)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Added optional C extension for using libmaxminddb in place of the pure PHP
|
|
||||||
reader.
|
|
||||||
* Significantly improved error handling in pure PHP reader.
|
|
||||||
* Improved performance for IPv4 lookups in an IPv6 database.
|
|
||||||
|
|
||||||
0.1.0 (2013-07-16)
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* Initial release
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
# MaxMind DB Reader PHP API #
|
|
||||||
|
|
||||||
## Description ##
|
|
||||||
|
|
||||||
This is the PHP API for reading MaxMind DB files. MaxMind DB is a binary file
|
|
||||||
format that stores data indexed by IP address subnets (IPv4 or IPv6).
|
|
||||||
|
|
||||||
## Installation ##
|
|
||||||
|
|
||||||
### C Extension (Recommended for Performance) ###
|
|
||||||
|
|
||||||
For significantly faster IP lookups, we recommend installing the C extension via
|
|
||||||
[PIE](https://github.com/php/pie):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pie install maxmind-db/reader-ext
|
|
||||||
```
|
|
||||||
|
|
||||||
The C extension requires the [libmaxminddb](https://github.com/maxmind/libmaxminddb)
|
|
||||||
C library. See the [installation instructions](https://github.com/maxmind/MaxMind-DB-Reader-php-ext#prerequisites)
|
|
||||||
for your platform.
|
|
||||||
|
|
||||||
### Pure PHP (No Compilation Required) ###
|
|
||||||
|
|
||||||
If you prefer not to compile a C extension or need maximum portability, you can
|
|
||||||
install the pure PHP implementation with [Composer](https://getcomposer.org/).
|
|
||||||
|
|
||||||
### Download Composer ###
|
|
||||||
|
|
||||||
To download Composer, run in the root directory of your project:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -sS https://getcomposer.org/installer | php
|
|
||||||
```
|
|
||||||
|
|
||||||
You should now have the file `composer.phar` in your project directory.
|
|
||||||
|
|
||||||
### Install Dependencies ###
|
|
||||||
|
|
||||||
Run in your project root:
|
|
||||||
|
|
||||||
```
|
|
||||||
php composer.phar require maxmind-db/reader:^1.13.1
|
|
||||||
```
|
|
||||||
|
|
||||||
You should now have the files `composer.json` and `composer.lock` as well as
|
|
||||||
the directory `vendor` in your project directory. If you use a version control
|
|
||||||
system, `composer.json` should be added to it.
|
|
||||||
|
|
||||||
### Require Autoloader ###
|
|
||||||
|
|
||||||
After installing the dependencies, you need to require the Composer autoloader
|
|
||||||
from your code:
|
|
||||||
|
|
||||||
```php
|
|
||||||
require 'vendor/autoload.php';
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation (Standalone) ##
|
|
||||||
|
|
||||||
If you don't want to use Composer for some reason, a custom
|
|
||||||
`autoload.php` is provided for you in the project root. To use the
|
|
||||||
library, simply include that file,
|
|
||||||
|
|
||||||
```php
|
|
||||||
require('/path/to/MaxMind-DB-Reader-php/autoload.php');
|
|
||||||
```
|
|
||||||
|
|
||||||
and then instantiate the reader class normally:
|
|
||||||
|
|
||||||
```php
|
|
||||||
use MaxMind\Db\Reader;
|
|
||||||
$reader = new Reader('example.mmdb');
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation (RPM)
|
|
||||||
|
|
||||||
RPMs are available in the [official Fedora repository](https://apps.fedoraproject.org/packages/php-maxminddb).
|
|
||||||
|
|
||||||
To install on Fedora, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
dnf install php-maxminddb
|
|
||||||
```
|
|
||||||
|
|
||||||
To install on CentOS or RHEL 7, first [enable the EPEL repository](https://fedoraproject.org/wiki/EPEL)
|
|
||||||
and then run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yum install php-maxminddb
|
|
||||||
```
|
|
||||||
|
|
||||||
Please note that these packages are *not* maintained by MaxMind.
|
|
||||||
|
|
||||||
## Usage ##
|
|
||||||
|
|
||||||
## Example ##
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
require_once 'vendor/autoload.php';
|
|
||||||
|
|
||||||
use MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
$ipAddress = '24.24.24.24';
|
|
||||||
$databaseFile = 'GeoIP2-City.mmdb';
|
|
||||||
|
|
||||||
$reader = new Reader($databaseFile);
|
|
||||||
|
|
||||||
// get returns just the record for the IP address
|
|
||||||
print_r($reader->get($ipAddress));
|
|
||||||
|
|
||||||
// getWithPrefixLen returns an array containing the record and the
|
|
||||||
// associated prefix length for that record.
|
|
||||||
print_r($reader->getWithPrefixLen($ipAddress));
|
|
||||||
|
|
||||||
$reader->close();
|
|
||||||
```
|
|
||||||
|
|
||||||
## Optional PHP C Extension ##
|
|
||||||
|
|
||||||
MaxMind provides an optional C extension that is a drop-in replacement for
|
|
||||||
`MaxMind\Db\Reader`. In order to use this extension, you must install the
|
|
||||||
Reader API as described above and install the extension as described below. If
|
|
||||||
you are using an autoloader, no changes to your code should be necessary.
|
|
||||||
|
|
||||||
### Installing Extension via PIE (Recommended) ###
|
|
||||||
|
|
||||||
We recommend installing the extension via [PIE](https://github.com/php/pie):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pie install maxmind-db/reader-ext
|
|
||||||
```
|
|
||||||
|
|
||||||
See the [extension repository](https://github.com/maxmind/MaxMind-DB-Reader-php-ext#prerequisites)
|
|
||||||
for prerequisites including libmaxminddb installation instructions.
|
|
||||||
|
|
||||||
### Installing Extension via PECL (Legacy) ###
|
|
||||||
|
|
||||||
First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as
|
|
||||||
described in its [README.md
|
|
||||||
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#installing-from-a-tarball).
|
|
||||||
After successfully installing libmaxmindb, you may install the extension
|
|
||||||
from [PECL](https://pecl.php.net/package/maxminddb):
|
|
||||||
|
|
||||||
```
|
|
||||||
pecl install maxminddb
|
|
||||||
```
|
|
||||||
|
|
||||||
### Installing Extension from Source ###
|
|
||||||
|
|
||||||
Alternatively, you may install it from the source. To do so, run the following
|
|
||||||
commands from the top-level directory of this distribution:
|
|
||||||
|
|
||||||
```
|
|
||||||
cd ext
|
|
||||||
phpize
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
make test
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
You then must load your extension. The recommended method is to add the
|
|
||||||
following to your `php.ini` file:
|
|
||||||
|
|
||||||
```
|
|
||||||
extension=maxminddb.so
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: You may need to install the PHP development package on your OS such as
|
|
||||||
php5-dev for Debian-based systems or php-devel for RedHat/Fedora-based ones.
|
|
||||||
|
|
||||||
## 128-bit Integer Support ##
|
|
||||||
|
|
||||||
The MaxMind DB format includes 128-bit unsigned integer as a type. Although
|
|
||||||
no MaxMind-distributed database currently makes use of this type, both the
|
|
||||||
pure PHP reader and the C extension support this type. The pure PHP reader
|
|
||||||
requires gmp or bcmath to read databases with 128-bit unsigned integers.
|
|
||||||
|
|
||||||
The integer is currently returned as a hexadecimal string (prefixed with "0x")
|
|
||||||
by the C extension and a decimal string (no prefix) by the pure PHP reader.
|
|
||||||
Any change to make the reader implementations always return either a
|
|
||||||
hexadecimal or decimal representation of the integer will NOT be considered a
|
|
||||||
breaking change.
|
|
||||||
|
|
||||||
## Support ##
|
|
||||||
|
|
||||||
Please report all issues with this code using the [GitHub issue tracker](https://github.com/maxmind/MaxMind-DB-Reader-php/issues).
|
|
||||||
|
|
||||||
If you are having an issue with a MaxMind service that is not specific to the
|
|
||||||
client API, please see [our support page](https://www.maxmind.com/en/support).
|
|
||||||
|
|
||||||
## Requirements ##
|
|
||||||
|
|
||||||
This library requires PHP 7.2 or greater.
|
|
||||||
|
|
||||||
The GMP or BCMath extension may be required to read some databases
|
|
||||||
using the pure PHP API.
|
|
||||||
|
|
||||||
## Contributing ##
|
|
||||||
|
|
||||||
Patches and pull requests are encouraged. All code should follow the PSR-1 and
|
|
||||||
PSR-2 style guidelines. Please include unit tests whenever possible.
|
|
||||||
|
|
||||||
## Versioning ##
|
|
||||||
|
|
||||||
The MaxMind DB Reader PHP API uses [Semantic Versioning](https://semver.org/).
|
|
||||||
|
|
||||||
## Copyright and License ##
|
|
||||||
|
|
||||||
This software is Copyright (c) 2014-2025 by MaxMind, Inc.
|
|
||||||
|
|
||||||
This is free software, licensed under the Apache License, Version 2.0.
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PSR-4 autoloader implementation for the MaxMind\DB namespace.
|
|
||||||
* First we define the 'mmdb_autoload' function, and then we register
|
|
||||||
* it with 'spl_autoload_register' so that PHP knows to use it.
|
|
||||||
*
|
|
||||||
* @param mixed $class
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically include the file that defines <code>class</code>.
|
|
||||||
*
|
|
||||||
* @param string $class
|
|
||||||
* the name of the class to load
|
|
||||||
*/
|
|
||||||
function mmdb_autoload($class): void
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* A project-specific mapping between the namespaces and where
|
|
||||||
* they're located. By convention, we include the trailing
|
|
||||||
* slashes. The one-element array here simply makes things easy
|
|
||||||
* to extend in the future if (for example) the test classes
|
|
||||||
* begin to use one another.
|
|
||||||
*/
|
|
||||||
$namespace_map = ['MaxMind\Db\\' => __DIR__ . '/src/MaxMind/Db/'];
|
|
||||||
|
|
||||||
foreach ($namespace_map as $prefix => $dir) {
|
|
||||||
// First swap out the namespace prefix with a directory...
|
|
||||||
$path = str_replace($prefix, $dir, $class);
|
|
||||||
|
|
||||||
// replace the namespace separator with a directory separator...
|
|
||||||
$path = str_replace('\\', '/', $path);
|
|
||||||
|
|
||||||
// and finally, add the PHP file extension to the result.
|
|
||||||
$path .= '.php';
|
|
||||||
|
|
||||||
// $path should now contain the path to a PHP file defining $class
|
|
||||||
if (file_exists($path)) {
|
|
||||||
include $path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spl_autoload_register('mmdb_autoload');
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "maxmind-db/reader",
|
|
||||||
"description": "MaxMind DB Reader API",
|
|
||||||
"keywords": ["database", "geoip", "geoip2", "geolocation", "maxmind"],
|
|
||||||
"homepage": "https://github.com/maxmind/MaxMind-DB-Reader-php",
|
|
||||||
"type": "library",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gregory J. Oschwald",
|
|
||||||
"email": "goschwald@maxmind.com",
|
|
||||||
"homepage": "https://www.maxmind.com/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-bcmath": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
|
|
||||||
"ext-gmp": "bcmath or gmp is required for decoding larger integers with the pure PHP decoder",
|
|
||||||
"ext-maxminddb": "A C-based database decoder that provides significantly faster lookups",
|
|
||||||
"maxmind-db/reader-ext": "C extension for significantly faster IP lookups (install via PIE: pie install maxmind-db/reader-ext)"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"ext-maxminddb": "<1.11.1 || >=2.0.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"friendsofphp/php-cs-fixer": "3.*",
|
|
||||||
"phpunit/phpunit": ">=8.0.0,<10.0.0",
|
|
||||||
"squizlabs/php_codesniffer": "4.*",
|
|
||||||
"phpstan/phpstan": "*"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"MaxMind\\Db\\": "src/MaxMind/Db"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"MaxMind\\Db\\Test\\Reader\\": "tests/MaxMind/Db/Test/Reader"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
PHP_ARG_WITH(maxminddb,
|
|
||||||
[Whether to enable the MaxMind DB Reader extension],
|
|
||||||
[ --with-maxminddb Enable MaxMind DB Reader extension support])
|
|
||||||
|
|
||||||
PHP_ARG_ENABLE(maxminddb-debug, for MaxMind DB debug support,
|
|
||||||
[ --enable-maxminddb-debug Enable MaxMind DB debug support], no, no)
|
|
||||||
|
|
||||||
if test $PHP_MAXMINDDB != "no"; then
|
|
||||||
|
|
||||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(for libmaxminddb)
|
|
||||||
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmaxminddb; then
|
|
||||||
dnl retrieve build options from pkg-config
|
|
||||||
if $PKG_CONFIG libmaxminddb --atleast-version 1.0.0; then
|
|
||||||
LIBMAXMINDDB_INC=`$PKG_CONFIG libmaxminddb --cflags`
|
|
||||||
LIBMAXMINDDB_LIB=`$PKG_CONFIG libmaxminddb --libs`
|
|
||||||
LIBMAXMINDDB_VER=`$PKG_CONFIG libmaxminddb --modversion`
|
|
||||||
AC_MSG_RESULT(found version $LIBMAXMINDDB_VER)
|
|
||||||
else
|
|
||||||
AC_MSG_ERROR(system libmaxminddb must be upgraded to version >= 1.0.0)
|
|
||||||
fi
|
|
||||||
PHP_EVAL_LIBLINE($LIBMAXMINDDB_LIB, MAXMINDDB_SHARED_LIBADD)
|
|
||||||
PHP_EVAL_INCLINE($LIBMAXMINDDB_INC)
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(pkg-config information missing)
|
|
||||||
AC_MSG_WARN(will use libmaxmxinddb from compiler default path)
|
|
||||||
|
|
||||||
PHP_CHECK_LIBRARY(maxminddb, MMDB_open)
|
|
||||||
PHP_ADD_LIBRARY(maxminddb, 1, MAXMINDDB_SHARED_LIBADD)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $PHP_MAXMINDDB_DEBUG != "no"; then
|
|
||||||
CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror"
|
|
||||||
fi
|
|
||||||
|
|
||||||
PHP_SUBST(MAXMINDDB_SHARED_LIBADD)
|
|
||||||
|
|
||||||
PHP_NEW_EXTENSION(maxminddb, maxminddb.c, $ext_shared)
|
|
||||||
fi
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
ARG_WITH("maxminddb", "Enable MaxMind DB Reader extension support", "no");
|
|
||||||
|
|
||||||
if (PHP_MAXMINDDB == "yes") {
|
|
||||||
if (CHECK_HEADER_ADD_INCLUDE("maxminddb.h", "CFLAGS_MAXMINDDB", PHP_MAXMINDDB + ";" + PHP_PHP_BUILD + "\\include\\maxminddb") &&
|
|
||||||
CHECK_LIB("libmaxminddb.lib", "maxminddb", PHP_MAXMINDDB)) {
|
|
||||||
EXTENSION("maxminddb", "maxminddb.c");
|
|
||||||
} else {
|
|
||||||
WARNING('Could not find maxminddb.h or libmaxminddb.lib; skipping');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,819 +0,0 @@
|
|||||||
/* MaxMind, Inc., licenses this file to you under the Apache License, Version
|
|
||||||
* 2.0 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "php_maxminddb.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <php.h>
|
|
||||||
#include <zend.h>
|
|
||||||
|
|
||||||
#include "Zend/zend_exceptions.h"
|
|
||||||
#include "Zend/zend_types.h"
|
|
||||||
#include "ext/spl/spl_exceptions.h"
|
|
||||||
#include "ext/standard/info.h"
|
|
||||||
#include <maxminddb.h>
|
|
||||||
|
|
||||||
#ifdef ZTS
|
|
||||||
#include <TSRM.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define __STDC_FORMAT_MACROS
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#define PHP_MAXMINDDB_NS ZEND_NS_NAME("MaxMind", "Db")
|
|
||||||
#define PHP_MAXMINDDB_READER_NS ZEND_NS_NAME(PHP_MAXMINDDB_NS, "Reader")
|
|
||||||
#define PHP_MAXMINDDB_METADATA_NS \
|
|
||||||
ZEND_NS_NAME(PHP_MAXMINDDB_READER_NS, "Metadata")
|
|
||||||
#define PHP_MAXMINDDB_READER_EX_NS \
|
|
||||||
ZEND_NS_NAME(PHP_MAXMINDDB_READER_NS, "InvalidDatabaseException")
|
|
||||||
|
|
||||||
#define Z_MAXMINDDB_P(zv) php_maxminddb_fetch_object(Z_OBJ_P(zv))
|
|
||||||
typedef size_t strsize_t;
|
|
||||||
typedef zend_object free_obj_t;
|
|
||||||
|
|
||||||
/* For PHP 8 compatibility */
|
|
||||||
#if PHP_VERSION_ID < 80000
|
|
||||||
|
|
||||||
#define PROP_OBJ(zv) (zv)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define PROP_OBJ(zv) Z_OBJ_P(zv)
|
|
||||||
|
|
||||||
#define TSRMLS_C
|
|
||||||
#define TSRMLS_CC
|
|
||||||
#define TSRMLS_DC
|
|
||||||
|
|
||||||
/* End PHP 8 compatibility */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ZEND_ACC_CTOR
|
|
||||||
#define ZEND_ACC_CTOR 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* IS_MIXED was added in 2020 */
|
|
||||||
#ifndef IS_MIXED
|
|
||||||
#define IS_MIXED IS_UNDEF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ZEND_THIS was added in 7.4 */
|
|
||||||
#ifndef ZEND_THIS
|
|
||||||
#define ZEND_THIS (&EX(This))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _maxminddb_obj {
|
|
||||||
MMDB_s *mmdb;
|
|
||||||
zend_object std;
|
|
||||||
} maxminddb_obj;
|
|
||||||
|
|
||||||
PHP_FUNCTION(maxminddb);
|
|
||||||
|
|
||||||
static int
|
|
||||||
get_record(INTERNAL_FUNCTION_PARAMETERS, zval *record, int *prefix_len);
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_entry_data_list(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_array(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_map(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
static void handle_uint128(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
static void handle_uint64(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
static void handle_uint32(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC);
|
|
||||||
|
|
||||||
#define CHECK_ALLOCATED(val) \
|
|
||||||
if (!val) { \
|
|
||||||
zend_error(E_ERROR, "Out of memory"); \
|
|
||||||
return; \
|
|
||||||
}
|
|
||||||
|
|
||||||
static zend_object_handlers maxminddb_obj_handlers;
|
|
||||||
static zend_class_entry *maxminddb_ce, *maxminddb_exception_ce, *metadata_ce;
|
|
||||||
|
|
||||||
static inline maxminddb_obj *
|
|
||||||
php_maxminddb_fetch_object(zend_object *obj TSRMLS_DC) {
|
|
||||||
return (maxminddb_obj *)((char *)(obj)-XtOffsetOf(maxminddb_obj, std));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_maxminddbreader_construct, 0, 0, 1)
|
|
||||||
ZEND_ARG_TYPE_INFO(0, db_file, IS_STRING, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader, __construct) {
|
|
||||||
char *db_file = NULL;
|
|
||||||
strsize_t name_len;
|
|
||||||
zval *_this_zval = NULL;
|
|
||||||
|
|
||||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
|
||||||
getThis(),
|
|
||||||
"Os",
|
|
||||||
&_this_zval,
|
|
||||||
maxminddb_ce,
|
|
||||||
&db_file,
|
|
||||||
&name_len) == FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != php_check_open_basedir(db_file TSRMLS_CC) ||
|
|
||||||
0 != access(db_file, R_OK)) {
|
|
||||||
zend_throw_exception_ex(
|
|
||||||
spl_ce_InvalidArgumentException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"The file \"%s\" does not exist or is not readable.",
|
|
||||||
db_file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MMDB_s *mmdb = (MMDB_s *)ecalloc(1, sizeof(MMDB_s));
|
|
||||||
int const status = MMDB_open(db_file, MMDB_MODE_MMAP, mmdb);
|
|
||||||
|
|
||||||
if (MMDB_SUCCESS != status) {
|
|
||||||
zend_throw_exception_ex(
|
|
||||||
maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Error opening database file (%s). Is this a valid "
|
|
||||||
"MaxMind DB file?",
|
|
||||||
db_file);
|
|
||||||
efree(mmdb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
maxminddb_obj *mmdb_obj = Z_MAXMINDDB_P(ZEND_THIS);
|
|
||||||
mmdb_obj->mmdb = mmdb;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
|
|
||||||
arginfo_maxminddbreader_get, 0, 1, IS_MIXED, 1)
|
|
||||||
ZEND_ARG_TYPE_INFO(0, ip_address, IS_STRING, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader, get) {
|
|
||||||
int prefix_len = 0;
|
|
||||||
get_record(INTERNAL_FUNCTION_PARAM_PASSTHRU, return_value, &prefix_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
|
|
||||||
arginfo_maxminddbreader_getWithPrefixLen, 0, 1, IS_ARRAY, 1)
|
|
||||||
ZEND_ARG_TYPE_INFO(0, ip_address, IS_STRING, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader, getWithPrefixLen) {
|
|
||||||
zval record, z_prefix_len;
|
|
||||||
|
|
||||||
int prefix_len = 0;
|
|
||||||
if (get_record(INTERNAL_FUNCTION_PARAM_PASSTHRU, &record, &prefix_len) ==
|
|
||||||
FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
array_init(return_value);
|
|
||||||
add_next_index_zval(return_value, &record);
|
|
||||||
|
|
||||||
ZVAL_LONG(&z_prefix_len, prefix_len);
|
|
||||||
add_next_index_zval(return_value, &z_prefix_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
get_record(INTERNAL_FUNCTION_PARAMETERS, zval *record, int *prefix_len) {
|
|
||||||
char *ip_address = NULL;
|
|
||||||
strsize_t name_len;
|
|
||||||
zval *this_zval = NULL;
|
|
||||||
|
|
||||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
|
||||||
getThis(),
|
|
||||||
"Os",
|
|
||||||
&this_zval,
|
|
||||||
maxminddb_ce,
|
|
||||||
&ip_address,
|
|
||||||
&name_len) == FAILURE) {
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(ZEND_THIS);
|
|
||||||
|
|
||||||
MMDB_s *mmdb = mmdb_obj->mmdb;
|
|
||||||
|
|
||||||
if (NULL == mmdb) {
|
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Attempt to read from a closed MaxMind DB.");
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct addrinfo hints = {
|
|
||||||
.ai_family = AF_UNSPEC,
|
|
||||||
.ai_flags = AI_NUMERICHOST,
|
|
||||||
/* We set ai_socktype so that we only get one result back */
|
|
||||||
.ai_socktype = SOCK_STREAM};
|
|
||||||
|
|
||||||
struct addrinfo *addresses = NULL;
|
|
||||||
int gai_status = getaddrinfo(ip_address, NULL, &hints, &addresses);
|
|
||||||
if (gai_status) {
|
|
||||||
zend_throw_exception_ex(spl_ce_InvalidArgumentException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"The value \"%s\" is not a valid IP address.",
|
|
||||||
ip_address);
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
if (!addresses || !addresses->ai_addr) {
|
|
||||||
zend_throw_exception_ex(
|
|
||||||
spl_ce_InvalidArgumentException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"getaddrinfo was successful but failed to set the addrinfo");
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sa_family = addresses->ai_addr->sa_family;
|
|
||||||
|
|
||||||
int mmdb_error = MMDB_SUCCESS;
|
|
||||||
MMDB_lookup_result_s result =
|
|
||||||
MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error);
|
|
||||||
|
|
||||||
freeaddrinfo(addresses);
|
|
||||||
|
|
||||||
if (MMDB_SUCCESS != mmdb_error) {
|
|
||||||
zend_class_entry *ex;
|
|
||||||
if (MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR == mmdb_error) {
|
|
||||||
ex = spl_ce_InvalidArgumentException;
|
|
||||||
} else {
|
|
||||||
ex = maxminddb_exception_ce;
|
|
||||||
}
|
|
||||||
zend_throw_exception_ex(ex,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Error looking up %s. %s",
|
|
||||||
ip_address,
|
|
||||||
MMDB_strerror(mmdb_error));
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*prefix_len = result.netmask;
|
|
||||||
|
|
||||||
if (sa_family == AF_INET && mmdb->metadata.ip_version == 6) {
|
|
||||||
/* We return the prefix length given the IPv4 address. If there is
|
|
||||||
no IPv4 subtree, we return a prefix length of 0. */
|
|
||||||
*prefix_len = *prefix_len >= 96 ? *prefix_len - 96 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.found_entry) {
|
|
||||||
ZVAL_NULL(record);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
MMDB_entry_data_list_s *entry_data_list = NULL;
|
|
||||||
int status = MMDB_get_entry_data_list(&result.entry, &entry_data_list);
|
|
||||||
|
|
||||||
if (MMDB_SUCCESS != status) {
|
|
||||||
zend_throw_exception_ex(maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Error while looking up data for %s. %s",
|
|
||||||
ip_address,
|
|
||||||
MMDB_strerror(status));
|
|
||||||
MMDB_free_entry_data_list(entry_data_list);
|
|
||||||
return FAILURE;
|
|
||||||
} else if (NULL == entry_data_list) {
|
|
||||||
zend_throw_exception_ex(
|
|
||||||
maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Error while looking up data for %s. Your database may "
|
|
||||||
"be corrupt or you have found a bug in libmaxminddb.",
|
|
||||||
ip_address);
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MMDB_entry_data_list_s *rv =
|
|
||||||
handle_entry_data_list(entry_data_list, record TSRMLS_CC);
|
|
||||||
if (rv == NULL) {
|
|
||||||
/* We should have already thrown the exception in handle_entry_data_list
|
|
||||||
*/
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
MMDB_free_entry_data_list(entry_data_list);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_maxminddbreader_void, 0, 0, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader, metadata) {
|
|
||||||
zval *this_zval = NULL;
|
|
||||||
|
|
||||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
|
||||||
getThis(),
|
|
||||||
"O",
|
|
||||||
&this_zval,
|
|
||||||
maxminddb_ce) == FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const maxminddb_obj *const mmdb_obj =
|
|
||||||
(maxminddb_obj *)Z_MAXMINDDB_P(this_zval);
|
|
||||||
|
|
||||||
if (NULL == mmdb_obj->mmdb) {
|
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Attempt to read from a closed MaxMind DB.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
object_init_ex(return_value, metadata_ce);
|
|
||||||
|
|
||||||
MMDB_entry_data_list_s *entry_data_list;
|
|
||||||
int status =
|
|
||||||
MMDB_get_metadata_as_entry_data_list(mmdb_obj->mmdb, &entry_data_list);
|
|
||||||
if (status != MMDB_SUCCESS) {
|
|
||||||
zend_throw_exception_ex(maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Error while decoding metadata. %s",
|
|
||||||
MMDB_strerror(status));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zval metadata_array;
|
|
||||||
const MMDB_entry_data_list_s *rv =
|
|
||||||
handle_entry_data_list(entry_data_list, &metadata_array TSRMLS_CC);
|
|
||||||
if (rv == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MMDB_free_entry_data_list(entry_data_list);
|
|
||||||
zend_call_method_with_1_params(PROP_OBJ(return_value),
|
|
||||||
metadata_ce,
|
|
||||||
&metadata_ce->constructor,
|
|
||||||
ZEND_CONSTRUCTOR_FUNC_NAME,
|
|
||||||
NULL,
|
|
||||||
&metadata_array);
|
|
||||||
zval_ptr_dtor(&metadata_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader, close) {
|
|
||||||
zval *this_zval = NULL;
|
|
||||||
|
|
||||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
|
||||||
getThis(),
|
|
||||||
"O",
|
|
||||||
&this_zval,
|
|
||||||
maxminddb_ce) == FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(this_zval);
|
|
||||||
|
|
||||||
if (NULL == mmdb_obj->mmdb) {
|
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Attempt to close a closed MaxMind DB.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MMDB_close(mmdb_obj->mmdb);
|
|
||||||
efree(mmdb_obj->mmdb);
|
|
||||||
mmdb_obj->mmdb = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_entry_data_list(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
switch (entry_data_list->entry_data.type) {
|
|
||||||
case MMDB_DATA_TYPE_MAP:
|
|
||||||
return handle_map(entry_data_list, z_value TSRMLS_CC);
|
|
||||||
case MMDB_DATA_TYPE_ARRAY:
|
|
||||||
return handle_array(entry_data_list, z_value TSRMLS_CC);
|
|
||||||
case MMDB_DATA_TYPE_UTF8_STRING:
|
|
||||||
ZVAL_STRINGL(z_value,
|
|
||||||
entry_data_list->entry_data.utf8_string,
|
|
||||||
entry_data_list->entry_data.data_size);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_BYTES:
|
|
||||||
ZVAL_STRINGL(z_value,
|
|
||||||
(char const *)entry_data_list->entry_data.bytes,
|
|
||||||
entry_data_list->entry_data.data_size);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_DOUBLE:
|
|
||||||
ZVAL_DOUBLE(z_value, entry_data_list->entry_data.double_value);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_FLOAT:
|
|
||||||
ZVAL_DOUBLE(z_value, entry_data_list->entry_data.float_value);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_UINT16:
|
|
||||||
ZVAL_LONG(z_value, entry_data_list->entry_data.uint16);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_UINT32:
|
|
||||||
handle_uint32(entry_data_list, z_value TSRMLS_CC);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_BOOLEAN:
|
|
||||||
ZVAL_BOOL(z_value, entry_data_list->entry_data.boolean);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_UINT64:
|
|
||||||
handle_uint64(entry_data_list, z_value TSRMLS_CC);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_UINT128:
|
|
||||||
handle_uint128(entry_data_list, z_value TSRMLS_CC);
|
|
||||||
break;
|
|
||||||
case MMDB_DATA_TYPE_INT32:
|
|
||||||
ZVAL_LONG(z_value, entry_data_list->entry_data.int32);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
zend_throw_exception_ex(maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Invalid data type arguments: %d",
|
|
||||||
entry_data_list->entry_data.type);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return entry_data_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_map(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
array_init(z_value);
|
|
||||||
const uint32_t map_size = entry_data_list->entry_data.data_size;
|
|
||||||
|
|
||||||
uint32_t i;
|
|
||||||
for (i = 0; i < map_size && entry_data_list; i++) {
|
|
||||||
entry_data_list = entry_data_list->next;
|
|
||||||
|
|
||||||
char *key = estrndup(entry_data_list->entry_data.utf8_string,
|
|
||||||
entry_data_list->entry_data.data_size);
|
|
||||||
if (NULL == key) {
|
|
||||||
zend_throw_exception_ex(maxminddb_exception_ce,
|
|
||||||
0 TSRMLS_CC,
|
|
||||||
"Invalid data type arguments");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry_data_list = entry_data_list->next;
|
|
||||||
zval new_value;
|
|
||||||
entry_data_list =
|
|
||||||
handle_entry_data_list(entry_data_list, &new_value TSRMLS_CC);
|
|
||||||
if (entry_data_list != NULL) {
|
|
||||||
add_assoc_zval(z_value, key, &new_value);
|
|
||||||
}
|
|
||||||
efree(key);
|
|
||||||
}
|
|
||||||
return entry_data_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const MMDB_entry_data_list_s *
|
|
||||||
handle_array(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
const uint32_t size = entry_data_list->entry_data.data_size;
|
|
||||||
|
|
||||||
array_init(z_value);
|
|
||||||
|
|
||||||
uint32_t i;
|
|
||||||
for (i = 0; i < size && entry_data_list; i++) {
|
|
||||||
entry_data_list = entry_data_list->next;
|
|
||||||
zval new_value;
|
|
||||||
entry_data_list =
|
|
||||||
handle_entry_data_list(entry_data_list, &new_value TSRMLS_CC);
|
|
||||||
if (entry_data_list != NULL) {
|
|
||||||
add_next_index_zval(z_value, &new_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry_data_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_uint128(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
uint64_t high = 0;
|
|
||||||
uint64_t low = 0;
|
|
||||||
#if MMDB_UINT128_IS_BYTE_ARRAY
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
high = (high << 8) | entry_data_list->entry_data.uint128[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 8; i < 16; i++) {
|
|
||||||
low = (low << 8) | entry_data_list->entry_data.uint128[i];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
high = entry_data_list->entry_data.uint128 >> 64;
|
|
||||||
low = (uint64_t)entry_data_list->entry_data.uint128;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *num_str;
|
|
||||||
spprintf(&num_str, 0, "0x%016" PRIX64 "%016" PRIX64, high, low);
|
|
||||||
CHECK_ALLOCATED(num_str);
|
|
||||||
|
|
||||||
ZVAL_STRING(z_value, num_str);
|
|
||||||
efree(num_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_uint32(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
uint32_t val = entry_data_list->entry_data.uint32;
|
|
||||||
|
|
||||||
#if LONG_MAX >= UINT32_MAX
|
|
||||||
ZVAL_LONG(z_value, val);
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (val <= LONG_MAX) {
|
|
||||||
ZVAL_LONG(z_value, val);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *int_str;
|
|
||||||
spprintf(&int_str, 0, "%" PRIu32, val);
|
|
||||||
CHECK_ALLOCATED(int_str);
|
|
||||||
|
|
||||||
ZVAL_STRING(z_value, int_str);
|
|
||||||
efree(int_str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_uint64(const MMDB_entry_data_list_s *entry_data_list,
|
|
||||||
zval *z_value TSRMLS_DC) {
|
|
||||||
uint64_t val = entry_data_list->entry_data.uint64;
|
|
||||||
|
|
||||||
#if LONG_MAX >= UINT64_MAX
|
|
||||||
ZVAL_LONG(z_value, val);
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (val <= LONG_MAX) {
|
|
||||||
ZVAL_LONG(z_value, val);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *int_str;
|
|
||||||
spprintf(&int_str, 0, "%" PRIu64, val);
|
|
||||||
CHECK_ALLOCATED(int_str);
|
|
||||||
|
|
||||||
ZVAL_STRING(z_value, int_str);
|
|
||||||
efree(int_str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void maxminddb_free_storage(free_obj_t *object TSRMLS_DC) {
|
|
||||||
maxminddb_obj *obj =
|
|
||||||
php_maxminddb_fetch_object((zend_object *)object TSRMLS_CC);
|
|
||||||
if (obj->mmdb != NULL) {
|
|
||||||
MMDB_close(obj->mmdb);
|
|
||||||
efree(obj->mmdb);
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_object_std_dtor(&obj->std TSRMLS_CC);
|
|
||||||
}
|
|
||||||
|
|
||||||
static zend_object *maxminddb_create_handler(zend_class_entry *type TSRMLS_DC) {
|
|
||||||
maxminddb_obj *obj = (maxminddb_obj *)ecalloc(1, sizeof(maxminddb_obj));
|
|
||||||
zend_object_std_init(&obj->std, type TSRMLS_CC);
|
|
||||||
object_properties_init(&(obj->std), type);
|
|
||||||
|
|
||||||
obj->std.handlers = &maxminddb_obj_handlers;
|
|
||||||
|
|
||||||
return &obj->std;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
static zend_function_entry maxminddb_methods[] = {
|
|
||||||
PHP_ME(MaxMind_Db_Reader, __construct, arginfo_maxminddbreader_construct,
|
|
||||||
ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
|
|
||||||
PHP_ME(MaxMind_Db_Reader, close, arginfo_maxminddbreader_void, ZEND_ACC_PUBLIC)
|
|
||||||
PHP_ME(MaxMind_Db_Reader, get, arginfo_maxminddbreader_get, ZEND_ACC_PUBLIC)
|
|
||||||
PHP_ME(MaxMind_Db_Reader, getWithPrefixLen, arginfo_maxminddbreader_getWithPrefixLen, ZEND_ACC_PUBLIC)
|
|
||||||
PHP_ME(MaxMind_Db_Reader, metadata, arginfo_maxminddbreader_void, ZEND_ACC_PUBLIC)
|
|
||||||
{ NULL, NULL, NULL }
|
|
||||||
};
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_metadata_construct, 0, 0, 1)
|
|
||||||
ZEND_ARG_TYPE_INFO(0, metadata, IS_ARRAY, 0)
|
|
||||||
ZEND_END_ARG_INFO()
|
|
||||||
|
|
||||||
PHP_METHOD(MaxMind_Db_Reader_Metadata, __construct) {
|
|
||||||
zval *object = NULL;
|
|
||||||
zval *metadata_array = NULL;
|
|
||||||
zend_long node_count = 0;
|
|
||||||
zend_long record_size = 0;
|
|
||||||
|
|
||||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
|
|
||||||
getThis(),
|
|
||||||
"Oa",
|
|
||||||
&object,
|
|
||||||
metadata_ce,
|
|
||||||
&metadata_array) == FAILURE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
zval *tmp = NULL;
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"binary_format_major_version",
|
|
||||||
sizeof("binary_format_major_version") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"binaryFormatMajorVersion",
|
|
||||||
sizeof("binaryFormatMajorVersion") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"binary_format_minor_version",
|
|
||||||
sizeof("binary_format_minor_version") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"binaryFormatMinorVersion",
|
|
||||||
sizeof("binaryFormatMinorVersion") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"build_epoch",
|
|
||||||
sizeof("build_epoch") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"buildEpoch",
|
|
||||||
sizeof("buildEpoch") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"database_type",
|
|
||||||
sizeof("database_type") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"databaseType",
|
|
||||||
sizeof("databaseType") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"description",
|
|
||||||
sizeof("description") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"description",
|
|
||||||
sizeof("description") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"ip_version",
|
|
||||||
sizeof("ip_version") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"ipVersion",
|
|
||||||
sizeof("ipVersion") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(
|
|
||||||
HASH_OF(metadata_array), "languages", sizeof("languages") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"languages",
|
|
||||||
sizeof("languages") - 1,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"record_size",
|
|
||||||
sizeof("record_size") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"recordSize",
|
|
||||||
sizeof("recordSize") - 1,
|
|
||||||
tmp);
|
|
||||||
if (Z_TYPE_P(tmp) == IS_LONG) {
|
|
||||||
record_size = Z_LVAL_P(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (record_size != 0) {
|
|
||||||
zend_update_property_long(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"nodeByteSize",
|
|
||||||
sizeof("nodeByteSize") - 1,
|
|
||||||
record_size / 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tmp = zend_hash_str_find(HASH_OF(metadata_array),
|
|
||||||
"node_count",
|
|
||||||
sizeof("node_count") - 1))) {
|
|
||||||
zend_update_property(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"nodeCount",
|
|
||||||
sizeof("nodeCount") - 1,
|
|
||||||
tmp);
|
|
||||||
if (Z_TYPE_P(tmp) == IS_LONG) {
|
|
||||||
node_count = Z_LVAL_P(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (record_size != 0) {
|
|
||||||
zend_update_property_long(metadata_ce,
|
|
||||||
PROP_OBJ(object),
|
|
||||||
"searchTreeSize",
|
|
||||||
sizeof("searchTreeSize") - 1,
|
|
||||||
record_size * node_count / 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
static zend_function_entry metadata_methods[] = {
|
|
||||||
PHP_ME(MaxMind_Db_Reader_Metadata, __construct, arginfo_metadata_construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
|
|
||||||
{NULL, NULL, NULL}
|
|
||||||
};
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(maxminddb) {
|
|
||||||
zend_class_entry ce;
|
|
||||||
|
|
||||||
INIT_CLASS_ENTRY(ce, PHP_MAXMINDDB_READER_EX_NS, NULL);
|
|
||||||
maxminddb_exception_ce =
|
|
||||||
zend_register_internal_class_ex(&ce, zend_ce_exception);
|
|
||||||
|
|
||||||
INIT_CLASS_ENTRY(ce, PHP_MAXMINDDB_READER_NS, maxminddb_methods);
|
|
||||||
maxminddb_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
|
||||||
maxminddb_ce->create_object = maxminddb_create_handler;
|
|
||||||
|
|
||||||
INIT_CLASS_ENTRY(ce, PHP_MAXMINDDB_METADATA_NS, metadata_methods);
|
|
||||||
metadata_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
|
||||||
zend_declare_property_null(metadata_ce,
|
|
||||||
"binaryFormatMajorVersion",
|
|
||||||
sizeof("binaryFormatMajorVersion") - 1,
|
|
||||||
ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(metadata_ce,
|
|
||||||
"binaryFormatMinorVersion",
|
|
||||||
sizeof("binaryFormatMinorVersion") - 1,
|
|
||||||
ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "buildEpoch", sizeof("buildEpoch") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(metadata_ce,
|
|
||||||
"databaseType",
|
|
||||||
sizeof("databaseType") - 1,
|
|
||||||
ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "description", sizeof("description") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "ipVersion", sizeof("ipVersion") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "languages", sizeof("languages") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(metadata_ce,
|
|
||||||
"nodeByteSize",
|
|
||||||
sizeof("nodeByteSize") - 1,
|
|
||||||
ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "nodeCount", sizeof("nodeCount") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(
|
|
||||||
metadata_ce, "recordSize", sizeof("recordSize") - 1, ZEND_ACC_PUBLIC);
|
|
||||||
zend_declare_property_null(metadata_ce,
|
|
||||||
"searchTreeSize",
|
|
||||||
sizeof("searchTreeSize") - 1,
|
|
||||||
ZEND_ACC_PUBLIC);
|
|
||||||
|
|
||||||
memcpy(&maxminddb_obj_handlers,
|
|
||||||
zend_get_std_object_handlers(),
|
|
||||||
sizeof(zend_object_handlers));
|
|
||||||
maxminddb_obj_handlers.clone_obj = NULL;
|
|
||||||
maxminddb_obj_handlers.offset = XtOffsetOf(maxminddb_obj, std);
|
|
||||||
maxminddb_obj_handlers.free_obj = maxminddb_free_storage;
|
|
||||||
zend_declare_class_constant_string(maxminddb_ce,
|
|
||||||
"MMDB_LIB_VERSION",
|
|
||||||
sizeof("MMDB_LIB_VERSION") - 1,
|
|
||||||
MMDB_lib_version() TSRMLS_CC);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PHP_MINFO_FUNCTION(maxminddb) {
|
|
||||||
php_info_print_table_start();
|
|
||||||
|
|
||||||
php_info_print_table_row(2, "MaxMind DB Reader", "enabled");
|
|
||||||
php_info_print_table_row(
|
|
||||||
2, "maxminddb extension version", PHP_MAXMINDDB_VERSION);
|
|
||||||
php_info_print_table_row(
|
|
||||||
2, "libmaxminddb library version", MMDB_lib_version());
|
|
||||||
|
|
||||||
php_info_print_table_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_module_entry maxminddb_module_entry = {STANDARD_MODULE_HEADER,
|
|
||||||
PHP_MAXMINDDB_EXTNAME,
|
|
||||||
NULL,
|
|
||||||
PHP_MINIT(maxminddb),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
PHP_MINFO(maxminddb),
|
|
||||||
PHP_MAXMINDDB_VERSION,
|
|
||||||
STANDARD_MODULE_PROPERTIES};
|
|
||||||
|
|
||||||
#ifdef COMPILE_DL_MAXMINDDB
|
|
||||||
ZEND_GET_MODULE(maxminddb)
|
|
||||||
#endif
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/* MaxMind, Inc., licenses this file to you under the Apache License, Version
|
|
||||||
* 2.0 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <zend_interfaces.h>
|
|
||||||
|
|
||||||
#ifndef PHP_MAXMINDDB_H
|
|
||||||
#define PHP_MAXMINDDB_H 1
|
|
||||||
#define PHP_MAXMINDDB_VERSION "1.13.1"
|
|
||||||
#define PHP_MAXMINDDB_EXTNAME "maxminddb"
|
|
||||||
|
|
||||||
extern zend_module_entry maxminddb_module_entry;
|
|
||||||
#define phpext_maxminddb_ptr &maxminddb_module_entry
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
--TEST--
|
|
||||||
Check for maxminddb presence
|
|
||||||
--SKIPIF--
|
|
||||||
<?php if (!extension_loaded('maxminddb')) {
|
|
||||||
echo 'skip';
|
|
||||||
} ?>
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
echo 'maxminddb extension is available';
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
maxminddb extension is available
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
--TEST--
|
|
||||||
Check that Reader class is not final
|
|
||||||
--SKIPIF--
|
|
||||||
<?php if (!extension_loaded('maxminddb')) {
|
|
||||||
echo 'skip';
|
|
||||||
} ?>
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
$reflectionClass = new \ReflectionClass('MaxMind\Db\Reader');
|
|
||||||
var_dump($reflectionClass->isFinal());
|
|
||||||
?>
|
|
||||||
--EXPECT--
|
|
||||||
bool(false)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
--TEST--
|
|
||||||
openbase_dir is followed
|
|
||||||
--INI--
|
|
||||||
open_basedir=/--dne--
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
use MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
$reader = new Reader('/usr/local/share/GeoIP/GeoIP2-City.mmdb');
|
|
||||||
?>
|
|
||||||
--EXPECTREGEX--
|
|
||||||
.*open_basedir restriction in effect.*
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
|
|
||||||
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
|
||||||
|
|
||||||
<name>maxminddb</name>
|
|
||||||
<channel>pecl.php.net</channel>
|
|
||||||
<summary>Reader for the MaxMind DB file format</summary>
|
|
||||||
<description>This is the PHP extension for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).</description>
|
|
||||||
<lead>
|
|
||||||
<name>Greg Oschwald</name>
|
|
||||||
<user>oschwald</user>
|
|
||||||
<email>goschwald@maxmind.com</email>
|
|
||||||
<active>yes</active>
|
|
||||||
</lead>
|
|
||||||
<date>2025-11-21</date>
|
|
||||||
<version>
|
|
||||||
<release>1.13.1</release>
|
|
||||||
<api>1.13.1</api>
|
|
||||||
</version>
|
|
||||||
<stability>
|
|
||||||
<release>stable</release>
|
|
||||||
<api>stable</api>
|
|
||||||
</stability>
|
|
||||||
<license uri="https://github.com/maxmind/MaxMind-DB-Reader-php/blob/main/LICENSE">Apache License 2.0</license>
|
|
||||||
<notes>* First PIE release. No other changes.</notes>
|
|
||||||
<contents>
|
|
||||||
<dir name="/">
|
|
||||||
<file role="doc" name="LICENSE"/>
|
|
||||||
<file role="doc" name="CHANGELOG.md"/>
|
|
||||||
<file role="doc" name="README.md"/>
|
|
||||||
|
|
||||||
<dir name="ext">
|
|
||||||
<file role="src" name="config.m4"/>
|
|
||||||
<file role="src" name="config.w32"/>
|
|
||||||
|
|
||||||
<file role="src" name="maxminddb.c"/>
|
|
||||||
<file role="src" name="php_maxminddb.h"/>
|
|
||||||
|
|
||||||
<dir name="tests">
|
|
||||||
<file role="test" name="001-load.phpt"/>
|
|
||||||
<file role="test" name="002-final.phpt"/>
|
|
||||||
<file role="test" name="003-open-basedir.phpt"/>
|
|
||||||
</dir>
|
|
||||||
</dir>
|
|
||||||
</dir>
|
|
||||||
</contents>
|
|
||||||
<dependencies>
|
|
||||||
<required>
|
|
||||||
<php>
|
|
||||||
<min>7.2.0</min>
|
|
||||||
</php>
|
|
||||||
<pearinstaller>
|
|
||||||
<min>1.10.0</min>
|
|
||||||
</pearinstaller>
|
|
||||||
</required>
|
|
||||||
</dependencies>
|
|
||||||
<providesextension>maxminddb</providesextension>
|
|
||||||
<extsrcrelease />
|
|
||||||
</package>
|
|
||||||
@@ -1,404 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MaxMind\Db;
|
|
||||||
|
|
||||||
use MaxMind\Db\Reader\Decoder;
|
|
||||||
use MaxMind\Db\Reader\InvalidDatabaseException;
|
|
||||||
use MaxMind\Db\Reader\Metadata;
|
|
||||||
use MaxMind\Db\Reader\Util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instances of this class provide a reader for the MaxMind DB format. IP
|
|
||||||
* addresses can be looked up using the get method.
|
|
||||||
*/
|
|
||||||
class Reader
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private static $DATA_SECTION_SEPARATOR_SIZE = 16;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static $METADATA_START_MARKER = "\xAB\xCD\xEFMaxMind.com";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int<0, max>
|
|
||||||
*/
|
|
||||||
private static $METADATA_START_MARKER_LENGTH = 14;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private static $METADATA_MAX_SIZE = 131072; // 128 * 1024 = 128KiB
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Decoder
|
|
||||||
*/
|
|
||||||
private $decoder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var resource
|
|
||||||
*/
|
|
||||||
private $fileHandle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $fileSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $ipV4Start;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Metadata
|
|
||||||
*/
|
|
||||||
private $metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a Reader for the MaxMind DB format. The file passed to it must
|
|
||||||
* be a valid MaxMind DB file such as a GeoIp2 database file.
|
|
||||||
*
|
|
||||||
* @param string $database the MaxMind DB file to use
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException for invalid database path or unknown arguments
|
|
||||||
* @throws InvalidDatabaseException
|
|
||||||
* if the database is invalid or there is an error reading
|
|
||||||
* from it
|
|
||||||
*/
|
|
||||||
public function __construct(string $database)
|
|
||||||
{
|
|
||||||
if (\func_num_args() !== 1) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 1 parameter, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_dir($database)) {
|
|
||||||
// This matches the error that the C extension throws.
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
"Error opening database file ($database). Is this a valid MaxMind DB file?"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fileHandle = @fopen($database, 'rb');
|
|
||||||
if ($fileHandle === false) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"The file \"$database\" does not exist or is not readable."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->fileHandle = $fileHandle;
|
|
||||||
|
|
||||||
$fstat = fstat($fileHandle);
|
|
||||||
if ($fstat === false) {
|
|
||||||
throw new \UnexpectedValueException(
|
|
||||||
"Error determining the size of \"$database\"."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->fileSize = $fstat['size'];
|
|
||||||
|
|
||||||
$start = $this->findMetadataStart($database);
|
|
||||||
$metadataDecoder = new Decoder($this->fileHandle, $start);
|
|
||||||
[$metadataArray] = $metadataDecoder->decode($start);
|
|
||||||
$this->metadata = new Metadata($metadataArray);
|
|
||||||
$this->decoder = new Decoder(
|
|
||||||
$this->fileHandle,
|
|
||||||
$this->metadata->searchTreeSize + self::$DATA_SECTION_SEPARATOR_SIZE
|
|
||||||
);
|
|
||||||
$this->ipV4Start = $this->ipV4StartNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the record for the IP address.
|
|
||||||
*
|
|
||||||
* @param string $ipAddress the IP address to look up
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException if this method is called on a closed database
|
|
||||||
* @throws \InvalidArgumentException if something other than a single IP address is passed to the method
|
|
||||||
* @throws InvalidDatabaseException
|
|
||||||
* if the database is invalid or there is an error reading
|
|
||||||
* from it
|
|
||||||
*
|
|
||||||
* @return mixed the record for the IP address
|
|
||||||
*/
|
|
||||||
public function get(string $ipAddress)
|
|
||||||
{
|
|
||||||
if (\func_num_args() !== 1) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 1 parameter, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[$record] = $this->getWithPrefixLen($ipAddress);
|
|
||||||
|
|
||||||
return $record;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the record for the IP address and its associated network prefix length.
|
|
||||||
*
|
|
||||||
* @param string $ipAddress the IP address to look up
|
|
||||||
*
|
|
||||||
* @throws \BadMethodCallException if this method is called on a closed database
|
|
||||||
* @throws \InvalidArgumentException if something other than a single IP address is passed to the method
|
|
||||||
* @throws InvalidDatabaseException
|
|
||||||
* if the database is invalid or there is an error reading
|
|
||||||
* from it
|
|
||||||
*
|
|
||||||
* @return array{0:mixed, 1:int} an array where the first element is the record and the
|
|
||||||
* second the network prefix length for the record
|
|
||||||
*/
|
|
||||||
public function getWithPrefixLen(string $ipAddress): array
|
|
||||||
{
|
|
||||||
if (\func_num_args() !== 1) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 1 parameter, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_resource($this->fileHandle)) {
|
|
||||||
throw new \BadMethodCallException(
|
|
||||||
'Attempt to read from a closed MaxMind DB.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
[$pointer, $prefixLen] = $this->findAddressInTree($ipAddress);
|
|
||||||
if ($pointer === 0) {
|
|
||||||
return [null, $prefixLen];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$this->resolveDataPointer($pointer), $prefixLen];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{0:int, 1:int}
|
|
||||||
*/
|
|
||||||
private function findAddressInTree(string $ipAddress): array
|
|
||||||
{
|
|
||||||
$packedAddr = @inet_pton($ipAddress);
|
|
||||||
if ($packedAddr === false) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"The value \"$ipAddress\" is not a valid IP address."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rawAddress = unpack('C*', $packedAddr);
|
|
||||||
if ($rawAddress === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack the unsigned char of the packed in_addr representation.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$bitCount = \count($rawAddress) * 8;
|
|
||||||
|
|
||||||
// The first node of the tree is always node 0, at the beginning of the
|
|
||||||
// value
|
|
||||||
$node = 0;
|
|
||||||
|
|
||||||
$metadata = $this->metadata;
|
|
||||||
|
|
||||||
// Check if we are looking up an IPv4 address in an IPv6 tree. If this
|
|
||||||
// is the case, we can skip over the first 96 nodes.
|
|
||||||
if ($metadata->ipVersion === 6) {
|
|
||||||
if ($bitCount === 32) {
|
|
||||||
$node = $this->ipV4Start;
|
|
||||||
}
|
|
||||||
} elseif ($metadata->ipVersion === 4 && $bitCount === 128) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"Error looking up $ipAddress. You attempted to look up an"
|
|
||||||
. ' IPv6 address in an IPv4-only database.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$nodeCount = $metadata->nodeCount;
|
|
||||||
|
|
||||||
for ($i = 0; $i < $bitCount && $node < $nodeCount; ++$i) {
|
|
||||||
$tempBit = 0xFF & $rawAddress[($i >> 3) + 1];
|
|
||||||
$bit = 1 & ($tempBit >> 7 - ($i % 8));
|
|
||||||
|
|
||||||
$node = $this->readNode($node, $bit);
|
|
||||||
}
|
|
||||||
if ($node === $nodeCount) {
|
|
||||||
// Record is empty
|
|
||||||
return [0, $i];
|
|
||||||
}
|
|
||||||
if ($node > $nodeCount) {
|
|
||||||
// Record is a data pointer
|
|
||||||
return [$node, $i];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Invalid or corrupt database. Maximum search depth reached without finding a leaf node'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function ipV4StartNode(): int
|
|
||||||
{
|
|
||||||
// If we have an IPv4 database, the start node is the first node
|
|
||||||
if ($this->metadata->ipVersion === 4) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$node = 0;
|
|
||||||
|
|
||||||
for ($i = 0; $i < 96 && $node < $this->metadata->nodeCount; ++$i) {
|
|
||||||
$node = $this->readNode($node, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $node;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function readNode(int $nodeNumber, int $index): int
|
|
||||||
{
|
|
||||||
$baseOffset = $nodeNumber * $this->metadata->nodeByteSize;
|
|
||||||
|
|
||||||
switch ($this->metadata->recordSize) {
|
|
||||||
case 24:
|
|
||||||
$bytes = Util::read($this->fileHandle, $baseOffset + $index * 3, 3);
|
|
||||||
$rc = unpack('N', "\x00" . $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack the unsigned long of the node.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $node] = $rc;
|
|
||||||
|
|
||||||
return $node;
|
|
||||||
|
|
||||||
case 28:
|
|
||||||
$bytes = Util::read($this->fileHandle, $baseOffset + 3 * $index, 4);
|
|
||||||
if ($index === 0) {
|
|
||||||
$middle = (0xF0 & \ord($bytes[3])) >> 4;
|
|
||||||
} else {
|
|
||||||
$middle = 0x0F & \ord($bytes[0]);
|
|
||||||
}
|
|
||||||
$rc = unpack('N', \chr($middle) . substr($bytes, $index, 3));
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack the unsigned long of the node.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $node] = $rc;
|
|
||||||
|
|
||||||
return $node;
|
|
||||||
|
|
||||||
case 32:
|
|
||||||
$bytes = Util::read($this->fileHandle, $baseOffset + $index * 4, 4);
|
|
||||||
$rc = unpack('N', $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack the unsigned long of the node.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $node] = $rc;
|
|
||||||
|
|
||||||
return $node;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Unknown record size: '
|
|
||||||
. $this->metadata->recordSize
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function resolveDataPointer(int $pointer)
|
|
||||||
{
|
|
||||||
$resolved = $pointer - $this->metadata->nodeCount
|
|
||||||
+ $this->metadata->searchTreeSize;
|
|
||||||
if ($resolved >= $this->fileSize) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
"The MaxMind DB file's search tree is corrupt"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
[$data] = $this->decoder->decode($resolved);
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is an extremely naive but reasonably readable implementation. There
|
|
||||||
* are much faster algorithms (e.g., Boyer-Moore) for this if speed is ever
|
|
||||||
* an issue, but I suspect it won't be.
|
|
||||||
*/
|
|
||||||
private function findMetadataStart(string $filename): int
|
|
||||||
{
|
|
||||||
$handle = $this->fileHandle;
|
|
||||||
$fileSize = $this->fileSize;
|
|
||||||
$marker = self::$METADATA_START_MARKER;
|
|
||||||
$markerLength = self::$METADATA_START_MARKER_LENGTH;
|
|
||||||
|
|
||||||
$minStart = $fileSize - min(self::$METADATA_MAX_SIZE, $fileSize);
|
|
||||||
|
|
||||||
for ($offset = $fileSize - $markerLength; $offset >= $minStart; --$offset) {
|
|
||||||
if (fseek($handle, $offset) !== 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$value = fread($handle, $markerLength);
|
|
||||||
if ($value === $marker) {
|
|
||||||
return $offset + $markerLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
"Error opening database file ($filename). "
|
|
||||||
. 'Is this a valid MaxMind DB file?'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \InvalidArgumentException if arguments are passed to the method
|
|
||||||
* @throws \BadMethodCallException if the database has been closed
|
|
||||||
*
|
|
||||||
* @return Metadata object for the database
|
|
||||||
*/
|
|
||||||
public function metadata(): Metadata
|
|
||||||
{
|
|
||||||
if (\func_num_args()) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 0 parameters, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not technically required, but this makes it consistent with
|
|
||||||
// C extension and it allows us to change our implementation later.
|
|
||||||
if (!\is_resource($this->fileHandle)) {
|
|
||||||
throw new \BadMethodCallException(
|
|
||||||
'Attempt to read from a closed MaxMind DB.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return clone $this->metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the MaxMind DB and returns resources to the system.
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
* if an I/O error occurs
|
|
||||||
*/
|
|
||||||
public function close(): void
|
|
||||||
{
|
|
||||||
if (\func_num_args()) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 0 parameters, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_resource($this->fileHandle)) {
|
|
||||||
throw new \BadMethodCallException(
|
|
||||||
'Attempt to close a closed MaxMind DB.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
fclose($this->fileHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,452 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
// @codingStandardsIgnoreLine
|
|
||||||
|
|
||||||
class Decoder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var resource
|
|
||||||
*/
|
|
||||||
private $fileStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $pointerBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is only used for unit testing.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $pointerTestHack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $switchByteOrder;
|
|
||||||
|
|
||||||
private const _EXTENDED = 0;
|
|
||||||
private const _POINTER = 1;
|
|
||||||
private const _UTF8_STRING = 2;
|
|
||||||
private const _DOUBLE = 3;
|
|
||||||
private const _BYTES = 4;
|
|
||||||
private const _UINT16 = 5;
|
|
||||||
private const _UINT32 = 6;
|
|
||||||
private const _MAP = 7;
|
|
||||||
private const _INT32 = 8;
|
|
||||||
private const _UINT64 = 9;
|
|
||||||
private const _UINT128 = 10;
|
|
||||||
private const _ARRAY = 11;
|
|
||||||
// 12 is the container type
|
|
||||||
// 13 is the end marker type
|
|
||||||
private const _BOOLEAN = 14;
|
|
||||||
private const _FLOAT = 15;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param resource $fileStream
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
$fileStream,
|
|
||||||
int $pointerBase = 0,
|
|
||||||
bool $pointerTestHack = false
|
|
||||||
) {
|
|
||||||
$this->fileStream = $fileStream;
|
|
||||||
$this->pointerBase = $pointerBase;
|
|
||||||
|
|
||||||
$this->pointerTestHack = $pointerTestHack;
|
|
||||||
|
|
||||||
$this->switchByteOrder = $this->isPlatformLittleEndian();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<mixed>
|
|
||||||
*/
|
|
||||||
public function decode(int $offset): array
|
|
||||||
{
|
|
||||||
$ctrlByte = \ord(Util::read($this->fileStream, $offset, 1));
|
|
||||||
++$offset;
|
|
||||||
|
|
||||||
$type = $ctrlByte >> 5;
|
|
||||||
|
|
||||||
// Pointers are a special case, we don't read the next $size bytes, we
|
|
||||||
// use the size to determine the length of the pointer and then follow
|
|
||||||
// it.
|
|
||||||
if ($type === self::_POINTER) {
|
|
||||||
[$pointer, $offset] = $this->decodePointer($ctrlByte, $offset);
|
|
||||||
|
|
||||||
// for unit testing
|
|
||||||
if ($this->pointerTestHack) {
|
|
||||||
return [$pointer];
|
|
||||||
}
|
|
||||||
|
|
||||||
[$result] = $this->decode($pointer);
|
|
||||||
|
|
||||||
return [$result, $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type === self::_EXTENDED) {
|
|
||||||
$nextByte = \ord(Util::read($this->fileStream, $offset, 1));
|
|
||||||
|
|
||||||
$type = $nextByte + 7;
|
|
||||||
|
|
||||||
if ($type < 8) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Something went horribly wrong in the decoder. An extended type '
|
|
||||||
. 'resolved to a type number < 8 ('
|
|
||||||
. $type
|
|
||||||
. ')'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
++$offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
[$size, $offset] = $this->sizeFromCtrlByte($ctrlByte, $offset);
|
|
||||||
|
|
||||||
return $this->decodeByType($type, $offset, $size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int<0, max> $size
|
|
||||||
*
|
|
||||||
* @return array{0:mixed, 1:int}
|
|
||||||
*/
|
|
||||||
private function decodeByType(int $type, int $offset, int $size): array
|
|
||||||
{
|
|
||||||
switch ($type) {
|
|
||||||
case self::_MAP:
|
|
||||||
return $this->decodeMap($size, $offset);
|
|
||||||
|
|
||||||
case self::_ARRAY:
|
|
||||||
return $this->decodeArray($size, $offset);
|
|
||||||
|
|
||||||
case self::_BOOLEAN:
|
|
||||||
return [$this->decodeBoolean($size), $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
$newOffset = $offset + $size;
|
|
||||||
$bytes = Util::read($this->fileStream, $offset, $size);
|
|
||||||
|
|
||||||
switch ($type) {
|
|
||||||
case self::_BYTES:
|
|
||||||
case self::_UTF8_STRING:
|
|
||||||
return [$bytes, $newOffset];
|
|
||||||
|
|
||||||
case self::_DOUBLE:
|
|
||||||
$this->verifySize(8, $size);
|
|
||||||
|
|
||||||
return [$this->decodeDouble($bytes), $newOffset];
|
|
||||||
|
|
||||||
case self::_FLOAT:
|
|
||||||
$this->verifySize(4, $size);
|
|
||||||
|
|
||||||
return [$this->decodeFloat($bytes), $newOffset];
|
|
||||||
|
|
||||||
case self::_INT32:
|
|
||||||
return [$this->decodeInt32($bytes, $size), $newOffset];
|
|
||||||
|
|
||||||
case self::_UINT16:
|
|
||||||
case self::_UINT32:
|
|
||||||
case self::_UINT64:
|
|
||||||
case self::_UINT128:
|
|
||||||
return [$this->decodeUint($bytes, $size), $newOffset];
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Unknown or unexpected type: ' . $type
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function verifySize(int $expected, int $actual): void
|
|
||||||
{
|
|
||||||
if ($expected !== $actual) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
"The MaxMind DB file's data section contains bad data (unknown data type or corrupt data)"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{0:array<mixed>, 1:int}
|
|
||||||
*/
|
|
||||||
private function decodeArray(int $size, int $offset): array
|
|
||||||
{
|
|
||||||
$array = [];
|
|
||||||
|
|
||||||
for ($i = 0; $i < $size; ++$i) {
|
|
||||||
[$value, $offset] = $this->decode($offset);
|
|
||||||
$array[] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$array, $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function decodeBoolean(int $size): bool
|
|
||||||
{
|
|
||||||
return $size !== 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function decodeDouble(string $bytes): float
|
|
||||||
{
|
|
||||||
// This assumes IEEE 754 doubles, but most (all?) modern platforms
|
|
||||||
// use them.
|
|
||||||
$rc = unpack('E', $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack a double value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $double] = $rc;
|
|
||||||
|
|
||||||
return $double;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function decodeFloat(string $bytes): float
|
|
||||||
{
|
|
||||||
// This assumes IEEE 754 floats, but most (all?) modern platforms
|
|
||||||
// use them.
|
|
||||||
$rc = unpack('G', $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack a float value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $float] = $rc;
|
|
||||||
|
|
||||||
return $float;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function decodeInt32(string $bytes, int $size): int
|
|
||||||
{
|
|
||||||
switch ($size) {
|
|
||||||
case 0:
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
$bytes = str_pad($bytes, 4, "\x00", \STR_PAD_LEFT);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
"The MaxMind DB file's data section contains bad data (unknown data type or corrupt data)"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rc = unpack('l', $this->maybeSwitchByteOrder($bytes));
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack a 32bit integer value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $int] = $rc;
|
|
||||||
|
|
||||||
return $int;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{0:array<string, mixed>, 1:int}
|
|
||||||
*/
|
|
||||||
private function decodeMap(int $size, int $offset): array
|
|
||||||
{
|
|
||||||
$map = [];
|
|
||||||
|
|
||||||
for ($i = 0; $i < $size; ++$i) {
|
|
||||||
[$key, $offset] = $this->decode($offset);
|
|
||||||
[$value, $offset] = $this->decode($offset);
|
|
||||||
$map[$key] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$map, $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{0:int, 1:int}
|
|
||||||
*/
|
|
||||||
private function decodePointer(int $ctrlByte, int $offset): array
|
|
||||||
{
|
|
||||||
$pointerSize = (($ctrlByte >> 3) & 0x3) + 1;
|
|
||||||
|
|
||||||
$buffer = Util::read($this->fileStream, $offset, $pointerSize);
|
|
||||||
$offset += $pointerSize;
|
|
||||||
|
|
||||||
switch ($pointerSize) {
|
|
||||||
case 1:
|
|
||||||
$packed = \chr($ctrlByte & 0x7) . $buffer;
|
|
||||||
$rc = unpack('n', $packed);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned short value from the given bytes (pointerSize is 1).'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $pointer] = $rc;
|
|
||||||
$pointer += $this->pointerBase;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
$packed = "\x00" . \chr($ctrlByte & 0x7) . $buffer;
|
|
||||||
$rc = unpack('N', $packed);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned long value from the given bytes (pointerSize is 2).'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $pointer] = $rc;
|
|
||||||
$pointer += $this->pointerBase + 2048;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
$packed = \chr($ctrlByte & 0x7) . $buffer;
|
|
||||||
|
|
||||||
// It is safe to use 'N' here, even on 32 bit machines as the
|
|
||||||
// first bit is 0.
|
|
||||||
$rc = unpack('N', $packed);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned long value from the given bytes (pointerSize is 3).'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $pointer] = $rc;
|
|
||||||
$pointer += $this->pointerBase + 526336;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
// We cannot use unpack here as we might overflow on 32 bit
|
|
||||||
// machines
|
|
||||||
$pointerOffset = $this->decodeUint($buffer, $pointerSize);
|
|
||||||
|
|
||||||
$pointerBase = $this->pointerBase;
|
|
||||||
|
|
||||||
if (\PHP_INT_MAX - $pointerBase >= $pointerOffset) {
|
|
||||||
$pointer = $pointerOffset + $pointerBase;
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException(
|
|
||||||
'The database offset is too large to be represented on your platform.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Unexpected pointer size ' . $pointerSize
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$pointer, $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
private function decodeUint(string $bytes, int $byteLength)
|
|
||||||
{
|
|
||||||
if ($byteLength === 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PHP integers are signed. PHP_INT_SIZE - 1 is the number of
|
|
||||||
// complete bytes that can be converted to an integer. However,
|
|
||||||
// we can convert another byte if the leading bit is zero.
|
|
||||||
$useRealInts = $byteLength <= \PHP_INT_SIZE - 1
|
|
||||||
|| ($byteLength === \PHP_INT_SIZE && (\ord($bytes[0]) & 0x80) === 0);
|
|
||||||
|
|
||||||
if ($useRealInts) {
|
|
||||||
$integer = 0;
|
|
||||||
for ($i = 0; $i < $byteLength; ++$i) {
|
|
||||||
$part = \ord($bytes[$i]);
|
|
||||||
$integer = ($integer << 8) + $part;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $integer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We only use gmp or bcmath if the final value is too big
|
|
||||||
$integerAsString = '0';
|
|
||||||
for ($i = 0; $i < $byteLength; ++$i) {
|
|
||||||
$part = \ord($bytes[$i]);
|
|
||||||
|
|
||||||
if (\extension_loaded('gmp')) {
|
|
||||||
$integerAsString = gmp_strval(gmp_add(gmp_mul($integerAsString, '256'), $part));
|
|
||||||
} elseif (\extension_loaded('bcmath')) {
|
|
||||||
$integerAsString = bcadd(bcmul($integerAsString, '256'), (string) $part);
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException(
|
|
||||||
'The gmp or bcmath extension must be installed to read this database.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $integerAsString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{0:int, 1:int}
|
|
||||||
*/
|
|
||||||
private function sizeFromCtrlByte(int $ctrlByte, int $offset): array
|
|
||||||
{
|
|
||||||
$size = $ctrlByte & 0x1F;
|
|
||||||
|
|
||||||
if ($size < 29) {
|
|
||||||
return [$size, $offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
$bytesToRead = $size - 28;
|
|
||||||
$bytes = Util::read($this->fileStream, $offset, $bytesToRead);
|
|
||||||
|
|
||||||
if ($size === 29) {
|
|
||||||
$size = 29 + \ord($bytes);
|
|
||||||
} elseif ($size === 30) {
|
|
||||||
$rc = unpack('n', $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned short value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $adjust] = $rc;
|
|
||||||
$size = 285 + $adjust;
|
|
||||||
} else {
|
|
||||||
$rc = unpack('N', "\x00" . $bytes);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned long value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
[, $adjust] = $rc;
|
|
||||||
$size = $adjust + 65821;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$size, $offset + $bytesToRead];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function maybeSwitchByteOrder(string $bytes): string
|
|
||||||
{
|
|
||||||
return $this->switchByteOrder ? strrev($bytes) : $bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isPlatformLittleEndian(): bool
|
|
||||||
{
|
|
||||||
$testint = 0x00FF;
|
|
||||||
$packed = pack('S', $testint);
|
|
||||||
$rc = unpack('v', $packed);
|
|
||||||
if ($rc === false) {
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'Could not unpack an unsigned short value from the given bytes.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $testint === current($rc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class should be thrown when unexpected data is found in the database.
|
|
||||||
*/
|
|
||||||
// phpcs:disable
|
|
||||||
class InvalidDatabaseException extends \Exception {}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides the metadata for the MaxMind DB file.
|
|
||||||
*/
|
|
||||||
class Metadata
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This is an unsigned 16-bit integer indicating the major version number
|
|
||||||
* for the database's binary format.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $binaryFormatMajorVersion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an unsigned 16-bit integer indicating the minor version number
|
|
||||||
* for the database's binary format.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $binaryFormatMinorVersion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an unsigned 64-bit integer that contains the database build
|
|
||||||
* timestamp as a Unix epoch value.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $buildEpoch;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a string that indicates the structure of each data record
|
|
||||||
* associated with an IP address. The actual definition of these
|
|
||||||
* structures is left up to the database creator.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $databaseType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This key will always point to a map (associative array). The keys of
|
|
||||||
* that map will be language codes, and the values will be a description
|
|
||||||
* in that language as a UTF-8 string. May be undefined for some
|
|
||||||
* databases.
|
|
||||||
*
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
public $description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an unsigned 16-bit integer which is always 4 or 6. It indicates
|
|
||||||
* whether the database contains IPv4 or IPv6 address data.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $ipVersion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of strings, each of which is a language code. A given record
|
|
||||||
* may contain data items that have been localized to some or all of
|
|
||||||
* these languages. This may be undefined.
|
|
||||||
*
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
public $languages;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $nodeByteSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an unsigned 32-bit integer indicating the number of nodes in
|
|
||||||
* the search tree.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $nodeCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an unsigned 16-bit integer. It indicates the number of bits in a
|
|
||||||
* record in the search tree. Note that each node consists of two records.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $recordSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $searchTreeSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $metadata
|
|
||||||
*/
|
|
||||||
public function __construct(array $metadata)
|
|
||||||
{
|
|
||||||
if (\func_num_args() !== 1) {
|
|
||||||
throw new \ArgumentCountError(
|
|
||||||
\sprintf('%s() expects exactly 1 parameter, %d given', __METHOD__, \func_num_args())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->binaryFormatMajorVersion
|
|
||||||
= $metadata['binary_format_major_version'];
|
|
||||||
$this->binaryFormatMinorVersion
|
|
||||||
= $metadata['binary_format_minor_version'];
|
|
||||||
$this->buildEpoch = $metadata['build_epoch'];
|
|
||||||
$this->databaseType = $metadata['database_type'];
|
|
||||||
$this->languages = $metadata['languages'];
|
|
||||||
$this->description = $metadata['description'];
|
|
||||||
$this->ipVersion = $metadata['ip_version'];
|
|
||||||
$this->nodeCount = $metadata['node_count'];
|
|
||||||
$this->recordSize = $metadata['record_size'];
|
|
||||||
$this->nodeByteSize = $this->recordSize / 4;
|
|
||||||
$this->searchTreeSize = $this->nodeCount * $this->nodeByteSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
class Util
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param resource $stream
|
|
||||||
* @param int<0, max> $numberOfBytes
|
|
||||||
*/
|
|
||||||
public static function read($stream, int $offset, int $numberOfBytes): string
|
|
||||||
{
|
|
||||||
if ($numberOfBytes === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (fseek($stream, $offset) === 0) {
|
|
||||||
$value = fread($stream, $numberOfBytes);
|
|
||||||
|
|
||||||
// We check that the number of bytes read is equal to the number
|
|
||||||
// asked for. We use ftell as getting the length of $value is
|
|
||||||
// much slower.
|
|
||||||
if ($value !== false && ftell($stream) - $offset === $numberOfBytes) {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidDatabaseException(
|
|
||||||
'The MaxMind DB file contains bad data'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once(__DIR__.'/../.hta_config/conf.php');
|
|
||||||
require_once(__DIR__.'/../.hta_slug/_header.php');
|
|
||||||
require_once(__DIR__.'/../.hta_slug/_nav.php');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<section class="diZContainer diZmxAuto diZmb20">
|
|
||||||
<h1 class="diZBorderBottom">SiliconPin - Tools</h1>
|
|
||||||
<div class="diZFlexRow diZmy8 diZFlexRow">
|
|
||||||
<a href="/tools" class="diZButtonDefault diZmr2"><span>All</span></a>
|
|
||||||
<a href="/tools/image" class="diZButtonDefault diZmr2"><span>Image</span></a>
|
|
||||||
<a href="/tools/text" class="diZButtonDefault diZmr2"><span>Text</span></a>
|
|
||||||
<a href="/tools/html" class="diZButtonDefault diZmr2"><span>HTML</span></a>
|
|
||||||
<a href="/tools/color" class="diZButtonDefault diZmr2"><span>Color</span></a>
|
|
||||||
<a href="/tools/info" class="diZButtonDefault diZmr2"><span>Info</span></a>
|
|
||||||
<a href="/tools/encrypt-decrypt" class="diZButtonDefault diZmr2"><span>Encrypt / Decrypt</span></a>
|
|
||||||
</div>
|
|
||||||
<div class="diZGridCols1-3">
|
|
||||||
<?php
|
|
||||||
$requestUri = $_SERVER['REQUEST_URI'];
|
|
||||||
$requestUri = explode('/', $requestUri)[2];
|
|
||||||
$requestUri = ($requestUri <= 1) ? "%%" : $requestUri;
|
|
||||||
if(isset($requestUri) && strlen($requestUri > 1)){
|
|
||||||
try {
|
|
||||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
$stmt = $conn->prepare("SELECT * FROM api_tools WHERE `type` = :type");
|
|
||||||
$stmt->bindParam(':type', $requestUri);
|
|
||||||
$stmt->execute();
|
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
// var_dump($rows);
|
|
||||||
foreach($rows as $row){
|
|
||||||
// echo $row['name'].'<br>';
|
|
||||||
if($row['status']==1){
|
|
||||||
$link_button = '<a class="diZButtonDefault" href="/tools/'.$row['slug'].'" ><span class="">'.$row['name'].'</span></a>';
|
|
||||||
} else{
|
|
||||||
$link_button = '<a class="diZButtonDefault"><span>'.$row['name'].'</span></a>';
|
|
||||||
}
|
|
||||||
echo '
|
|
||||||
<div class="diZblogStyle diZPadding10px">
|
|
||||||
<p class="diZLineClamp1">'.$row['description'].'</p>
|
|
||||||
'.$link_button.'
|
|
||||||
</div>';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$in_page_message = "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
echo 'Page Not Found!';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<style>
|
|
||||||
.diZContainer {
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZBorderBottom {
|
|
||||||
border-bottom: 2px solid #87ab63;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZFlexRow {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZButtonDefault {
|
|
||||||
background: #87ab63;
|
|
||||||
color: #121212;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: bold;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZButtonDefault:hover {
|
|
||||||
background: #6f8f52;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZGridCols1-3 {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
||||||
gap: 15px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZblogStyle {
|
|
||||||
background: #1e1e1e;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 15px;
|
|
||||||
box-shadow: 0px 0px 10px rgba(135, 171, 99, 0.3);
|
|
||||||
transition: transform 0.3s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZblogStyle:hover {
|
|
||||||
transform: translateY(-5px);
|
|
||||||
box-shadow: 0px 0px 15px rgba(135, 171, 99, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZToolsContentHeight {
|
|
||||||
min-height: 60px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once(__DIR__.'/../.hta_config/conf.php');
|
|
||||||
require_once(__DIR__.'/../.hta_slug/_header.php');
|
|
||||||
require_once(__DIR__.'/../.hta_slug/_nav.php');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<section class="diZContainer diZmxAuto diZmb20">
|
|
||||||
<h1 class="diZBorderBottom">SiliconPin - Tools</h1>
|
|
||||||
<div class="diZFlexRow diZmy8 diZFlexRow diZOverflowAuto diZWhiteSpaceNowrap">
|
|
||||||
<a href="/tools" class="diZButtonDefault diZmr2"><span>All</span></a>
|
|
||||||
<a href="/tools/image" class="diZButtonDefault diZmr2"><span>Image</span></a>
|
|
||||||
<a href="/tools/text" class="diZButtonDefault diZmr2"><span>Text</span></a><br>
|
|
||||||
<a href="/tools/html" class="diZButtonDefault diZmr2"><span>HTML</span></a>
|
|
||||||
<a href="/tools/color" class="diZButtonDefault diZmr2"><span>Color</span></a>
|
|
||||||
<a href="/tools/info" class="diZButtonDefault diZmr2"><span>Info</span></a>
|
|
||||||
<a href="/tools/encrypt-decrypt" class="diZButtonDefault diZmr2"><span>Encrypt / Decrypt</span></a>
|
|
||||||
</div>
|
|
||||||
<div class="diZGridCols1-3">
|
|
||||||
<?php
|
|
||||||
try {
|
|
||||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
$stmt = $conn->prepare("SELECT * FROM api_tools");
|
|
||||||
$stmt->execute();
|
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
// var_dump($rows);
|
|
||||||
foreach($rows as $row){
|
|
||||||
// echo $row['name'].'<br>';
|
|
||||||
if($row['status']==1){
|
|
||||||
$link_button = '<a class="diZButtonDefault" href="/tools/'.$row['slug'].'" ><span class="">'.$row['name'].'</span></a>';
|
|
||||||
} else{
|
|
||||||
$link_button = '<a class="diZButtonDefault"><span>'.$row['name'].'</span></a>';
|
|
||||||
}
|
|
||||||
echo '
|
|
||||||
<div class="diZblogStyle diZPadding10px">
|
|
||||||
<p class="diZLineClamp2 diZTextJustify diZToolsContentHeight" >'.$row['description'].'</p>
|
|
||||||
'.$link_button.'
|
|
||||||
</div>';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$in_page_message = "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<style>
|
|
||||||
.diZContainer {
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: auto;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZBorderBottom {
|
|
||||||
border-bottom: 2px solid #87ab63;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZFlexRow {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZButtonDefault {
|
|
||||||
background: #87ab63;
|
|
||||||
color: #121212;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: bold;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZButtonDefault:hover {
|
|
||||||
background: #6f8f52;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZGridCols1-3 {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
||||||
gap: 15px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZblogStyle {
|
|
||||||
background: #1e1e1e;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 15px;
|
|
||||||
box-shadow: 0px 0px 10px rgba(135, 171, 99, 0.3);
|
|
||||||
transition: transform 0.3s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZblogStyle:hover {
|
|
||||||
transform: translateY(-5px);
|
|
||||||
box-shadow: 0px 0px 15px rgba(135, 171, 99, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.diZToolsContentHeight {
|
|
||||||
min-height: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Convert Base64 to Image</h2>
|
|
||||||
<div class="diZMaxW500 diZmxAuto diZFlexColumn toolsSection diZmy20">
|
|
||||||
<textarea rows="10" class="base64-textarea" placeholder="Enter base64 encoded image data"></textarea>
|
|
||||||
<p class="diZDisplayNone diZDengerText" id="no-select-message"></p>
|
|
||||||
<button class="convert-button diZmt2"><span>Convert to Image</span></button>
|
|
||||||
<div class="" id="preview"></div>
|
|
||||||
|
|
||||||
<div class="diZFlexColumn diZDisplayNone diZJustifyCenter" id="download-options" >
|
|
||||||
<p>Choose Image Format & Download:</p>
|
|
||||||
<div class="diZFlexRow">
|
|
||||||
<button class="format-button" data-format="png"><span>PNG</span></button>
|
|
||||||
<button class="format-button" data-format="jpeg"><span>JPEG</span></button>
|
|
||||||
<button class="format-button" data-format="webp"><span>WebP</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
document.querySelector('.convert-button').addEventListener('click', function() {
|
|
||||||
var base64Data = document.querySelector('.base64-textarea').value.trim();
|
|
||||||
if (base64Data !== '') {
|
|
||||||
var img = document.createElement('img');
|
|
||||||
img.src = base64Data;
|
|
||||||
img.style.maxWidth = '100%';
|
|
||||||
img.style.height = 'auto';
|
|
||||||
document.getElementById('preview').innerHTML = '';
|
|
||||||
document.getElementById('preview').appendChild(img);
|
|
||||||
document.getElementById('download-options').style.display = 'block';
|
|
||||||
} else {
|
|
||||||
document.getElementById('no-select-message').innerHTML = 'Please enter base64 encoded image data.';
|
|
||||||
document.getElementById('no-select-message').style.display = 'block';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add event listeners to format buttons
|
|
||||||
var formatButtons = document.querySelectorAll('.format-button');
|
|
||||||
formatButtons.forEach(function(button) {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
var imageFormat = this.getAttribute('data-format');
|
|
||||||
downloadImage(imageFormat);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function downloadImage(imageFormat) {
|
|
||||||
var base64Data = document.querySelector('.base64-textarea').value.trim();
|
|
||||||
var downloadLink = document.createElement('a');
|
|
||||||
downloadLink.href = base64Data;
|
|
||||||
downloadLink.download = 'image.' + imageFormat;
|
|
||||||
downloadLink.click();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h1 class="diZBorderBottom">Color Hex/RGB Code From Image</h1>
|
|
||||||
<p>The Color Code Extractor from Image is a simple and efficient web-based tool that allows users to upload an image and click on any part of it to get the RGB and HEX color codes of the pixel they clicked on. This tool is particularly useful for designers, developers, and anyone who needs to identify and use specific colors from images.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection">
|
|
||||||
<label class="diZFlexColumn " for="imageInput">Choose Image</label><br>
|
|
||||||
<input class="diZPadding10px" type="file" id="imageInput" accept="image/*" /><br><br>
|
|
||||||
<canvas class="diZDisplayNone diZw100" id="canvas"></canvas><br>
|
|
||||||
<div class="diZFlexBetween">
|
|
||||||
<div id="result">Click on the image to get the color code.</div>
|
|
||||||
<button class="diZDisplayNone" id="copyButton" ><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h2>Usage:</h2>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Upload an Image:</strong> Click on the file input field and select an image file from your device.</li>
|
|
||||||
<li><strong>Display the Image:</strong> Once the image is uploaded, it will be displayed on a hidden canvas element.</li>
|
|
||||||
<li><strong>Extract Color Code:</strong> Click on any part of the displayed image. The tool will capture the color of the clicked pixel and display both the RGB and HEX color codes.</li>
|
|
||||||
<li><strong>Copy Color Code:</strong> Click the "Copy Color Code" button to copy the displayed color code to your clipboard for easy use in your projects.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2>Features:</h2>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Easy Image Upload:</strong> Supports uploading images directly from your device.</li>
|
|
||||||
<li><strong>Accurate Color Extraction:</strong> Retrieves the exact RGB and HEX color codes from any pixel of the image.</li>
|
|
||||||
<li><strong>Clipboard Copy Functionality:</strong> Allows you to easily copy the extracted color codes to your clipboard.</li>
|
|
||||||
<li><strong>Fallback for Compatibility:</strong> Provides a fallback method for copying color codes on browsers that do not support the Clipboard API.</li>
|
|
||||||
<li><strong>User-Friendly Interface:</strong> Simple and intuitive design for ease of use.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2>Use Case:</h2>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Web Designers and Developers:</strong> Quickly extract color codes from images for use in web design and development projects.</li>
|
|
||||||
<li><strong>Graphic Designers:</strong> Identify and use specific colors from images in design software.</li>
|
|
||||||
<li><strong>Digital Artists:</strong> Match colors from reference images to create cohesive artworks.</li>
|
|
||||||
<li><strong>Marketing Professionals:</strong> Ensure brand consistency by extracting and using exact colors from marketing materials and logos.</li>
|
|
||||||
<li><strong>DIY Enthusiasts:</strong> Use color codes to match paint colors, fabrics, or other materials in home decoration projects.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const imageInput = document.getElementById('imageInput');
|
|
||||||
const copyButton = document.getElementById('copyButton');
|
|
||||||
|
|
||||||
imageInput.addEventListener('change', function(event) {
|
|
||||||
const file = event.target.files[0];
|
|
||||||
if (file) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = function(e) {
|
|
||||||
const img = new Image();
|
|
||||||
img.onload = function() {
|
|
||||||
const canvas = document.getElementById('canvas');
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
canvas.width = img.width;
|
|
||||||
canvas.height = img.height;
|
|
||||||
ctx.drawImage(img, 0, 0);
|
|
||||||
canvas.style.display = 'block';
|
|
||||||
|
|
||||||
canvas.addEventListener('click', function(event) {
|
|
||||||
const rect = canvas.getBoundingClientRect();
|
|
||||||
const x = event.clientX - rect.left;
|
|
||||||
const y = event.clientY - rect.top;
|
|
||||||
console.log(`Clicked at (x, y): (${x}, ${y})`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const imageData = ctx.getImageData(x, y, 1, 1).data;
|
|
||||||
const rgb = `rgb(${imageData[0]}, ${imageData[1]}, ${imageData[2]})`;
|
|
||||||
const hex = `#${((1 << 24) + (imageData[0] << 16) + (imageData[1] << 8) + imageData[2]).toString(16).slice(1).toUpperCase()}`;
|
|
||||||
const colorCode = `RGB: ${rgb}, HEX: ${hex}`;
|
|
||||||
console.log('Color code:', colorCode);
|
|
||||||
document.getElementById('result').innerText = colorCode;
|
|
||||||
copyButton.style.display = 'block';
|
|
||||||
copyButton.setAttribute('data-color-code', colorCode);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error getting image data:', err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
img.src = e.target.result;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
copyButton.addEventListener('click', function() {
|
|
||||||
const colorCode = copyButton.getAttribute('data-color-code');
|
|
||||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
||||||
navigator.clipboard.writeText(colorCode).then(() => {
|
|
||||||
console.log('Color code copied to clipboard');
|
|
||||||
}).catch(err => {
|
|
||||||
console.error('Could not copy text: ', err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
textarea.value = colorCode;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
try {
|
|
||||||
document.execCommand('copy');
|
|
||||||
console.log('Color code copied to clipboard');
|
|
||||||
copyButton.innerHTML = '<span>Copied!</span>';
|
|
||||||
setTimeout(() => {
|
|
||||||
copyButton.innerHTML = '<span>Copy</span>';
|
|
||||||
}, 2000);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Could not copy text: ', err);
|
|
||||||
}
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
header('Access-Control-Allow-Origin: *');
|
|
||||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
|
||||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
||||||
header('X-Powered-By: SiliconPin Tools');
|
|
||||||
/**
|
|
||||||
* DNS A Record Lookup API
|
|
||||||
* Endpoint: /dns-tools-get-a-record
|
|
||||||
* Method: POST
|
|
||||||
* Content-Type: application/json
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// Response headers
|
|
||||||
// -------------------------------
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// Allow only POST
|
|
||||||
// -------------------------------
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
http_response_code(405);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Only POST method allowed'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// Read JSON body
|
|
||||||
// -------------------------------
|
|
||||||
$rawInput = file_get_contents('php://input');
|
|
||||||
$data = json_decode($rawInput, true);
|
|
||||||
|
|
||||||
$domain = $data['domain'] ?? '';
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// Domain validation
|
|
||||||
// -------------------------------
|
|
||||||
function validateDomain(string $domain): bool
|
|
||||||
{
|
|
||||||
return (bool) preg_match(
|
|
||||||
'/^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/',
|
|
||||||
$domain
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$domain || !validateDomain($domain)) {
|
|
||||||
http_response_code(400);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Invalid domain'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// DNS lookup (NO shell_exec)
|
|
||||||
// -------------------------------
|
|
||||||
$records = dns_get_record($domain, DNS_A);
|
|
||||||
$ips = [];
|
|
||||||
|
|
||||||
if ($records !== false) {
|
|
||||||
foreach ($records as $record) {
|
|
||||||
if (!empty($record['ip'])) {
|
|
||||||
$ips[] = $record['ip'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------
|
|
||||||
// Response
|
|
||||||
// -------------------------------
|
|
||||||
if (empty($ips)) {
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'domain' => $domain,
|
|
||||||
'message' => 'No A records found',
|
|
||||||
'ips' => []
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
'success' => true,
|
|
||||||
'domain' => $domain,
|
|
||||||
'ips' => $ips
|
|
||||||
]);
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* DNS MX Record Lookup API
|
|
||||||
* Endpoint: /dns-tools-get-mx-record
|
|
||||||
* Method: POST
|
|
||||||
* Content-Type: application/json
|
|
||||||
*/
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
|
|
||||||
// Allow only POST
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
http_response_code(405);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Only POST method allowed'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read JSON input
|
|
||||||
$input = json_decode(file_get_contents('php://input'), true);
|
|
||||||
$domain = $input['domain'] ?? '';
|
|
||||||
|
|
||||||
// Domain validation
|
|
||||||
function validateDomain(string $domain): bool
|
|
||||||
{
|
|
||||||
return (bool) preg_match(
|
|
||||||
'/^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/',
|
|
||||||
$domain
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$domain || !validateDomain($domain)) {
|
|
||||||
http_response_code(400);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Invalid domain'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch MX records
|
|
||||||
$records = dns_get_record($domain, DNS_MX);
|
|
||||||
$mxRecords = [];
|
|
||||||
|
|
||||||
if ($records !== false) {
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$mxRecords[] = [
|
|
||||||
'host' => $record['target'] ?? '',
|
|
||||||
'priority' => $record['pri'] ?? null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response
|
|
||||||
if (empty($mxRecords)) {
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'domain' => $domain,
|
|
||||||
'message' => 'No MX records found',
|
|
||||||
'records' => []
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
'success' => true,
|
|
||||||
'domain' => $domain,
|
|
||||||
'records' => $mxRecords
|
|
||||||
]);
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* DNS NS Record Lookup API
|
|
||||||
* Endpoint: /dns-tools-get-ns-record
|
|
||||||
* Method: POST
|
|
||||||
* Content-Type: application/json
|
|
||||||
*/
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
|
|
||||||
// Allow only POST requests
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
http_response_code(405);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Only POST method allowed'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read JSON body
|
|
||||||
$input = json_decode(file_get_contents('php://input'), true);
|
|
||||||
$domain = $input['domain'] ?? '';
|
|
||||||
|
|
||||||
// Domain validation
|
|
||||||
function validateDomain(string $domain): bool
|
|
||||||
{
|
|
||||||
return (bool) preg_match(
|
|
||||||
'/^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/',
|
|
||||||
$domain
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$domain || !validateDomain($domain)) {
|
|
||||||
http_response_code(400);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Invalid domain'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch NS records
|
|
||||||
$records = dns_get_record($domain, DNS_NS);
|
|
||||||
$nsRecords = [];
|
|
||||||
|
|
||||||
if ($records !== false) {
|
|
||||||
foreach ($records as $record) {
|
|
||||||
if (!empty($record['target'])) {
|
|
||||||
$nsRecords[] = $record['target'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response
|
|
||||||
if (empty($nsRecords)) {
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'domain' => $domain,
|
|
||||||
'message' => 'No NS records found',
|
|
||||||
'records' => []
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
'success' => true,
|
|
||||||
'domain' => $domain,
|
|
||||||
'records' => $nsRecords
|
|
||||||
]);
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
$isp = geoip_isp_by_name('www.example.com');
|
|
||||||
if ($isp) {
|
|
||||||
echo 'This host IP is from ISP: ' . $isp;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h2 class="diZBorderBottom">Get Current Location's Latitude & Longitude</h2>
|
|
||||||
<p class="diZTextJustify">The Geolocation Tool is a powerful and user-friendly web application designed to pinpoint your exact geographical location. With just a click, this tool leverages advanced geolocation technology to provide you with accurate latitude and longitude coordinates of your current position</p>
|
|
||||||
<div class="diZFlexColumn diZItemsCenter diZMaxW500 diZmxAuto diZmy20 toolsSection">
|
|
||||||
<p class="diZDisplayNone" id="copiedNotice"></p>
|
|
||||||
<div class="diZFlexRow diZItemsCenter diZFlexBetween">
|
|
||||||
<h2 class="" id="demo"></h2>
|
|
||||||
<span title="Click to copy Latitude & Longitude!" onclick="copyToClipboard()" class="diZCursorPointer"><img src="/assets/svg/copy.svg" /></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h2>Features:</h2>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Real-Time Location Tracking:</strong> Instantly fetches and displays your current latitude and longitude.</li>
|
|
||||||
<li><strong>User-Friendly Interface:</strong> Simple and intuitive design makes it easy for anyone to use.</li>
|
|
||||||
<li><strong>High Accuracy:</strong> Utilizes modern geolocation APIs to ensure precise location data.</li>
|
|
||||||
<li><strong>Privacy-Conscious:</strong> Only accesses your location when you allow it, ensuring your privacy is respected.</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const x = document.getElementById("demo");
|
|
||||||
const copiedNoticeSection = document.getElementById('copiedNotice');
|
|
||||||
|
|
||||||
function getLocation() {
|
|
||||||
if (navigator.geolocation) {
|
|
||||||
navigator.geolocation.getCurrentPosition(showPosition);
|
|
||||||
} else {
|
|
||||||
x.innerHTML = "Geolocation is not supported by this browser.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getLocation();
|
|
||||||
|
|
||||||
function showPosition(position) {
|
|
||||||
x.innerHTML = "Latitude: " + position.coords.latitude +
|
|
||||||
"<br>Longitude: " + position.coords.longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const copyText = document.getElementById("demo").innerText;
|
|
||||||
const textArea = document.createElement("textarea");
|
|
||||||
textArea.value = copyText;
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.select();
|
|
||||||
document.execCommand("copy");
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
setTimeout(() => {
|
|
||||||
copiedNoticeSection.style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
copiedNoticeSection.style.display = 'block';
|
|
||||||
copiedNoticeSection.innerHTML = 'Coordinates copied to clipboard!';
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Function to generate a random name
|
|
||||||
function generateRandomName($length = 6) {
|
|
||||||
$vowels = array('a', 'e', 'i', 'o', 'u');
|
|
||||||
$consonants = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z');
|
|
||||||
|
|
||||||
$name = '';
|
|
||||||
$is_vowel = mt_rand(0, 1);
|
|
||||||
for ($i = 0; $i < $length; $i++) {
|
|
||||||
$source = $is_vowel ? $vowels : $consonants;
|
|
||||||
$name .= $source[mt_rand(0, count($source) - 1)];
|
|
||||||
$is_vowel = !$is_vowel;
|
|
||||||
}
|
|
||||||
return ucfirst($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$randomFirstName = generateRandomName(mt_rand(4, 8));
|
|
||||||
$randomLastName = generateRandomName(mt_rand(4, 8));
|
|
||||||
?>
|
|
||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h2 class="diZBorderBottom">Get a Random Name</h2>
|
|
||||||
<div class="diZMaxW500 diZFlexColumn diZItemsCenter diZJustifyCenter diZmxAuto toolsSection diZmy20">
|
|
||||||
<span class="diZDisplayNone" id="copiedNoticeName">Copied to clipboard</span>
|
|
||||||
<div class="diZFlexRow diZItemsCenter diZJustifyCenter">
|
|
||||||
<h2 id="randomName"><?php echo $randomFirstName . ' ' . $randomLastName; ?></h2>
|
|
||||||
<span class="diZCursorPointer" onclick="copyNameToClipboard()"><img src="/assets/svg/copy.svg" alt="Copy to Clipboard"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="">
|
|
||||||
<h3>Random Name Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li class="diZTextJustify diZmt2">Generate random names for testing or placeholder purposes in applications or websites.</li>
|
|
||||||
<li class="diZTextJustify diZmt2">Use randomly generated names in mockups or design prototypes.</li>
|
|
||||||
<li class="diZTextJustify diZmt2">Create unique usernames or profile names in development environments.</li>
|
|
||||||
<li class="diZTextJustify diZmt2">Generate fictional character names for creative writing or gaming applications.</li>
|
|
||||||
<li class="diZTextJustify diZmt2">Provide random names for demo accounts or example data in presentations.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function copyNameToClipboard() {
|
|
||||||
var copyText = document.getElementById('randomName');
|
|
||||||
var textArea = document.createElement('textarea');
|
|
||||||
textArea.value = copyText.textContent.trim();
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
|
|
||||||
var copiedNotice = document.getElementById('copiedNoticeName');
|
|
||||||
copiedNotice.style.display = 'block';
|
|
||||||
setTimeout(function() {
|
|
||||||
copiedNotice.style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h2 class="diZBorderBottom">Random Unique Number Generator</h2>
|
|
||||||
<p class="diZTextJustify">This tool generates a random and unique number sequence every time it's called. It combines a random string of digits with a unique identifier based on the current microtime, ensuring that each generated number is both unpredictable and unique. This ensures that generated IDs do not conflict in the future. Use it for various applications where unique identifiers or random tokens are required, such as in cryptographic nonce generation, session identifiers, or unique transaction IDs.</p>
|
|
||||||
<div class="diZmy20">
|
|
||||||
<?php
|
|
||||||
function generateRandomUniqueNumber($length = 10) {
|
|
||||||
$randomNumber = '';
|
|
||||||
|
|
||||||
for ($i = 0; $i < $length; $i++) {
|
|
||||||
$randomNumber .= mt_rand(0, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append a unique identifier (based on microtime)
|
|
||||||
$uniqueId = uniqid();
|
|
||||||
$randomUniqueNumber = $randomNumber . $uniqueId;
|
|
||||||
|
|
||||||
return $randomUniqueNumber;
|
|
||||||
}
|
|
||||||
// Usage
|
|
||||||
$randomUniqueNumber = generateRandomUniqueNumber();
|
|
||||||
// echo $randomUniqueNumber;
|
|
||||||
?>
|
|
||||||
<div class="diZMaxW500 diZFlexColumn diZItemsCenter diZJustifyCenter diZmxAuto toolsSection">
|
|
||||||
<span class="diZDisplayNone" id="copiedNotice">Copied to clipboard</span>
|
|
||||||
<div class="diZFlexRow diZItemsCenter diZJustifyCenter">
|
|
||||||
<h2 id="randomNumber"><?php echo $randomUniqueNumber; ?></h2>
|
|
||||||
<span title="Click to copy Siliconid!" onclick="copyToClipboard()" class="diZCursorPointer"><img src="/assets/svg/copy.svg" /></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li class="diZTextJustify"><strong>Order and Transaction IDs:</strong> Generate unique identifiers for orders and transactions in e-commerce platforms to ensure each transaction is uniquely identified and tracked.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Session IDs:</strong> Use unique numbers as session identifiers in web applications to manage user sessions securely and uniquely.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Cryptographic Nonces:</strong> Generate random tokens for cryptographic nonces in security-sensitive operations to prevent replay attacks and ensure message integrity.</li>
|
|
||||||
<li class="diZTextJustify"><strong>API Tokens:</strong> Create unique tokens for API authentication and authorization purposes, ensuring secure and verifiable access to APIs.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Coupon and Voucher Codes:</strong> Generate unique codes for promotional coupons and vouchers to track redemptions and prevent duplication.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Database Keys:</strong> Generate unique primary keys or identifiers for database records to ensure data integrity and efficient data retrieval.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Logging and Tracking:</strong> Use unique numbers as tracking IDs in logging systems to uniquely identify and trace events or actions within applications.</li>
|
|
||||||
<li class="diZTextJustify"><strong>Password Reset Tokens:</strong> Generate unique tokens for password reset links sent via email to securely verify and authorize password changes.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function copyToClipboard() {
|
|
||||||
var copyText = document.getElementById('randomNumber');
|
|
||||||
var textArea = document.createElement('textarea');
|
|
||||||
textArea.value = copyText.textContent.trim();
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textArea); //copiedNotice
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById('copiedNotice').style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
document.getElementById('copiedNotice').style.display = 'block';
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<div class="diZContainer diZmxAuto">
|
|
||||||
<h1 class="diZBorderBottom">HEX to RGB Converter</h1>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection diZmy20 diZPadding15px">
|
|
||||||
<label for="hex">HEX Color:</label><br><br>
|
|
||||||
<input style="width: 96%;" onchange="visibleColor();" type="text" id="hex" value="#" pattern="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" required ><br>
|
|
||||||
<br>
|
|
||||||
<div id="result"></div><br>
|
|
||||||
<div class="diZFlexRow">
|
|
||||||
<button id="convert-button" onclick="convertHexToRgb()"><span>Convert</span></button>
|
|
||||||
<button id="copyButton" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function hexToRgb(hex) {
|
|
||||||
hex = hex.replace(/^#/, '');
|
|
||||||
if (hex.length === 3) {
|
|
||||||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
||||||
}
|
|
||||||
var bigint = parseInt(hex, 16);
|
|
||||||
var r = (bigint >> 16) & 255;
|
|
||||||
var g = (bigint >> 8) & 255;
|
|
||||||
var b = bigint & 255;
|
|
||||||
return [r, g, b];
|
|
||||||
}
|
|
||||||
function visibleColor(){
|
|
||||||
var hexColorCode = document.getElementById('hex').value;
|
|
||||||
document.getElementById('convert-button').style.backgroundColor = hexColorCode;
|
|
||||||
}
|
|
||||||
function convertHexToRgb() {
|
|
||||||
var hexColor = document.getElementById('hex').value;
|
|
||||||
var rgbArray = hexToRgb(hexColor);
|
|
||||||
var red = rgbArray[0];
|
|
||||||
var green = rgbArray[1];
|
|
||||||
var blue = rgbArray[2];
|
|
||||||
|
|
||||||
document.getElementById('result').textContent = "HEX " + hexColor + " is equivalent to RGB(" + red + ", " + green + ", " + blue + ")";
|
|
||||||
|
|
||||||
document.getElementById('copyButton').style.display = 'inline-block';
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
var rgbText = document.getElementById('result').textContent.split('equivalent to ')[1];
|
|
||||||
var textarea = document.createElement('textarea');
|
|
||||||
textarea.value = rgbText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'RGB values copied successfully';
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy4">
|
|
||||||
<h1 class="diZBorderBottom">HTML Remover</h1>
|
|
||||||
<p class="diZTextJustify">The HTML Remover tool helps you clean text by removing all HTML tags, leaving only plain text. It's perfect for extracting content from HTML code without any formatting.</p>
|
|
||||||
<div class="diZFlexColumn diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
||||||
<div class="diZmt2 diZFlexColumn">
|
|
||||||
<label for="htmlInput">Input Text with HTML:</label>
|
|
||||||
<textarea class="diZTextAreaResizeNone" rows="10" id="htmlInput" placeholder="Paste your text with html here..."></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZItemsCenter">
|
|
||||||
<button class="diZmt2 " onclick="cleanHTML()"><span>Remove</span></button>
|
|
||||||
</div>
|
|
||||||
<div class="diZmt2 diZFlexColumn">
|
|
||||||
<label for="cleanedHTML">Cleaned Text:</label>
|
|
||||||
<textarea class="diZTextAreaResizeNone" rows="10" id="cleanedHTML" readonly placeholder="Cleaned Text will appear here..."></textarea>
|
|
||||||
</div>
|
|
||||||
<p class="diZDisplayNone" id="copied-notice"></p>
|
|
||||||
<div class="diZFlexColumn diZItemsCenter">
|
|
||||||
<button class="diZmt2 " onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<!-- diZwFit diZJustifyCenter diZItemsCenter -->
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Text with HTML:</strong> Paste your desired text with HTML into the text area provided.</li>
|
|
||||||
<li><strong>Remove HTML:</strong> Click the "Remove" button to clean the text, stripping out all HTML tags.</li>
|
|
||||||
<li><strong>View Cleaned Text:</strong> The cleaned, plain text will appear in the output text area below.</li>
|
|
||||||
<li><strong>Copy Cleaned Text:</strong> Click the "Copy" button to copy the cleaned text to your clipboard.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Effortlessly removes all HTML tags from the input text.</li>
|
|
||||||
<li>Provides a user-friendly interface for inputting and viewing text.</li>
|
|
||||||
<li>Includes a copy function to quickly copy the cleaned text to your clipboard.</li>
|
|
||||||
<li>Displays a notification when the text is successfully copied to the clipboard.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Writers and editors extracting plain text content from HTML-formatted documents.</li>
|
|
||||||
<li>Developers cleaning up text before using it in applications or databases.</li>
|
|
||||||
<li>Content creators preparing text for use in plain text editors or word processors.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function cleanHTML() {
|
|
||||||
const inputHTML = document.getElementById("htmlInput").value;
|
|
||||||
|
|
||||||
// Create a temporary element to hold the input HTML
|
|
||||||
const tempDiv = document.createElement("div");
|
|
||||||
tempDiv.innerHTML = inputHTML;
|
|
||||||
|
|
||||||
// Remove all HTML tags
|
|
||||||
const plainText = tempDiv.textContent || tempDiv.innerText || "";
|
|
||||||
|
|
||||||
document.getElementById("cleanedHTML").value = plainText;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const cleanedHTML = document.getElementById("cleanedHTML").value;
|
|
||||||
navigator.clipboard.writeText(cleanedHTML)
|
|
||||||
.then(() => {
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'Text copied to clipboard!';
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById('copied-notice').style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
// console.error('Failed to copy: ', err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto ">
|
|
||||||
<h1 class="diZBorderBottom">HTML Decoder</h1>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection diZmy20">
|
|
||||||
<div class="diZFlexColumn diZJustifyCenter">
|
|
||||||
<textarea class="diZScrollBarNone" rows="10" id="encodedText" placeholder="Enter encoded HTML here..."></textarea>
|
|
||||||
<div></div>
|
|
||||||
<button class="diZmt4 diZmxAuto" onclick="decodeHtml()"><span>Decode</span></button>
|
|
||||||
<textarea class="diZmt4 diZScrollBarNone" rows="10" id="decodedText" readonly placeholder="Decoded HTML will appear here..."></textarea>
|
|
||||||
<button class="diZmt4 diZmxAuto" id="copyButton" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function decodeHtml() {
|
|
||||||
const encodedInput = document.getElementById('encodedText').value;
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
textarea.innerHTML = encodedInput;
|
|
||||||
const decoded = textarea.value;
|
|
||||||
document.getElementById('decodedText').value = decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const decodedText = document.getElementById('decodedText');
|
|
||||||
decodedText.select();
|
|
||||||
decodedText.setSelectionRange(0, 99999); // For mobile devices
|
|
||||||
document.execCommand('copy');
|
|
||||||
let copyButtons = document.getElementById('copyButton');
|
|
||||||
copyButtons.innerHTML = 'Copied to clipboard!';
|
|
||||||
setTimeout(() => {
|
|
||||||
copyButtons.innerHTML = 'Copy';
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// alert('Decoded HTML copied to clipboard!');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once('.htac_header.php');
|
|
||||||
?>
|
|
||||||
<section class="diZContainer diZmxAuto diZmy20">
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection">
|
|
||||||
<h1>HTML Encoder</h1>
|
|
||||||
<div class="diZFlexColumn">
|
|
||||||
<textarea class="diZScrollBarNone" rows="10" id="inputText" placeholder="Enter HTML code here..."></textarea>
|
|
||||||
|
|
||||||
<button class="diZmt4 diZmxAuto" onclick="encodeHtml()"><span>Encode</span></button>
|
|
||||||
|
|
||||||
<textarea class="diZmt4 diZScrollBarNone" rows="10" id="outputText" readonly placeholder="Encoded HTML will appear here..."></textarea>
|
|
||||||
|
|
||||||
<button class="diZmt4 diZmxAuto" id="copyButton" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function encodeHtml() {
|
|
||||||
const input = document.getElementById('inputText').value;
|
|
||||||
const encoded = input.replace(/[\u00A0-\u9999<>&'"]/gim, function(i) {
|
|
||||||
return '&#' + i.charCodeAt(0) + ';';
|
|
||||||
});
|
|
||||||
document.getElementById('outputText').value = encoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const encodedText = document.getElementById('outputText');
|
|
||||||
encodedText.select();
|
|
||||||
encodedText.setSelectionRange(0, 99999); // For mobile devices
|
|
||||||
document.execCommand('copy');
|
|
||||||
let copyButtons = document.getElementById('copyButton');
|
|
||||||
copyButtons.innerHTML = 'Copied to clipboard!';
|
|
||||||
setTimeout(() => {
|
|
||||||
copyButtons.innerHTML = 'Copy';
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// alert('Decoded HTML copied to clipboard!');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto ">
|
|
||||||
<h1 class="diZBorderBottom">Image Compression Tool</h1>
|
|
||||||
<div class="toolsSection diZMaxW600 diZmxAuto diZmy20">
|
|
||||||
<div>
|
|
||||||
<input type="file" id="imageInput" accept="image/*">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="qualityInput">Compression Quality:</label>
|
|
||||||
<div class="diZFlexRow">
|
|
||||||
<input class="diZw100" type="range" id="qualityInput" min="1" max="100" step="1" value="10" />
|
|
||||||
<span id="qualityValue">10%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="image-preview">
|
|
||||||
<img id="preview" src="" alt="" style="width: 100%;" />
|
|
||||||
<span id="imageSize" class="image-size"></span>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexBetween">
|
|
||||||
<button class="comp-button" onclick="compressImage()"><span>Compress Image</span></button>
|
|
||||||
<a class="diZDisplayNone diZButtonDefault" id="downloadLink" href="#" download="compressed_image.jpg"><span>Download Compressed Image</span></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function compressImage() {
|
|
||||||
const fileInput = document.getElementById('imageInput');
|
|
||||||
const file = fileInput.files[0];
|
|
||||||
|
|
||||||
if (!file) {
|
|
||||||
alert('Please select an image file.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onload = function(event) {
|
|
||||||
const image = new Image();
|
|
||||||
image.src = event.target.result;
|
|
||||||
|
|
||||||
image.onload = function() {
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
|
|
||||||
canvas.width = image.width;
|
|
||||||
canvas.height = image.height;
|
|
||||||
console.log(image.width)
|
|
||||||
ctx.drawImage(image, 0, 0);
|
|
||||||
|
|
||||||
const qualityInput = document.getElementById('qualityInput');
|
|
||||||
const qualityValue = parseFloat(qualityInput.value) / 100; // Normalize quality value to range 0-1
|
|
||||||
|
|
||||||
canvas.toBlob(function(blob) {
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const preview = document.getElementById('preview');
|
|
||||||
const downloadLink = document.getElementById('downloadLink');
|
|
||||||
|
|
||||||
preview.src = url;
|
|
||||||
downloadLink.href = url;
|
|
||||||
downloadLink.style.display = 'flex';
|
|
||||||
|
|
||||||
const imageSizeSpan = document.getElementById('imageSize');
|
|
||||||
const compressedSize = (blob.size / 1024).toFixed(2); // Convert bytes to kilobytes and round to 2 decimal places
|
|
||||||
imageSizeSpan.textContent = `Compressed Image Size: ${compressedSize} KB`;
|
|
||||||
}, 'image/jpeg', qualityValue); // Pass normalized quality value to toBlob
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('qualityInput').addEventListener('input', function() {
|
|
||||||
document.getElementById('qualityValue').textContent = this.value + "%";
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Convert Image to Base64</h2>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection diZmy20">
|
|
||||||
<div class="diZFlexColumn ">
|
|
||||||
<input type="file" class="image-input diZmt2" accept="image/*">
|
|
||||||
<textarea rows="10" class="base64-textarea diZmt2" readonly></textarea>
|
|
||||||
<p class="diZDisplayNone diZTextCenter diZmt2" id="copied-notice"></p>
|
|
||||||
<div class="diZmt2" id="preview" ></div>
|
|
||||||
<button class="copy-button diZmt2 diZmxAuto"><span>Copy Base64</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.querySelector('.image-input').addEventListener('change', function() {
|
|
||||||
var file = this.files[0];
|
|
||||||
if (file) {
|
|
||||||
var reader = new FileReader();
|
|
||||||
reader.onload = function(e) {
|
|
||||||
var base64 = e.target.result;
|
|
||||||
var img = document.createElement('img');
|
|
||||||
img.src = base64;
|
|
||||||
img.style.width = '100%';
|
|
||||||
document.getElementById('preview').innerHTML = '';
|
|
||||||
document.getElementById('preview').appendChild(img);
|
|
||||||
document.querySelector('.base64-textarea').value = base64;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector('.copy-button').addEventListener('click', function() {
|
|
||||||
var base64TextArea = document.querySelector('.base64-textarea');
|
|
||||||
base64TextArea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'Base64 copied to clipboard!';
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
|
|
||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h1 class="diZBorderBottom">JSON Formatter</h1>
|
|
||||||
<div class="diZFlexRowCol">
|
|
||||||
<div class="diZw100 jsonCustomHeight diZFlexColumn diZJsonInputBorder diZBorderRadius5px diZmr2">
|
|
||||||
<textarea oninput="parseJSON()" id="jsonInput" class="diZJsonInput diZScrollBarNone" rows="40" placeholder="Enter JSON here"></textarea><br>
|
|
||||||
</div>
|
|
||||||
<div class="diZw100 jsonCustomHeight diZFlexColumn diZJsonInputBorder diZBorderRadius5px">
|
|
||||||
<div id="output" class="diZJsonViewer"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="diZFloatRight diZFlexRow diZJustifyCenter diZItemsCenter">
|
|
||||||
<p class=" diZJsonKey" id="countArray">Array Length: 0</p>
|
|
||||||
<button class="diZmt4 diZmb4 diZml2" onclick="copyToClipboard()"><span>Copy JSON</span></button>
|
|
||||||
<button class="diZmt4 diZmb4 diZml2" onclick="downloadJsonData()"><span>Download JSON</span></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function parseJSON() {
|
|
||||||
const input = document.getElementById('jsonInput').value;
|
|
||||||
const outputElement = document.getElementById('output');
|
|
||||||
outputElement.innerHTML = ''; // Clear previous output
|
|
||||||
|
|
||||||
try {
|
|
||||||
const parsedData = JSON.parse(input);
|
|
||||||
outputElement.appendChild(createTreeView(parsedData));
|
|
||||||
let totalObjects = parsedData.length;
|
|
||||||
document.getElementById('countArray').innerHTML = 'Array Length: '+ totalObjects;
|
|
||||||
} catch (error) {
|
|
||||||
outputElement.textContent = 'Error parsing JSON: ' + error.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createTreeView(data) {
|
|
||||||
const container = document.createElement('div');
|
|
||||||
|
|
||||||
if (typeof data === 'object' && data !== null) {
|
|
||||||
const ul = document.createElement('ul');
|
|
||||||
ul.className = 'diZJsonUl';
|
|
||||||
for (const key in data) {
|
|
||||||
if (data.hasOwnProperty(key)) {
|
|
||||||
const li = document.createElement('li');
|
|
||||||
li.className = 'diZJsonLi';
|
|
||||||
const keySpan = document.createElement('span');
|
|
||||||
keySpan.className = 'diZJsonKey';
|
|
||||||
keySpan.textContent = `${key}: `;
|
|
||||||
|
|
||||||
const valueSpan = document.createElement('span');
|
|
||||||
if (typeof data[key] === 'object' && data[key] !== null) {
|
|
||||||
const childContainer = createTreeView(data[key]);
|
|
||||||
li.appendChild(keySpan);
|
|
||||||
li.appendChild(childContainer);
|
|
||||||
} else {
|
|
||||||
if (typeof data[key] === 'string') {
|
|
||||||
valueSpan.className = 'diZJsonString';
|
|
||||||
valueSpan.textContent = `"${data[key]}"`;
|
|
||||||
} else {
|
|
||||||
valueSpan.className = 'diZJsonValue';
|
|
||||||
valueSpan.textContent = data[key];
|
|
||||||
}
|
|
||||||
li.appendChild(keySpan);
|
|
||||||
li.appendChild(valueSpan);
|
|
||||||
}
|
|
||||||
ul.appendChild(li);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
container.appendChild(ul);
|
|
||||||
} else {
|
|
||||||
const span = document.createElement('span');
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
span.className = 'diZJsonString';
|
|
||||||
span.textContent = `"${data}"`;
|
|
||||||
} else {
|
|
||||||
span.className = 'diZJsonValue';
|
|
||||||
span.textContent = data;
|
|
||||||
}
|
|
||||||
container.appendChild(span);
|
|
||||||
}
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const input = document.getElementById('jsonInput').value;
|
|
||||||
navigator.clipboard.writeText(input).then(() => {
|
|
||||||
console.log('JSON copied to clipboard!');
|
|
||||||
}, (err) => {
|
|
||||||
console.log('Failed to copy JSON: ', err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function downloadJsonData() {
|
|
||||||
const jsonData = document.getElementById('jsonInput').value;
|
|
||||||
let jsonObject;
|
|
||||||
try {
|
|
||||||
jsonObject = JSON.parse(jsonData);
|
|
||||||
} catch (error) {
|
|
||||||
console.log('Invalid JSON data');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const jsonString = JSON.stringify(jsonObject, null, 2);
|
|
||||||
const blob = new Blob([jsonString], { type: 'application/json' });
|
|
||||||
const downloadLink = document.createElement('a');
|
|
||||||
downloadLink.href = URL.createObjectURL(blob);
|
|
||||||
downloadLink.download = 'json-data.json';
|
|
||||||
downloadLink.click();
|
|
||||||
URL.revokeObjectURL(downloadLink.href);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Case Converter</h2>
|
|
||||||
<p class="diZTextJustify">The Letter Case Converter tool allows you to effortlessly change the case of your text to Uppercase, Lowercase, or Title Case. Whether you're writing a document, formatting code, or preparing content for publication, this tool provides a quick and easy way to ensure your text is in the desired case format.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection diZmt20 ">
|
|
||||||
<form class="diZFlexColumn">
|
|
||||||
<label class="" for="inputString">Input Text:</label>
|
|
||||||
<textarea id="inputString" class="diZTextAreaResizeNone" name="inputString" rows="8" oninput="convertCase()"></textarea>
|
|
||||||
<div class="diZFlexBetween diZmt4">
|
|
||||||
<div class="caseOptionButton diZButtonDefault" onclick="setActive(this)" data-case="uppercase"><span>Uppercase</span></div>
|
|
||||||
<div class="caseOptionButton diZButtonDefault" onclick="setActive(this)" data-case="lowercase"><span>Lowercase</span></div>
|
|
||||||
<div class="caseOptionButton diZButtonDefault" onclick="setActive(this)" data-case="titlecase"><span>Titlecase</span></div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div class="diZFlexColumn">
|
|
||||||
<textarea id="result" rows="7" readonly class="result-cc diZTextAreaResizeNone diZmt4"></textarea>
|
|
||||||
<p class="diZDisplayNone diZmt4" id="copied-notice"></p>
|
|
||||||
<button type="button" class="copy-button-cc diZmt4 diZmxAuto" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="diZmb20">
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Text:</strong> Input your desired text into the text area provided.</li>
|
|
||||||
<li><strong>Choose Case Conversion:</strong> Select the type of conversion you want: Uppercase, Lowercase, or Title Case.</li>
|
|
||||||
<!-- <li><strong>Convert Text:</strong> Click the "Convert" button to apply the selected case transformation to your text.</li> -->
|
|
||||||
<li><strong>Copy Converted Text:</strong> Once converted, the text will appear in the output text area. Click the "Copy" button to copy it to your clipboard.</li>
|
|
||||||
<li><strong>Paste and Use:</strong> Paste the copied text into your document, email, or any other text field where you need the transformed text.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Converts text to uppercase.</li>
|
|
||||||
<li>Converts text to lowercase.</li>
|
|
||||||
<li>Converts text to title case.</li>
|
|
||||||
<li>Provides instant feedback with a "Text copied to clipboard!" notification upon copying.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Writers ensuring consistent capitalization in their documents.</li>
|
|
||||||
<li>Developers needing text transformations for various programming tasks.</li>
|
|
||||||
<li>Students formatting essays and assignments according to specific case requirements.</li>
|
|
||||||
<li>Content creators adjusting the text case for social media posts, emails, or presentations.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function convertCase() {
|
|
||||||
var inputString = document.getElementById("inputString").value;
|
|
||||||
var targetCase = document.querySelector('.caseOptionButton.active').getAttribute('data-case');
|
|
||||||
var result = document.getElementById("result");
|
|
||||||
|
|
||||||
if (inputString.trim() === "") {
|
|
||||||
result.value = "Please enter a string.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetCase === 'uppercase') {
|
|
||||||
result.value = inputString.toUpperCase();
|
|
||||||
} else if (targetCase === 'lowercase') {
|
|
||||||
result.value = inputString.toLowerCase();
|
|
||||||
} else if (targetCase === 'titlecase') {
|
|
||||||
result.value = inputString.replace(/\w\S*/g, function (txt) {
|
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
result.value = "Invalid target case specified.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setActive(button) {
|
|
||||||
var buttons = document.querySelectorAll('.caseOptionButton');
|
|
||||||
buttons.forEach(function(btn) {
|
|
||||||
btn.classList.remove('active');
|
|
||||||
});
|
|
||||||
button.classList.add('active');
|
|
||||||
|
|
||||||
convertCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
var result = document.getElementById("result");
|
|
||||||
var range = document.createRange();
|
|
||||||
range.selectNode(result);
|
|
||||||
window.getSelection().removeAllRanges();
|
|
||||||
window.getSelection().addRange(range);
|
|
||||||
document.execCommand("copy");
|
|
||||||
window.getSelection().removeAllRanges();
|
|
||||||
// alert("Copied to clipboard!");
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById('copied-notice').style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'Copied to clipboard!';
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
.active{
|
|
||||||
border: 2px solid #4caf50;
|
|
||||||
background: transparent;
|
|
||||||
color: #4caf50;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
|
|
||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h1 class="diZBorderBottom">Text Counter</h1>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZmyAuto diZFlexColumn toolsSection diZmt20">
|
|
||||||
<label for="inputText">Enter your text:</label><br>
|
|
||||||
<textarea class="" rows="10" id="inputText" placeholder="Type your text here..." oninput="countTextMetrics()" style="resize: vertical;"></textarea>
|
|
||||||
<div>
|
|
||||||
<p>Total letters: <span id="letterCount">0</span></p>
|
|
||||||
<p>Total words: <span id="wordCount">0</span></p>
|
|
||||||
<p>Total sentences: <span id="sentenceCount">0</span></p>
|
|
||||||
<p>Total paragraphs: <span id="paragraphCount">0</span></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section class="diZContainer diZmxAuto diZmb20">
|
|
||||||
<div>
|
|
||||||
<h2 class="diZBorderBottom">Content Limitations</h2>
|
|
||||||
<table class="diZw70 diZmxAuto">
|
|
||||||
<tr>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Name</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Min/Max</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Limit</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Type</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Meta Title</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">55</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Meta Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">160</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Google Ideal Post Content</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Min</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">300</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Word</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Instagram Captions/Comments</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">2200</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Twitter Post</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">280</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Twitter Username</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">20</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Wall Post (Truncation)</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">477</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Wall Post (All)</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">63206</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Comment</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">8000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Page Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">255</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Username</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">50</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Messenger Message</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">20000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">YouTube Video Title</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">70</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">YouTube Video Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">5000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Snapchat Caption</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">250</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Pinterest Pin Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">500</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function countTextMetrics() {
|
|
||||||
const text = document.getElementById('inputText').value;
|
|
||||||
|
|
||||||
// Count letters
|
|
||||||
const letterCount = text.replace(/[^a-zA-Z]/g, '').length;
|
|
||||||
document.getElementById('letterCount').textContent = letterCount;
|
|
||||||
|
|
||||||
// Count words
|
|
||||||
const words = text.split(/\s+/).filter(word => word.length > 0);
|
|
||||||
const wordCount = words.length;
|
|
||||||
document.getElementById('wordCount').textContent = wordCount;
|
|
||||||
|
|
||||||
// Count sentences
|
|
||||||
const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);
|
|
||||||
const sentenceCount = sentences.length;
|
|
||||||
document.getElementById('sentenceCount').textContent = sentenceCount;
|
|
||||||
|
|
||||||
// Count paragraphs
|
|
||||||
const paragraphs = text.split(/\n\n+/).filter(paragraph => paragraph.trim().length > 0);
|
|
||||||
const paragraphCount = paragraphs.length;
|
|
||||||
document.getElementById('paragraphCount').textContent = paragraphCount;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
header('Access-Control-Allow-Origin: *');
|
|
||||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
|
||||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
|
||||||
header('X-Powered-By: SiliconPin Tools');
|
|
||||||
require_once __DIR__ . '/../.hta_lib/maxmind-db-reader/autoload.php';
|
|
||||||
|
|
||||||
use MaxMind\Db\Reader;
|
|
||||||
|
|
||||||
function respond($status, $data = null, $error = null)
|
|
||||||
{
|
|
||||||
echo json_encode([
|
|
||||||
'success' => $status,
|
|
||||||
'data' => $data,
|
|
||||||
'error' => $error
|
|
||||||
], JSON_PRETTY_PRINT);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($_GET['ip']) || trim($_GET['ip']) === '') {
|
|
||||||
respond(false, null, 'IP parameter is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ip = trim($_GET['ip']);
|
|
||||||
|
|
||||||
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
|
|
||||||
respond(false, null, 'Invalid IP address');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cityReader = new Reader(__DIR__ . '/../.hta_lib/data/GeoLite2-City.mmdb');
|
|
||||||
$asnReader = new Reader(__DIR__ . '/../.hta_lib/data/GeoLite2-ASN.mmdb');
|
|
||||||
|
|
||||||
$cityData = $cityReader->get($ip);
|
|
||||||
$asnData = $asnReader->get($ip);
|
|
||||||
|
|
||||||
$cityReader->close();
|
|
||||||
$asnReader->close();
|
|
||||||
|
|
||||||
$response = [
|
|
||||||
'ip' => $ip,
|
|
||||||
|
|
||||||
'continent' => [
|
|
||||||
'name' => $cityData['continent']['names']['en'] ?? null,
|
|
||||||
'code' => $cityData['continent']['code'] ?? null
|
|
||||||
],
|
|
||||||
|
|
||||||
'country' => [
|
|
||||||
'name' => $cityData['country']['names']['en'] ?? null,
|
|
||||||
'code' => $cityData['country']['iso_code'] ?? null
|
|
||||||
],
|
|
||||||
|
|
||||||
'state' => [
|
|
||||||
'name' => $cityData['subdivisions'][0]['names']['en'] ?? null,
|
|
||||||
'code' => $cityData['subdivisions'][0]['iso_code'] ?? null
|
|
||||||
],
|
|
||||||
|
|
||||||
'city' => $cityData['city']['names']['en'] ?? null,
|
|
||||||
|
|
||||||
'timezone' => $cityData['location']['time_zone'] ?? null,
|
|
||||||
|
|
||||||
'location' => [
|
|
||||||
'latitude' => $cityData['location']['latitude'] ?? null,
|
|
||||||
'longitude' => $cityData['location']['longitude'] ?? null
|
|
||||||
],
|
|
||||||
|
|
||||||
'postal_code' => $cityData['postal']['code'] ?? null,
|
|
||||||
|
|
||||||
'asn' => [
|
|
||||||
'number' => $asnData['autonomous_system_number'] ?? null,
|
|
||||||
'org' => $asnData['autonomous_system_organization'] ?? null
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$anycastASN = [15169, 13335, 36692];
|
|
||||||
$response['is_anycast'] = in_array($response['asn']['number'], $anycastASN);
|
|
||||||
$response['note'] = $response['is_anycast']
|
|
||||||
? 'Anycast IP detected. Location may vary.'
|
|
||||||
: 'IP-based location is approximate.';
|
|
||||||
|
|
||||||
respond(true, $response);
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
respond(false, null, $e->getMessage());
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once ('.hta_config/db_config.php');
|
|
||||||
?>
|
|
||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h2 class="diZBorderBottom">MD5 Decryption</h2>
|
|
||||||
<p class="diZTextJustify">The MD5 Decryption Tool is designed to help you decrypt MD5 hashes. It searches a pre-existing database for the original text corresponding to a given MD5 hash and retrieves it if available. This tool is especially useful for developers and security professionals who need to quickly look up the original value of an MD5 hash.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto toolsSection diZmy20">
|
|
||||||
<?php
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
try {
|
|
||||||
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
||||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
$stmt = $db->prepare("SELECT * FROM md5_data WHERE md5 = :md5");
|
|
||||||
$stmt->bindParam(':md5', $_POST["md5-hash"]);
|
|
||||||
$stmt->execute();
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if ($result) {
|
|
||||||
echo ' <div class="">
|
|
||||||
<p>Given MD5 Vlue: </p>
|
|
||||||
<p class="diZDisplayNone" id="copied-notice"></p>
|
|
||||||
<div class="diZFlexColumn">
|
|
||||||
<textarea class="diZTextAreaResizeNone" rows="8" id="output" readonly>'.$result['value'].'</textarea><br>
|
|
||||||
<button class="diZmxAuto" id="copyButton" onclick="copyOutputText()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>';
|
|
||||||
echo '
|
|
||||||
<script>
|
|
||||||
function copyOutputText() {
|
|
||||||
const outputText = document.getElementById(\'output\').value;
|
|
||||||
const textarea = document.createElement(\'textarea\');
|
|
||||||
textarea.value = outputText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand(\'copy\');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
document.getElementById(\'copied-notice\').style.display = \'block\';
|
|
||||||
document.getElementById(\'copied-notice\').innerHTML = \'MD5 value copied to clipboard!\';
|
|
||||||
}
|
|
||||||
</script>';
|
|
||||||
} else {
|
|
||||||
echo '<div>
|
|
||||||
<div>
|
|
||||||
<p>No data found for the given MD5 hash </p>
|
|
||||||
<div>
|
|
||||||
<button class="" id="" onclick="tryAgain()">Try Again</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>';
|
|
||||||
echo ' <script>
|
|
||||||
function tryAgain() {
|
|
||||||
window.location.href="/tools/md5-decryption";
|
|
||||||
}
|
|
||||||
</script>' ;
|
|
||||||
// echo json_encode(array('success' => false, 'message' => 'No data found for the given MD5 hash'));
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
echo ' <form method="post" action="" class="diZFlexColumn">
|
|
||||||
<label for="md5-hash" class="custom-label">Enter MD5 Hash:</label><br>
|
|
||||||
<textarea id="md5-hash" name="md5-hash" class="diZTextAreaResizeNone" rows="8"></textarea><br>
|
|
||||||
<button class="diZmxAuto" type="submit"><span>Convert MD5</span></button>
|
|
||||||
</form>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter MD5 Hash:</strong> Input the MD5 hash you want to decrypt into the provided text area.</li>
|
|
||||||
<li><strong>Decrypt MD5:</strong> Click the "Convert MD5" button to initiate the search for the corresponding value in the database.</li>
|
|
||||||
<li><strong>View and Copy Result:</strong> If a matching value is found, it will be displayed in the output area. Click the "Copy" button to copy the result to your clipboard.</li>
|
|
||||||
<li><strong>Try Again:</strong> If no matching value is found, click the "Try Again" button to search for another MD5 hash.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Simple and user-friendly interface for easy MD5 hash decryption.</li>
|
|
||||||
<li>Instantly displays the original text if found in the database.</li>
|
|
||||||
<li>Copy functionality to quickly copy the decrypted text to your clipboard.</li>
|
|
||||||
<li>Notification message to indicate successful copying of the decrypted text.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Developers verifying the integrity of files by comparing original text and its MD5 hash.</li>
|
|
||||||
<li>Security professionals analyzing hashed data to check for common vulnerabilities.</li>
|
|
||||||
<li>Researchers decrypting MD5 hashes for data analysis purposes.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
// require_once ('.hta_config/siliconpin_sp.php');
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
|
|
||||||
$md5_hash = md5($_POST["md5-text"]);
|
|
||||||
try {
|
|
||||||
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
||||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
$stmt = $db->prepare("INSERT INTO md5_data (md5, value) VALUES (:md5, :value)");
|
|
||||||
$stmt->bindParam(':md5', $md5_hash);
|
|
||||||
$stmt->bindParam(':value', $_POST["md5-text"]);
|
|
||||||
$stmt->execute();
|
|
||||||
echo ' <div class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Generate MD5 Hash</h2>
|
|
||||||
<p>The MD5 Hash Generator tool allows you to quickly and easily generate an MD5 hash from any text input. This is useful for creating checksums, storing passwords securely, or any other application where a unique hash representation of your data is needed.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
||||||
<div class="diZFlexColumn diZJustifyCenter ">
|
|
||||||
<div>
|
|
||||||
<p>Converted MD5: </p>
|
|
||||||
<p id="copied-notice"></p>
|
|
||||||
<div class="diZFlexColumn">
|
|
||||||
<input id="output" type="text" readonly value="'.$md5_hash.'" /><br>
|
|
||||||
<button class="diZmxAuto" id="copyButton" onclick="copyOutputText()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>';
|
|
||||||
echo '
|
|
||||||
<script>
|
|
||||||
function copyOutputText() {
|
|
||||||
const outputText = document.getElementById(\'output\').value;
|
|
||||||
const textarea = document.createElement(\'textarea\');
|
|
||||||
textarea.value = outputText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand(\'copy\');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
document.getElementById(\'copied-notice\').style.display = \'block\';
|
|
||||||
document.getElementById(\'copied-notice\').innerHTML = \'MD5 copied to clipboard!\';
|
|
||||||
}
|
|
||||||
</script>';
|
|
||||||
// echo json_encode(array('success' => true, 'message' => 'Data inserted successfully'));
|
|
||||||
// echo '<script>window.location.href="/admin/add-content";</script>';
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
echo '<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Generate MD5 Hash</h2>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
||||||
<form method="post" class="diZFlexColumn diZJustifyCenter "><br>
|
|
||||||
<label for="md5-text" class="">Enter Text Convert to MD5:</label><br>
|
|
||||||
<textarea name="md5-text" id="md5-text" rows="10"></textarea><br>
|
|
||||||
<button class="diZmxAuto" type="submit"><span>Generate MD5 Hash</span></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</section>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="diZContainer diZmxAuto">
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Text:</strong> Input your desired text into the text area provided.</li>
|
|
||||||
<li><strong>Generate MD5 Hash:</strong> Click the "Generate MD5 Hash" button to convert the text into an MD5 hash.</li>
|
|
||||||
<li><strong>Copy Hash:</strong> Once generated, the hash will appear in the output text area. Click the "Copy" button to copy it to your clipboard.</li>
|
|
||||||
<li><strong>Paste and Use:</strong> Paste the copied hash directly into your application, database, or any other place where you need an MD5 hash.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Generates a unique MD5 hash from any input text.</li>
|
|
||||||
<li>Displays the generated hash in a read-only text area for easy copying.</li>
|
|
||||||
<li>Provides a "Copy" button to quickly copy the generated hash to the clipboard.</li>
|
|
||||||
<li>Includes error handling to manage database insertion issues gracefully.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Web developers creating checksums for file verification.</li>
|
|
||||||
<li>Security professionals storing passwords securely in a database.</li>
|
|
||||||
<li>Software engineers ensuring data integrity by generating unique hashes for sensitive data.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <script>
|
|
||||||
function copyOutputText() {
|
|
||||||
const outputText = document.getElementById('output').value;
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
textarea.value = outputText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'Output text copied to clipboard!';
|
|
||||||
}
|
|
||||||
</script> -->
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Remove Multiple Whitespace</h2>
|
|
||||||
<div class="diZMaxW600 diZFlexColumn diZmxAuto diZmy20 toolsSection">
|
|
||||||
<textarea class="textarea-text" id="textInput" rows="10" placeholder="Enter text here..."></textarea>
|
|
||||||
<button class="diZmt2 diZmxAuto" onclick="processText()"><span>Remove</span></button>
|
|
||||||
<div class="diZFlexColumn diZDisplayNone diZmt2" id="after-procces">
|
|
||||||
<textarea class="textarea-text" id="output" rows="10" readonly></textarea>
|
|
||||||
<p class="diZDisplayNone diZTextCenter" id="copied-notice"></p>
|
|
||||||
<button class="diZmt2 diZmxAuto" id="copyButton" onclick="copyOutputText()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function removeMultipleWhitespace(text) {
|
|
||||||
return text.replace(/\s+/g, ' ').trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
function processText() {
|
|
||||||
const inputText = document.getElementById('textInput').value;
|
|
||||||
const cleanedText = removeMultipleWhitespace(inputText);
|
|
||||||
document.getElementById('output').value = cleanedText;
|
|
||||||
document.getElementById('after-procces').style.display = 'flex';
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyOutputText() {
|
|
||||||
const outputText = document.getElementById('output').value;
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
textarea.value = outputText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
const copiedNotice = document.getElementById('copied-notice');
|
|
||||||
copiedNotice.style.display = 'block';
|
|
||||||
copiedNotice.innerHTML = 'Output text copied to clipboard!';
|
|
||||||
setTimeout(() => {
|
|
||||||
copiedNotice.style.display = 'none';
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Domain MX Information API
|
|
||||||
* Endpoint: /dns-tools-get-mx-info
|
|
||||||
* Method: POST
|
|
||||||
* Content-Type: application/json
|
|
||||||
*/
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
|
|
||||||
// Allow only POST requests
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
http_response_code(405);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Only POST method allowed'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read JSON body
|
|
||||||
$input = json_decode(file_get_contents('php://input'), true);
|
|
||||||
$domain = $input['domain'] ?? '';
|
|
||||||
|
|
||||||
// Domain validation
|
|
||||||
function validateDomain(string $domain): bool
|
|
||||||
{
|
|
||||||
return (bool) filter_var(
|
|
||||||
$domain,
|
|
||||||
FILTER_VALIDATE_DOMAIN,
|
|
||||||
FILTER_FLAG_HOSTNAME
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$domain || !validateDomain($domain)) {
|
|
||||||
http_response_code(400);
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'Invalid domain'
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch MX records (safe, no shell_exec)
|
|
||||||
$records = dns_get_record($domain, DNS_MX);
|
|
||||||
$mxRecords = [];
|
|
||||||
|
|
||||||
if ($records !== false) {
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$mxRecords[] = [
|
|
||||||
'mail_server' => $record['target'] ?? '',
|
|
||||||
'priority' => $record['pri'] ?? null
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response
|
|
||||||
if (empty($mxRecords)) {
|
|
||||||
echo json_encode([
|
|
||||||
'success' => false,
|
|
||||||
'domain' => $domain,
|
|
||||||
'message' => 'No MX records found',
|
|
||||||
'records' => []
|
|
||||||
]);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode([
|
|
||||||
'success' => true,
|
|
||||||
'domain' => $domain,
|
|
||||||
'records' => $mxRecords
|
|
||||||
]);
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Domain DNS Information Viewer</h2>
|
|
||||||
</section>
|
|
||||||
<!-- <p class="diZTextJustify">NS Lookup simplifies checking DNS records. Enter any domain to instantly retrieve and explore its DNS details, including A, AAAA, MX, CNAME records, and more. Ideal for IT professionals and website administrators seeking quick and accurate DNS insights.</p> -->
|
|
||||||
<form method="post" class="diZToolsSection diZmt4 diZmb4 diZBorderRadius diZPadding5px">
|
|
||||||
<div class="diZFlexRowCol diZJustifyCenter diZItemsCenter">
|
|
||||||
<input class="diZmr2 diZw70" placeholder="Domain Name" name="domain" type="text" />
|
|
||||||
<button class="diZmr2" type="submit" value="Check"><span>Check</span></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
if(isset($_POST['domain']) && $_POST['domain']){
|
|
||||||
function validateDomain($domain) {
|
|
||||||
$regex = "/^(?!\-)(?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}$/";
|
|
||||||
if (preg_match($regex, $domain)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
|
|
||||||
if ($domain && validateDomain($domain)) {
|
|
||||||
$command = 'dig '.$_POST['domain']. ' NS';
|
|
||||||
$escaped_command = escapeshellcmd($command);
|
|
||||||
$output = shell_exec($escaped_command);
|
|
||||||
echo '<div class="diZContainer diZmxAuto diZPadding5px"><pre class="diZTextJustify" style="width: fit-content;"> ',$output, '</pre> <br><br></div>';
|
|
||||||
} else {
|
|
||||||
echo "Invalid domain.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy4">
|
|
||||||
<h1 class="diZBorderBottom">Open Graph Meta Generator</h1>
|
|
||||||
<p class="diZTextJustify">The Open Graph Meta Generator is a tool designed to help web developers and content creators easily generate meta tags for optimizing content sharing on social media platforms like Facebook and Twitter. By filling out a simple form, users can create the necessary Open Graph and Twitter meta tags to enhance the visibility and appearance of their web pages when shared online.</p>
|
|
||||||
<div class="diZFlexColumn diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
||||||
<form class="diZFlexColumn" id="metaForm">
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="ogTitle" class="form-label">Title:</label>
|
|
||||||
<input type="text" id="ogTitle" name="ogTitle" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="ogDescription" class="form-label">Description:</label>
|
|
||||||
<textarea id="ogDescription" name="ogDescription" class="diZTextAreaResizeNone" rows="4" required></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="ogImage" class="form-label">Image URL:</label>
|
|
||||||
<input type="text" id="ogImage" name="ogImage" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="ogUrl" class="form-label">URL:</label>
|
|
||||||
<input type="text" id="ogUrl" name="ogUrl" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="author" class="form-label">Author:</label>
|
|
||||||
<input type="text" id="author" name="author" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="keywords" class="form-label">Keywords:</label>
|
|
||||||
<input type="text" id="keywords" name="keywords" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="twitterTitle" class="form-label">Twitter Title:</label>
|
|
||||||
<input type="text" id="twitterTitle" name="twitterTitle" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="twitterDescription" class="form-label">Twitter Description:</label>
|
|
||||||
<textarea id="twitterDescription" name="twitterDescription" class="diZTextAreaResizeNone" rows="4" required></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="twitterImage" class="form-label">Twitter Image URL:</label>
|
|
||||||
<input type="text" id="twitterImage" name="twitterImage" class="" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<label for="twitterCard" class="form-label">Twitter Card Type:</label>
|
|
||||||
<select id="twitterCard" name="twitterCard" class="" required>
|
|
||||||
<option value="summary">Summary</option>
|
|
||||||
<option value="summary_large_image">Summary Large Image</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn diZmt2">
|
|
||||||
<div class="diZDisplayNone generated-meta-tags" id="generatedMetaTags"></div>
|
|
||||||
<p class="diZDisplayNone" id="copied-notice"></p>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexBetween diZmt2">
|
|
||||||
<button type="submit" class="button-style"><span>Generate</span></button>
|
|
||||||
<button id="copyButton" class="button-style" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<h2 class="diZBorderBottom">Content Limitations</h2>
|
|
||||||
<p>Understanding the character and word limits for various platforms and meta tags is crucial for optimizing your content. The following table provides a comprehensive guide to these limitations, ensuring that your content adheres to the best practices for SEO and social media sharing.</p>
|
|
||||||
<table class="diZw70 diZmxAuto">
|
|
||||||
<tr>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Name</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Min/Max</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Limit</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Type</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Meta Title</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">55</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Meta Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">160</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Google Ideal Post Content</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Min</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">300</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Word</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Instagram Captions/Comments</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">2200</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Twitter Post</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">280</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Twitter Username</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">20</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Wall Post (Truncation)</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">477</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Wall Post (All)</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">63206</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Comment</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">8000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Page Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">255</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Username</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">50</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Facebook Messenger Message</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">20000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">YouTube Video Title</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">70</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">YouTube Video Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">5000</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Snapchat Caption</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">250</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Pinterest Pin Description</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Max</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">500</td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">Letter</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Information:</strong> Input the required information, including Title, Description, Image URL, URL, Author, Keywords, Twitter Title, Twitter Description, Twitter Image URL, and Twitter Card Type, into the respective fields in the form.</li>
|
|
||||||
<li><strong>Generate Meta Tags:</strong> Click the "Generate" button to create the Open Graph and Twitter meta tags based on the provided information.</li>
|
|
||||||
<li><strong>Copy Meta Tags:</strong> The generated meta tags will appear in the output area. Click the "Copy" button to copy the meta tags to your clipboard.</li>
|
|
||||||
<li><strong>Paste and Use:</strong> Paste the copied meta tags into the head section of your HTML document to enhance your webpage's social media integration and SEO.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Generates Open Graph meta tags for improved social media sharing.</li>
|
|
||||||
<li>Generates Twitter meta tags for optimized content sharing on Twitter.</li>
|
|
||||||
<li>Provides a clear and user-friendly form to input all necessary information.</li>
|
|
||||||
<li>Includes a "Copy to Clipboard" function for easy integration into your HTML code.</li>
|
|
||||||
<li>Displays a "Meta tags copied to clipboard!" notification upon copying.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Web developers optimizing websites for social media sharing.</li>
|
|
||||||
<li>Content creators ensuring their articles and posts are displayed attractively on social media platforms.</li>
|
|
||||||
<li>SEO specialists enhancing webpage metadata for better search engine rankings.</li>
|
|
||||||
<li>Bloggers and marketers improving the visibility and engagement of their content on social media.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const form = document.getElementById('metaForm');
|
|
||||||
const generatedMetaTags = document.getElementById('generatedMetaTags');
|
|
||||||
const copiedNotice = document.getElementById('copied-notice');
|
|
||||||
|
|
||||||
form.addEventListener('submit', function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const ogTitle = document.getElementById('ogTitle').value.trim();
|
|
||||||
const ogDescription = document.getElementById('ogDescription').value.trim();
|
|
||||||
const ogImage = document.getElementById('ogImage').value.trim();
|
|
||||||
const ogUrl = document.getElementById('ogUrl').value.trim();
|
|
||||||
const author = document.getElementById('author').value.trim();
|
|
||||||
const keywords = document.getElementById('keywords').value.trim();
|
|
||||||
const twitterTitle = document.getElementById('twitterTitle').value.trim();
|
|
||||||
const twitterDescription = document.getElementById('twitterDescription').value.trim();
|
|
||||||
const twitterImage = document.getElementById('twitterImage').value.trim();
|
|
||||||
const twitterCard = document.getElementById('twitterCard').value.trim();
|
|
||||||
|
|
||||||
const metaTags = `
|
|
||||||
<title>${ogTitle}</title>
|
|
||||||
<meta name="description" content="${ogDescription}">
|
|
||||||
<meta name="keywords" content="${keywords}">
|
|
||||||
<meta name="author" content="${author}">
|
|
||||||
<meta property="og:title" content="${ogTitle}">
|
|
||||||
<meta property="og:description" content="${ogDescription}">
|
|
||||||
<meta property="og:image" content="${ogImage}">
|
|
||||||
<meta property="og:url" content="${ogUrl}">
|
|
||||||
<meta name="twitter:title" content="${twitterTitle}">
|
|
||||||
<meta name="twitter:description" content="${twitterDescription}">
|
|
||||||
<meta name="twitter:image" content="${twitterImage}">
|
|
||||||
<meta name="twitter:card" content="${twitterCard}">
|
|
||||||
`;
|
|
||||||
|
|
||||||
if(metaTags.length > 20) {
|
|
||||||
generatedMetaTags.style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
generatedMetaTags.innerText = `${metaTags}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const metaTags = document.getElementById('generatedMetaTags');
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
textarea.value = metaTags.innerText;
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
copiedNotice.style.display = 'block';
|
|
||||||
copiedNotice.innerHTML = 'Meta tags copied to clipboard!';
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
copiedNotice.style.display = 'none';
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Image to ICO Converter</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 50px;
|
|
||||||
}
|
|
||||||
#fileInput {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Image to ICO Converter</h1>
|
|
||||||
<input type="file" id="fileInput" accept="image/*">
|
|
||||||
<br>
|
|
||||||
<button id="convertButton"><span>Convert to ICO</span></button>
|
|
||||||
<br><br>
|
|
||||||
<a id="downloadLink" style="display: none;" download="icon.ico">Download ICO</a>
|
|
||||||
|
|
||||||
<script src="icojs.js"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const fileInput = document.getElementById('fileInput');
|
|
||||||
const convertButton = document.getElementById('convertButton');
|
|
||||||
const downloadLink = document.getElementById('downloadLink');
|
|
||||||
|
|
||||||
convertButton.addEventListener('click', function() {
|
|
||||||
if (fileInput.files.length > 0) {
|
|
||||||
const file = fileInput.files[0];
|
|
||||||
|
|
||||||
// Check if file is an image
|
|
||||||
if (file.type.startsWith('image/')) {
|
|
||||||
const reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onload = function(e) {
|
|
||||||
const img = new Image();
|
|
||||||
img.onload = function() {
|
|
||||||
// Create a canvas to draw the image
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
canvas.width = img.width;
|
|
||||||
canvas.height = img.height;
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
||||||
|
|
||||||
// Convert canvas to ICO format
|
|
||||||
const ico = new ICO();
|
|
||||||
ico.add(canvas.toDataURL('image/png')); // Add PNG image data
|
|
||||||
|
|
||||||
// Generate ICO file blob
|
|
||||||
const icoBlob = ico.build();
|
|
||||||
|
|
||||||
// Update download link
|
|
||||||
const url = URL.createObjectURL(icoBlob);
|
|
||||||
downloadLink.href = url;
|
|
||||||
downloadLink.style.display = 'inline-block';
|
|
||||||
};
|
|
||||||
img.src = e.target.result;
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
} else {
|
|
||||||
alert('Please upload an image file.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
alert('Please select a file to convert.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
$time = time();
|
|
||||||
$gen_pass = rand(100, 360) . $time . rand(100, 999);
|
|
||||||
$rand_pass = base_convert($gen_pass, 10, 36);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h1 class="diZBorderBottom">Get a random password</h1>
|
|
||||||
<p class="diZTextJustify">This tool generates a random password consisting of alphanumeric characters, ideal for creating secure credentials quickly. It combines a random numeric value with the current timestamp, converting the result into a base-36 string format for enhanced security and uniqueness.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZmy20 diZFlexColumn toolsSection">
|
|
||||||
<p class="diZDisplayNone" id="copied-notice"></p>
|
|
||||||
<div class="diZFlexRow diZItemsCenter diZJustifyCenter">
|
|
||||||
<h2>Password: <span id="randPassword"><?php echo $rand_pass; ?></span></h2>
|
|
||||||
<span class="diZCursorPointer" onclick="copyToClipboard()"><img src="/assets/svg/copy.svg" alt="Copy to Clipboard"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Generate Random Password:</strong> Click the "Get a random password" button to generate a new, unique password.</li>
|
|
||||||
<li><strong>Copy Password to Clipboard:</strong> Once generated, the password will display below the button.</li>
|
|
||||||
<li><strong>Click the Copy Icon:</strong> Click the copy icon next to the password to copy it to your clipboard.</li>
|
|
||||||
<li><strong>Paste and Use:</strong> Paste the copied password into any application, login form, or document where a secure password is required.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Randomized Generation:</strong> Each password is dynamically generated using random numbers and timestamps.</li>
|
|
||||||
<li><strong>Secure Base-36 Conversion:</strong> Converts the generated value into a base-36 string format for enhanced security.</li>
|
|
||||||
<li><strong>Clipboard Integration:</strong> Allows easy copying of the generated password with a single click.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>User Accounts:</strong> Quickly generate secure passwords for new user registrations or account setups.</li>
|
|
||||||
<li><strong>Password Resets:</strong> Provide users with randomly generated passwords for password recovery processes.</li>
|
|
||||||
<li><strong>Secure Access:</strong> Ideal for securing sensitive information and access credentials across various platforms.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function copyToClipboard() {
|
|
||||||
var copyText = document.getElementById('randPassword').innerText; // Get the text content
|
|
||||||
var textArea = document.createElement('textarea');
|
|
||||||
|
|
||||||
// Place the text in the textarea
|
|
||||||
textArea.value = copyText;
|
|
||||||
|
|
||||||
// Make the textarea hidden
|
|
||||||
textArea.style.position = 'fixed';
|
|
||||||
textArea.style.opacity = 0;
|
|
||||||
|
|
||||||
// Append the textarea to the body
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
|
|
||||||
// Select and copy the text
|
|
||||||
textArea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
|
|
||||||
// Remove the textarea from the DOM
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
|
|
||||||
// Show copied notice
|
|
||||||
var notice = document.getElementById('copied-notice');
|
|
||||||
notice.style.display = 'block';
|
|
||||||
notice.textContent = 'Text copied to clipboard!';
|
|
||||||
|
|
||||||
// Hide notice after 1 second
|
|
||||||
setTimeout(function() {
|
|
||||||
notice.style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
|
|
||||||
$input = json_decode(file_get_contents("php://input"), true);
|
|
||||||
$url = $input['url'] ?? null;
|
|
||||||
|
|
||||||
$response = [
|
|
||||||
"success" => false,
|
|
||||||
"detected" => [],
|
|
||||||
"errors" => [],
|
|
||||||
"warnings" => [],
|
|
||||||
"info" => []
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
|
|
||||||
$response['errors'][] = "Valid URL required";
|
|
||||||
echo json_encode($response);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fetch html */
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt_array($ch, [
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_TIMEOUT => 20,
|
|
||||||
CURLOPT_USERAGENT => 'SchemaValidatorBot/1.0',
|
|
||||||
CURLOPT_ENCODING => '' // gzip support
|
|
||||||
]);
|
|
||||||
|
|
||||||
$html = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
if (!$html) {
|
|
||||||
$response['errors'][] = "Failed to fetch URL";
|
|
||||||
echo json_encode($response);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* extract JSON-LD */
|
|
||||||
preg_match_all(
|
|
||||||
'/<script[^>]+type=["\']application\/ld\+json["\'][^>]*>(.*?)<\/script>/is',
|
|
||||||
$html,
|
|
||||||
$matches
|
|
||||||
);
|
|
||||||
|
|
||||||
if (empty($matches[1])) {
|
|
||||||
$response['warnings'][] = "No schema found in initial HTML";
|
|
||||||
|
|
||||||
// heuristic for SPA
|
|
||||||
if (
|
|
||||||
stripos($html, '__NEXT_DATA__') !== false ||
|
|
||||||
stripos($html, 'id="root"') !== false ||
|
|
||||||
stripos($html, 'data-reactroot') !== false
|
|
||||||
) {
|
|
||||||
$response['info'][] =
|
|
||||||
"This site appears to be client-side rendered. Schema may exist but cannot be validated using PHP-only.";
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($response, JSON_PRETTY_PRINT);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* analyze schemas */
|
|
||||||
foreach ($matches[1] as $schema) {
|
|
||||||
$json = json_decode($schema, true);
|
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
||||||
$response['errors'][] = json_last_error_msg();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($json['@type'])) {
|
|
||||||
$response['detected'][] = $json['@type'];
|
|
||||||
} elseif (isset($json[0])) {
|
|
||||||
foreach ($json as $item) {
|
|
||||||
if (isset($item['@type'])) {
|
|
||||||
$response['detected'][] = $item['@type'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$response['detected'] = array_values(array_unique($response['detected']));
|
|
||||||
$response['success'] = empty($response['errors']);
|
|
||||||
|
|
||||||
echo json_encode($response, JSON_PRETTY_PRINT);
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once('.htac_header.php');
|
|
||||||
?>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZFlexColumn diZmb20">
|
|
||||||
<h1 class="diZTextCenter diZBorderBottom">Screen Recorder</h1>
|
|
||||||
<div class="diZFlexRow ">
|
|
||||||
<button class="diZSpaceR" id="start"><span>Start Recording</span></button>
|
|
||||||
<button class="diZSpaceR" id="stop" disabled><span>Stop Recording</span></button>
|
|
||||||
<button class="diZSpaceR" id="download" disabled><span>Download Recording</span></button>
|
|
||||||
</div>
|
|
||||||
<div class="diZTextCenter diZmb4 diZmt4" id="timer">Duration: 00:00:00</div>
|
|
||||||
<video class="diZw100" id="video" muted controls autoplay></video>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
const startButton = document.getElementById('start');
|
|
||||||
const stopButton = document.getElementById('stop');
|
|
||||||
const downloadButton = document.getElementById('download');
|
|
||||||
const video = document.getElementById('video');
|
|
||||||
const timer = document.getElementById('timer');
|
|
||||||
|
|
||||||
let mediaRecorder;
|
|
||||||
let recordedChunks = [];
|
|
||||||
let startTime;
|
|
||||||
let timerInterval;
|
|
||||||
|
|
||||||
function formatTime(time) {
|
|
||||||
const hours = String(Math.floor(time / 3600)).padStart(2, '0');
|
|
||||||
const minutes = String(Math.floor((time % 3600) / 60)).padStart(2, '0');
|
|
||||||
const seconds = String(time % 60).padStart(2, '0');
|
|
||||||
return `${hours}:${minutes}:${seconds}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function startTimer() {
|
|
||||||
startTime = Date.now();
|
|
||||||
timerInterval = setInterval(() => {
|
|
||||||
const elapsedTime = Math.floor((Date.now() - startTime) / 1000);
|
|
||||||
timer.textContent ='Duration: ' + formatTime(elapsedTime);
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopTimer() {
|
|
||||||
clearInterval(timerInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
startButton.addEventListener('click', async () => {
|
|
||||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getDisplayMedia) {
|
|
||||||
console.log('getDisplayMedia is not supported in your browser.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const stream = await navigator.mediaDevices.getDisplayMedia({
|
|
||||||
video: { mediaSource: 'screen' },
|
|
||||||
audio: true // Enable audio recording
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show live video feed in the video element
|
|
||||||
video.srcObject = stream;
|
|
||||||
|
|
||||||
mediaRecorder = new MediaRecorder(stream);
|
|
||||||
|
|
||||||
mediaRecorder.ondataavailable = (event) => {
|
|
||||||
if (event.data.size > 0) {
|
|
||||||
console.log('Data available:', event.data.size);
|
|
||||||
recordedChunks.push(event.data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mediaRecorder.onstop = () => {
|
|
||||||
console.log('Recording stopped. Creating blob.');
|
|
||||||
if (recordedChunks.length > 0) {
|
|
||||||
const blob = new Blob(recordedChunks, {
|
|
||||||
type: 'video/webm'
|
|
||||||
});
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
video.src = url;
|
|
||||||
downloadButton.href = url;
|
|
||||||
downloadButton.download = 'recording.webm';
|
|
||||||
downloadButton.disabled = false;
|
|
||||||
} else {
|
|
||||||
console.error('No recorded data available.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mediaRecorder.start();
|
|
||||||
startTimer();
|
|
||||||
|
|
||||||
startButton.disabled = true;
|
|
||||||
stopButton.disabled = false;
|
|
||||||
downloadButton.disabled = true;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error: ' + error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
stopButton.addEventListener('click', () => {
|
|
||||||
if (mediaRecorder && mediaRecorder.state !== 'inactive') {
|
|
||||||
mediaRecorder.stop();
|
|
||||||
stopTimer();
|
|
||||||
|
|
||||||
startButton.disabled = false;
|
|
||||||
stopButton.disabled = true;
|
|
||||||
} else {
|
|
||||||
console.error('No active recording to stop.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
downloadButton.addEventListener('click', () => {
|
|
||||||
if (recordedChunks.length > 0) {
|
|
||||||
const blob = new Blob(recordedChunks, {
|
|
||||||
type: 'video/webm'
|
|
||||||
});
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.style.display = 'none';
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'recording.webm';
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
window.URL.revokeObjectURL(url);
|
|
||||||
recordedChunks = [];
|
|
||||||
} else {
|
|
||||||
console.error('No data available for download.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmy8">
|
|
||||||
<h1 class="diZBorderBottom">Slug Generator</h1>
|
|
||||||
<p class="diZTextJustify">The Slug Generator tool allows you to easily create SEO-friendly slugs from your input text. A slug is a URL-friendly version of a string, typically used in web addresses to identify a specific page or resource. This tool converts any text you input into a lowercase string, removes special characters, and replaces spaces with hyphens to generate a clean and readable URL slug.</p>
|
|
||||||
<div class="diZMaxW600 diZmxAuto diZmy20 diZFlexColumn toolsSection">
|
|
||||||
<textarea class="diZTextAreaResizeNone" placeholder="Enter text" id="inputText" rows="6"></textarea> <br>
|
|
||||||
<button class="diZmxAuto" onclick="generateSlug()"><span>Generate Slug</span></button>
|
|
||||||
<p id="copied-notice" class="diZDisplayNone"></p>
|
|
||||||
<textarea id="slugOutput" class="diZTextAreaResizeNone diZDisplayNone diZmy4" rows="6"></textarea>
|
|
||||||
<button id="copyBtn" class="diZDisplayNone diZmxAuto" onclick="copyToClipboard()"><span>Copy Slug</span></button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Text:</strong> Input your desired text into the text area provided.</li>
|
|
||||||
<li><strong>Generate Slug:</strong> Click the "Generate Slug" button to convert the text into a URL-friendly slug.</li>
|
|
||||||
<li><strong>Copy Slug:</strong> Once generated, the slug will appear in the output text area. Click the "Copy Slug" button to copy it to your clipboard.</li>
|
|
||||||
<li><strong>Paste and Use:</strong> Paste the copied slug directly into your web application, blog post, or any other content management system (CMS) where you need a URL slug.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Converts text to lowercase.</li>
|
|
||||||
<li>Removes special characters and replaces spaces with hyphens.</li>
|
|
||||||
<li>Provides instant feedback with a "Slug copied to clipboard!" notification upon copying.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Bloggers creating SEO-friendly URLs for their articles.</li>
|
|
||||||
<li>Developers generating slugs for dynamic content pages.</li>
|
|
||||||
<li>Content managers ensuring consistency and readability in URL structures.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<script>
|
|
||||||
function generateSlug() {
|
|
||||||
const inputText = document.getElementById('inputText').value;
|
|
||||||
const slugOutput = document.getElementById('slugOutput');
|
|
||||||
// Generate slug
|
|
||||||
const slug = inputText.trim().toLowerCase().replace(/[^\w\s-]/g, '').replace(/\s+/g, '-');
|
|
||||||
|
|
||||||
// Update output textarea and display copy button
|
|
||||||
if (slug.length > 0) {
|
|
||||||
document.getElementById('copyBtn').style.display = 'block';
|
|
||||||
slugOutput.style.display = 'block';
|
|
||||||
slugOutput.value = slug;
|
|
||||||
} else {
|
|
||||||
document.getElementById('copyBtn').style.display = 'none';
|
|
||||||
slugOutput.style.display = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard() {
|
|
||||||
const slugOutput = document.getElementById('slugOutput');
|
|
||||||
const textArea = document.createElement('textarea');
|
|
||||||
textArea.value = slugOutput.value;
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
|
|
||||||
// Show copied notice
|
|
||||||
document.getElementById('copied-notice').innerHTML = 'Slug copied to clipboard!';
|
|
||||||
document.getElementById('copied-notice').style.display = 'block';
|
|
||||||
|
|
||||||
// Hide notice after 1 second
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById('copied-notice').style.display = 'none';
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
<div class="tomljson-container">
|
|
||||||
<div class="tomljson-box">
|
|
||||||
<h2 class="tomljson-title">TOML to JSON Converter</h2>
|
|
||||||
<textarea cols="45" rows="8" class="tomljson-input" placeholder="Paste TOML here..."></textarea>
|
|
||||||
<div class="tomljson-button-group">
|
|
||||||
<button class="tomljson-convert-btn">Convert</button>
|
|
||||||
<button class="tomljson-copy-btn">Copy JSON</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3 class="tomljson-output-title">JSON Output:</h3>
|
|
||||||
<pre class="tomljson-output"></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script type="module">
|
|
||||||
import * as TOML from 'https://cdn.jsdelivr.net/npm/toml@3.0.0/+esm';
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
document.querySelector(".tomljson-convert-btn").addEventListener("click", () => {
|
|
||||||
try {
|
|
||||||
const tomlData = document.querySelector(".tomljson-input").value;
|
|
||||||
const jsonData = TOML.parse(tomlData);
|
|
||||||
document.querySelector(".tomljson-output").textContent = JSON.stringify(jsonData, null, 2);
|
|
||||||
} catch (error) {
|
|
||||||
document.querySelector(".tomljson-output").textContent = "Error: " + error.message;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector(".tomljson-copy-btn").addEventListener("click", () => {
|
|
||||||
const jsonOutput = document.querySelector(".tomljson-output").textContent;
|
|
||||||
navigator.clipboard.writeText(jsonOutput).then(() => {
|
|
||||||
document.querySelector(".tomljson-copy-btn").textContent = "Copied!";
|
|
||||||
setTimeout(() => document.querySelector(".tomljson-copy-btn").textContent = "Copy JSON", 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
.tomljson-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
margin: 100px 0
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-box {
|
|
||||||
background: #2c2c2c;
|
|
||||||
padding: 25px;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
|
|
||||||
max-width: 450px;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-title {
|
|
||||||
font-size: 22px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-input {
|
|
||||||
/* width: 100%; */
|
|
||||||
background: #3c3c3c;
|
|
||||||
color: #ffffff;
|
|
||||||
border: 1px solid #555;
|
|
||||||
border-radius: 5px;
|
|
||||||
/* padding: 12px; */
|
|
||||||
font-size: 14px;
|
|
||||||
resize: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-button-group {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-convert-btn, .tomljson-copy-btn {
|
|
||||||
background: #007bff;
|
|
||||||
border: none;
|
|
||||||
padding: 10px 18px;
|
|
||||||
border-radius: 5px;
|
|
||||||
color: #ffffff;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 15px;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-copy-btn {
|
|
||||||
background: #28a745;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-convert-btn:hover {
|
|
||||||
background: #0056b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-copy-btn:hover {
|
|
||||||
background: #218838;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-output-title {
|
|
||||||
font-size: 18px;
|
|
||||||
margin-top: 20px;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tomljson-output {
|
|
||||||
background: #3c3c3c;
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 5px;
|
|
||||||
text-align: left;
|
|
||||||
font-size: 14px;
|
|
||||||
height: 160px;
|
|
||||||
overflow: auto;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
border: 1px solid #555;
|
|
||||||
color: #ffffff;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
$errorMessage = "";
|
|
||||||
$dns_records = [];
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_STRING);
|
|
||||||
|
|
||||||
if (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
|
|
||||||
$dns_records = dns_get_record($domain, DNS_ALL);
|
|
||||||
|
|
||||||
if ($dns_records === false) {
|
|
||||||
$errorMessage = "Unable to retrieve DNS records for domain: $domain";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$errorMessage = "Invalid domain format: $domain";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<section class="diZContainer diZmxAuto diZmy4">
|
|
||||||
<h2 class="diZBorderBottom">DNS records for domain: <?php echo htmlspecialchars($domain); ?></h2>
|
|
||||||
|
|
||||||
<div class="diZmy20 toolsSection diZMaxW700 diZmxAuto">
|
|
||||||
<form action="" method="post">
|
|
||||||
<div class="diZFlexColumn">
|
|
||||||
<label for="domain">Enter domain:</label>
|
|
||||||
<p class="diZDangerText"><?php echo htmlspecialchars($errorMessage); ?></p>
|
|
||||||
<input type="text" id="domain" name="domain" placeholder="Enter Domain Name" required>
|
|
||||||
<button class="diZmxAuto diZmt4" type="submit"><span>Check DNS</span></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($dns_records)) { ?>
|
|
||||||
<div class="diZMaxW700 diZmxAuto diZOverflowXAuto">
|
|
||||||
<table class="diZw100">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Type</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Host</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Class</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">TTL</th>
|
|
||||||
<th class="diZTableBorder diZPadding5px">Other</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($dns_records as $record) { ?>
|
|
||||||
<tr>
|
|
||||||
<td class="diZTableBorder diZPadding5px"><?php echo $record['type']; ?></td>
|
|
||||||
<td class="diZTableBorder diZPadding5px"><?php echo $record['host']; ?></td>
|
|
||||||
<td class="diZTableBorder diZPadding5px"><?php echo $record['class']; ?></td>
|
|
||||||
<td class="diZTableBorder diZPadding5px"><?php echo $record['ttl']; ?></td>
|
|
||||||
<td class="diZTableBorder diZPadding5px">
|
|
||||||
<?php
|
|
||||||
foreach ($record as $key => $value) {
|
|
||||||
if (!in_array($key, ['type', 'host', 'class', 'ttl'])) {
|
|
||||||
if (is_array($value)) {
|
|
||||||
echo "$key: " . implode(', ', $value) . " <br>";
|
|
||||||
} else {
|
|
||||||
echo "$key: $value <br>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Domain:</strong> Input the domain name you wish to check in the provided text field.</li>
|
|
||||||
<li><strong>Check DNS:</strong> Click the "Check DNS" button to retrieve and display the DNS records for the entered domain.</li>
|
|
||||||
<li><strong>View Results:</strong> The DNS records will be displayed in a tabular format, showing the type, host, class, TTL, and other relevant information for each record.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Supports all common DNS record types (A, AAAA, CNAME, MX, NS, TXT, etc.).</li>
|
|
||||||
<li>Displays DNS records in a clear and organized table.</li>
|
|
||||||
<li>Validates domain format before querying DNS records.</li>
|
|
||||||
<li>Provides a user-friendly interface for easy DNS checking.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Web administrators troubleshooting DNS issues for their domains.</li>
|
|
||||||
<li>Developers needing to verify DNS settings for their applications.</li>
|
|
||||||
<li>SEO specialists checking the DNS configuration of websites.</li>
|
|
||||||
<li>Domain owners ensuring proper DNS setup and propagation.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
$ipv4 = $_SERVER['REMOTE_ADDR'];
|
|
||||||
|
|
||||||
// Get the IPv6 address of the client if available
|
|
||||||
$ipv6 = $_SERVER['REMOTE_ADDR'];
|
|
||||||
if (strpos($ipv6, ":") !== false) {
|
|
||||||
// IPv6 address detected
|
|
||||||
$ipv6 = explode("%", $ipv6)[0]; // Remove interface suffix, if any
|
|
||||||
} else {
|
|
||||||
// No IPv6 address detected
|
|
||||||
$ipv6 = "IPv6 not available";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display IPv4 and IPv6 addresses
|
|
||||||
echo "IPv4 Address: " . $ipv4 . "<br>";
|
|
||||||
echo "IPv6 Address: " . $ipv6 . "<br>";
|
|
||||||
?>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
|
||||||
<h2 class="diZBorderBottom">Ultimate Domain & IP Lookup Tool</h2>
|
|
||||||
<p class="diZmb20">This tool allows you to perform a comprehensive lookup of domain names or IP addresses, providing detailed WHOIS information.</p>
|
|
||||||
<form method="post" class="diZToolsSection diZmt4 diZmb4 diZBorderRadius diZPadding5px ">
|
|
||||||
<div class="diZFlexRowCol diZJustifyCenter diZItemsCenter ">
|
|
||||||
<input class="diZmr2 diZw70" placeholder="Domain" name="domain" type="text" />
|
|
||||||
<p class="diZmr2">OR</p>
|
|
||||||
<input class="diZmr2 diZw70" placeholder="IP Address" name="ip" type="text" />
|
|
||||||
<button type="submit"><span>Check</span></button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
if(isset($_POST['domain']) && $_POST['domain']){
|
|
||||||
function validateDomain($domain) {
|
|
||||||
$regex = "/^(?!\-)(?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}$/";
|
|
||||||
if (preg_match($regex, $domain)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
|
|
||||||
if ($domain && validateDomain($domain)) {
|
|
||||||
$command = 'whois '.$_POST['domain'];
|
|
||||||
$escaped_command = escapeshellcmd($command);
|
|
||||||
$output = shell_exec($escaped_command);
|
|
||||||
echo '<div class="diZContainer diZmxAuto diZPadding5px"><pre class="diZTextJustify" style="width: fit-content;"> ',$output, '</pre> <br><br></div>';
|
|
||||||
} else {
|
|
||||||
echo "Invalid domain.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isset($_POST['ip']) && $_POST['ip']){
|
|
||||||
function validatePublicIp($ip) {
|
|
||||||
if (filter_var($ip, FILTER_VALIDATE_IP)) {
|
|
||||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$ip = isset($_POST['ip']) ? $_POST['ip'] : '';
|
|
||||||
if ($ip && validatePublicIp($ip)) {
|
|
||||||
$command = 'whois '.$_POST['ip'];
|
|
||||||
$escaped_command = escapeshellcmd($command);
|
|
||||||
$output = shell_exec($escaped_command);
|
|
||||||
echo '<div class="diZContainer diZmxAuto diZPadding5px"><pre> ',$output, '</pre> <br><br></div>';
|
|
||||||
} else {
|
|
||||||
echo "Invalid IP address.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Enter a domain name or an IP address into the respective input field.</li>
|
|
||||||
<li>Click the "Check" button to retrieve WHOIS information.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Supports lookup for both domain names and IP addresses.</li>
|
|
||||||
<li>Displays WHOIS data including registration details and administrative contacts.</li>
|
|
||||||
<li>Secure input validation to ensure accurate results.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Investigate ownership and registration details of a domain.</li>
|
|
||||||
<li>Check the WHOIS information of an IP address for network troubleshooting.</li>
|
|
||||||
<li>Verify domain availability and registration status.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<div class="xmljson-container">
|
|
||||||
<div class="xmljson-box">
|
|
||||||
<h2 class="xmljson-title">XML to JSON Converter</h2>
|
|
||||||
<textarea cols="45" rows="8" class="xmljson-input" placeholder="Paste XML here..."></textarea>
|
|
||||||
<div class="xmljson-button-group">
|
|
||||||
<button class="xmljson-convert-btn">Convert</button>
|
|
||||||
<button class="xmljson-copy-btn">Copy JSON</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3 class="xmljson-output-title">JSON Output:</h3>
|
|
||||||
<pre class="xmljson-output"></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function xmlToJson(xml) {
|
|
||||||
let obj = {};
|
|
||||||
if (xml.nodeType === 1) { // Element
|
|
||||||
if (xml.attributes.length > 0) {
|
|
||||||
obj["@attributes"] = {};
|
|
||||||
for (let j = 0; j < xml.attributes.length; j++) {
|
|
||||||
let attribute = xml.attributes.item(j);
|
|
||||||
obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (xml.nodeType === 3) { // Text
|
|
||||||
return xml.nodeValue.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xml.hasChildNodes()) {
|
|
||||||
for (let i = 0; i < xml.childNodes.length; i++) {
|
|
||||||
let item = xml.childNodes.item(i);
|
|
||||||
let nodeName = item.nodeName;
|
|
||||||
let jsonNode = xmlToJson(item);
|
|
||||||
|
|
||||||
if (jsonNode !== "") {
|
|
||||||
if (typeof obj[nodeName] === "undefined") {
|
|
||||||
obj[nodeName] = jsonNode;
|
|
||||||
} else {
|
|
||||||
if (!Array.isArray(obj[nodeName])) {
|
|
||||||
obj[nodeName] = [obj[nodeName]];
|
|
||||||
}
|
|
||||||
obj[nodeName].push(jsonNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
document.querySelector(".xmljson-convert-btn").addEventListener("click", () => {
|
|
||||||
try {
|
|
||||||
const xmlText = document.querySelector(".xmljson-input").value;
|
|
||||||
const parser = new DOMParser();
|
|
||||||
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
|
||||||
|
|
||||||
if (xmlDoc.getElementsByTagName("parsererror").length) {
|
|
||||||
throw new Error("Invalid XML format!");
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonData = xmlToJson(xmlDoc.documentElement);
|
|
||||||
document.querySelector(".xmljson-output").textContent = JSON.stringify(jsonData, null, 2);
|
|
||||||
} catch (error) {
|
|
||||||
document.querySelector(".xmljson-output").textContent = "Error: " + error.message;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector(".xmljson-copy-btn").addEventListener("click", () => {
|
|
||||||
const jsonOutput = document.querySelector(".xmljson-output").textContent;
|
|
||||||
navigator.clipboard.writeText(jsonOutput).then(() => {
|
|
||||||
document.querySelector(".xmljson-copy-btn").textContent = "Copied!";
|
|
||||||
setTimeout(() => document.querySelector(".xmljson-copy-btn").textContent = "Copy JSON", 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.xmljson-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
margin: 100px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-box {
|
|
||||||
background: #2c2c2c;
|
|
||||||
padding: 25px;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
|
|
||||||
max-width: 450px;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-title {
|
|
||||||
font-size: 22px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-input {
|
|
||||||
background: #3c3c3c;
|
|
||||||
color: #ffffff;
|
|
||||||
border: 1px solid #555;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-size: 14px;
|
|
||||||
resize: none;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-button-group {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-convert-btn, .xmljson-copy-btn {
|
|
||||||
background: #007bff;
|
|
||||||
border: none;
|
|
||||||
padding: 10px 18px;
|
|
||||||
border-radius: 5px;
|
|
||||||
color: #ffffff;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 15px;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-copy-btn {
|
|
||||||
background: #28a745;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-convert-btn:hover {
|
|
||||||
background: #0056b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-copy-btn:hover {
|
|
||||||
background: #218838;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-output-title {
|
|
||||||
font-size: 18px;
|
|
||||||
margin-top: 20px;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.xmljson-output {
|
|
||||||
background: #3c3c3c;
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 5px;
|
|
||||||
text-align: left;
|
|
||||||
font-size: 14px;
|
|
||||||
height: 160px;
|
|
||||||
overflow: auto;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
border: 1px solid #555;
|
|
||||||
color: #ffffff;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
RewriteEngine On
|
|
||||||
#RewriteCond %{HTTPS} !=on
|
|
||||||
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
|
|
||||||
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
|
||||||
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
|
||||||
RewriteRule ^(.*) index.php
|
|
||||||
Binary file not shown.
102
_home.php
Normal file
102
_home.php
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
// require_once('.hta_config/siliconpin_sp.php');
|
||||||
|
require_once('.htac_header.php');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<section class="container-zz mx-auto">
|
||||||
|
<h1 class="grid-container" style="font-size: 30px; font-weight: bold; padding-top: 20px; padding-bottom: 10px; border-bottom: 4px solid #FFF; margin-bottom: 20px;">SiliconPin - Tools</h1>
|
||||||
|
<div class="grid-container" style="display: flex; flex-direction: row; overflow-x: auto; margin-bottom: 20px;">
|
||||||
|
<a href="/tools/type/?type=image" class="choosen-button">Image</a>
|
||||||
|
<a href="/tools/type/?type=text" class="choosen-button">Text</a>
|
||||||
|
<a href="/tools/type/?type=html" class="choosen-button">HTML</a>
|
||||||
|
<a href="/tools/type/?type=color" class="choosen-button">Color</a>
|
||||||
|
<a href="/tools/type/?type=info" class="choosen-button">Info</a>
|
||||||
|
<a href="/tools/type/?type=encrypt-decrypt" class="choosen-button">Encrypt / Decrypt</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid-container">
|
||||||
|
<?php
|
||||||
|
try {
|
||||||
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||||
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM api_tools");
|
||||||
|
$stmt->execute();
|
||||||
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
// var_dump($rows);
|
||||||
|
foreach($rows as $row){
|
||||||
|
// echo $row['name'].'<br>';
|
||||||
|
if($row['status']==1){
|
||||||
|
$link_button = '<a href="/tools/'.$row['slug'].'" ><p class="choosen-button">'.$row['name'].'</p></a>';
|
||||||
|
} else{
|
||||||
|
$link_button = '<h2><p class="choosen-button">'.$row['name'].'</p></h2>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
<div class="grid-item blog-style">
|
||||||
|
<p class="line-clamp-2" style="text-align: justify;" >'.$row['description'].'</p>
|
||||||
|
'.$link_button.'
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$in_page_message = "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container-zz{width:100%}@media (min-width: 640px){.container-zz{max-width:640px}}@media (min-width: 768px){.container-zz{max-width:768px}}@media (min-width: 1024px){.container-zz{max-width:1024px}}@media (min-width: 1280px){.container-zz{max-width:1280px}}@media (min-width: 1536px){.container-zz{max-width:1536px}}
|
||||||
|
.mx-auto{margin-left:auto;margin-right:auto;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.my-20{margin-top:5rem;margin-bottom:5rem}
|
||||||
|
.grid-container {
|
||||||
|
display: grid;
|
||||||
|
grid-gap: 10px;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 1200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-item {
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile (up to 600px) */
|
||||||
|
@media only screen and (max-width: 600px) {
|
||||||
|
.grid-container {
|
||||||
|
grid-template-columns: repeat(1, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Medium (601px - 1024px) */
|
||||||
|
@media only screen and (min-width: 601px) and (max-width: 1024px) {
|
||||||
|
.grid-container {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Large (1025px and above) */
|
||||||
|
@media only screen and (min-width: 1025px) {
|
||||||
|
.grid-container {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.line-clamp-2 {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.line-clamp-1 {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
#dynamicContent > img{
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
width: 100%;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('../.hta_config/conf.php');
|
require_once('.hta_config/siliconpin_sp.php');
|
||||||
require_once('../.hta_slug/_header.php');
|
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD']=='POST' && strlen($_POST['name']>3)){
|
if($_SERVER['REQUEST_METHOD']=='POST' && strlen($_POST['name']>3)){
|
||||||
$slugText = $_POST['name'];
|
$slugText = $_POST['name'];
|
||||||
@@ -1,46 +1,17 @@
|
|||||||
<section class="diZContainer diZmxAuto">
|
<section class="container-zz mx-auto my-20 flex-direction-col">
|
||||||
<h1 class="diZBorderBottom">Generate BAR Code</h1>
|
<h1 style="font-size: 25px;">Generate BAR Code</h1>
|
||||||
<p class="diZTextJustify">This tool allows you to generate BAR codes from any text you input. The generated BAR code can be downloaded and used in various applications such as inventory management, product labeling, and more.</p>
|
<!-- <h2 class="text-center">Alert: Text should not exceed 165 characters.</h2> -->
|
||||||
<div class="diZMaxW600 diZFlexColumn diZmxAuto toolsSection diZmy20">
|
<form id="barGenerator" action="" class="flex-direction-col">
|
||||||
<form id="barGenerator" action="" class="diZFlexColumn">
|
<textarea class="" name="" id="barCodeText" cols="36" rows="10" required style="background-color: #3d3d3d; padding: 6px;" autofocus></textarea>
|
||||||
<textarea class="" name="" id="barCodeText" rows="12" required autofocus></textarea><br>
|
<input class="" onclick="displayBarCode();" id="generatButton" type="submit" value="Generate BAR Code" style="background-color: #3d3d3d; padding: 10px 20px 10px 20px; border-radius: 10px; cursor: pointer; margin-top: 10px;">
|
||||||
<button onclick="displayBarCode();" id="generatButton"><span>Generate BAR Code</span></button>
|
</form>
|
||||||
<!-- <input class="" onclick="displayBarCode();" id="generatButton" type="submit" value="Generate BAR Code" > -->
|
<div class="">
|
||||||
</form>
|
<svg id="barCode"></svg>
|
||||||
<div class="diZJustifyCenter diZFlexColumn diZItemsCenter">
|
<div class="" id="buttonContainer">
|
||||||
<svg id="barCode"></svg>
|
<button class="" id="download-button" style="background-color: #3d3d3d; padding: 10px 20px 10px 20px; border-radius: 10px; cursor: pointer; margin-top: 10px;">Download</button>
|
||||||
<div class="diZmt4 diZFlexRow" id="buttonContainer">
|
<button class="" onclick="getNewCode();" style="background-color: #3d3d3d; padding: 10px 20px 10px 20px; border-radius: 10px; cursor: pointer; margin-top: 10px;">New BAR Code</button>
|
||||||
<button class="" id="download-button" ><span>Download</span></button>
|
|
||||||
<button class="" onclick="getNewCode();" ><span>New BAR Code</span></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><strong>Enter Text:</strong> Input your desired text into the text area provided.</li>
|
|
||||||
<li><strong>Generate BAR Code:</strong> Click the "Generate BAR Code" button to convert the text into a BAR code.</li>
|
|
||||||
<li><strong>View BAR Code:</strong> The generated BAR code will appear in the area below the button.</li>
|
|
||||||
<li><strong>Download BAR Code:</strong> Click the "Download" button to save the BAR code as an image file.</li>
|
|
||||||
<li><strong>Generate New BAR Code:</strong> Click the "New BAR Code" button to clear the text area and generate a new BAR code.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Features:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Generates BAR codes quickly and efficiently.</li>
|
|
||||||
<li>Supports various text inputs.</li>
|
|
||||||
<li>Provides a download option for the generated BAR code.</li>
|
|
||||||
<li>Easy-to-use interface with clear instructions.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Example Use Cases:</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Businesses creating product labels for inventory management.</li>
|
|
||||||
<li>Retail stores generating BAR codes for pricing and checkout systems.</li>
|
|
||||||
<li>Developers testing BAR code generation in their applications.</li>
|
|
||||||
<li>Individuals organizing personal collections with BAR code labels.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<script src="/assets/html2canvas.min.js"></script>
|
<script src="/assets/html2canvas.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -51,8 +22,7 @@
|
|||||||
const barText = document.getElementById('barCodeText');
|
const barText = document.getElementById('barCodeText');
|
||||||
document.getElementById('barCodeText').style.display = 'block';
|
document.getElementById('barCodeText').style.display = 'block';
|
||||||
document.getElementById('buttonContainer').style.display = 'none';
|
document.getElementById('buttonContainer').style.display = 'none';
|
||||||
document.getElementById('generatButton').style.display = 'flex';
|
document.getElementById('generatButton').style.display = 'block';
|
||||||
document.getElementById('barCode').style.display = 'none';
|
|
||||||
barGenerator.addEventListener('submit', async function (event) {
|
barGenerator.addEventListener('submit', async function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const formData = {
|
const formData = {
|
||||||
@@ -64,9 +34,8 @@
|
|||||||
function displayBarCode(){
|
function displayBarCode(){
|
||||||
JsBarcode("#barCode", barCodeText.value);
|
JsBarcode("#barCode", barCodeText.value);
|
||||||
document.getElementById('barCodeText').style.display = 'none';
|
document.getElementById('barCodeText').style.display = 'none';
|
||||||
document.getElementById('buttonContainer').style.display = 'flex';
|
document.getElementById('buttonContainer').style.display = 'block';
|
||||||
document.getElementById('generatButton').style.display = 'none';
|
document.getElementById('generatButton').style.display = 'none';
|
||||||
document.getElementById('barCode').style.display = 'block';
|
|
||||||
|
|
||||||
// console.log(barCodeText)
|
// console.log(barCodeText)
|
||||||
}
|
}
|
||||||
@@ -99,4 +68,15 @@
|
|||||||
function getNewCode(){
|
function getNewCode(){
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<style>
|
||||||
|
.container-zz{width:100%}@media (min-width: 640px){.container-zz{max-width:640px}}@media (min-width: 768px){.container-zz{max-width:768px}}@media (min-width: 1024px){.container-zz{max-width:1024px}}@media (min-width: 1280px){.container-zz{max-width:1280px}}@media (min-width: 1536px){.container-zz{max-width:1536px}}
|
||||||
|
.mx-auto{margin-left:auto;margin-right:auto}
|
||||||
|
.my-20{margin-top:5rem;margin-bottom:5rem}
|
||||||
|
.flex-direction-col{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
107
base64-to-image-converter.php
Normal file
107
base64-to-image-converter.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<div class="container-ddz">
|
||||||
|
<h2 style="text-align: center; font-size: 25px; margin-bottom: 10px;">Convert Base64 to Image</h2>
|
||||||
|
<textarea class="base64-textarea" placeholder="Enter base64 encoded image data"></textarea>
|
||||||
|
<p id="no-select-message" style="display: none; color: red;"></p>
|
||||||
|
<button class="convert-button">Convert to Image</button>
|
||||||
|
<div class="preview-container" id="preview"></div>
|
||||||
|
<div id="download-options" style="display: none; display: flex; flex-direction: column; justify-content: center; ">
|
||||||
|
<p>Choose Image Format & Download:</p>
|
||||||
|
<div>
|
||||||
|
<button class="format-button" data-format="png">PNG</button>
|
||||||
|
<button class="format-button" data-format="jpeg">JPEG</button>
|
||||||
|
<button class="format-button" data-format="webp">WebP</button>
|
||||||
|
<button id="download-button" style="display: none;">Download Image</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.querySelector('.convert-button').addEventListener('click', function() {
|
||||||
|
var base64Data = document.querySelector('.base64-textarea').value.trim();
|
||||||
|
if (base64Data !== '') {
|
||||||
|
var img = document.createElement('img');
|
||||||
|
img.src = base64Data;
|
||||||
|
img.style.maxWidth = '100%';
|
||||||
|
img.style.height = 'auto';
|
||||||
|
document.getElementById('preview').innerHTML = '';
|
||||||
|
document.getElementById('preview').appendChild(img);
|
||||||
|
document.getElementById('download-options').style.display = 'block';
|
||||||
|
} else {
|
||||||
|
document.getElementById('no-select-message').innerHTML = 'Please enter base64 encoded image data.';
|
||||||
|
document.getElementById('no-select-message').style.display = 'block';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add event listeners to format buttons
|
||||||
|
var formatButtons = document.querySelectorAll('.format-button');
|
||||||
|
formatButtons.forEach(function(button) {
|
||||||
|
button.addEventListener('click', function() {
|
||||||
|
var imageFormat = this.getAttribute('data-format');
|
||||||
|
downloadImage(imageFormat);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function downloadImage(imageFormat) {
|
||||||
|
var base64Data = document.querySelector('.base64-textarea').value.trim();
|
||||||
|
var downloadLink = document.createElement('a');
|
||||||
|
downloadLink.href = base64Data;
|
||||||
|
downloadLink.download = 'image.' + imageFormat;
|
||||||
|
downloadLink.click();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container-ddz {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
.preview-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.base64-textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 150px;
|
||||||
|
padding: 8px;
|
||||||
|
resize: none;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.convert-button {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: white;
|
||||||
|
padding: 6px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.convert-button:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
.format-button {
|
||||||
|
display: inline-block;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: white;
|
||||||
|
padding: 6px 12px;
|
||||||
|
margin: 5px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.format-button:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="color-shades-generator">
|
<div class="color-shades-generator">
|
||||||
<h1>Color Shades Generator</h1>
|
<h1>Color Shades Generator</h1>
|
||||||
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center;">
|
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center;">
|
||||||
<label for="colorInput">Choose Color</label>
|
<label for="colorInput" style="color: #000;">Choose Color</label>
|
||||||
<input type="color" id="colorInput" class="color-input" value="#ff0000" />
|
<input type="color" id="colorInput" class="color-input" value="#ff0000" />
|
||||||
</div>
|
</div>
|
||||||
<div id="colorShades" class="color-shades"></div>
|
<div id="colorShades" class="color-shades"></div>
|
||||||
@@ -99,12 +99,14 @@
|
|||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
background-color: #fff;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
.color-shades-generator h1 {
|
.color-shades-generator h1 {
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
color: #333;
|
||||||
}
|
}
|
||||||
.color-input {
|
.color-input {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
29
get-a-name.php
Normal file
29
get-a-name.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
// Function to generate a random name
|
||||||
|
function generateRandomName($length = 6) {
|
||||||
|
$vowels = array('a', 'e', 'i', 'o', 'u');
|
||||||
|
$consonants = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z');
|
||||||
|
|
||||||
|
$name = '';
|
||||||
|
$is_vowel = mt_rand(0, 1);
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$source = $is_vowel ? $vowels : $consonants;
|
||||||
|
$name .= $source[mt_rand(0, count($source) - 1)];
|
||||||
|
$is_vowel = !$is_vowel;
|
||||||
|
}
|
||||||
|
return ucfirst($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$randomFirstName = generateRandomName(mt_rand(4, 8));
|
||||||
|
$randomLastName = generateRandomName(mt_rand(4, 8));
|
||||||
|
?>
|
||||||
|
<div class="container-zz mx-auto my-20">
|
||||||
|
<h2 style="font-size: 25px; text-align: center;">Get a Random Name</h2>
|
||||||
|
<p style="font-size: 25px;">First Name: <?php echo $randomFirstName; ?> </p>
|
||||||
|
<p style="font-size: 25px;">Last Name: <?php echo $randomLastName; ?> </p>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.container-zz{width:100%}@media (min-width: 640px){.container-zz{max-width:640px}}@media (min-width: 768px){.container-zz{max-width:768px}}@media (min-width: 1024px){.container-zz{max-width:1024px}}@media (min-width: 1280px){.container-zz{max-width:1280px}}@media (min-width: 1536px){.container-zz{max-width:1536px}}
|
||||||
|
.mx-auto{margin-left:auto;margin-right:auto}
|
||||||
|
.my-20{margin-top:5rem;margin-bottom:5rem}
|
||||||
|
</style>
|
||||||
20
get-a-number.php
Normal file
20
get-a-number.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
function generateRandomUniqueNumber($length = 10) {
|
||||||
|
$randomNumber = '';
|
||||||
|
|
||||||
|
// Generate a random string of digits
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomNumber .= mt_rand(0, 9);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append a unique identifier (based on microtime)
|
||||||
|
$uniqueId = uniqid();
|
||||||
|
$randomUniqueNumber = $randomNumber . $uniqueId;
|
||||||
|
|
||||||
|
return $randomUniqueNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage
|
||||||
|
$randomUniqueNumber = generateRandomUniqueNumber();
|
||||||
|
echo $randomUniqueNumber;
|
||||||
|
?>
|
||||||
106
hex-to-rgb-generator.php
Normal file
106
hex-to-rgb-generator.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<div style="padding-bottom: 350px;">
|
||||||
|
<div class="container-dzx">
|
||||||
|
<h1>HEX to RGB Converter</h1>
|
||||||
|
<label for="hex">HEX Color:</label><br>
|
||||||
|
<input onchange="visibleColor();" type="text" id="hex" value="#" pattern="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" required style="background-color: #3d3d3d; width: 150px; padding: 8px; border-radius: 5px; border: 1px solid #ccc; margin-bottom: 10px;">
|
||||||
|
<br>
|
||||||
|
<!-- <div id="hexColor" style="width: 50px; height: 50px;">Code</div> -->
|
||||||
|
<!-- <input type="color" id="hexColor" name="hexColor" > -->
|
||||||
|
<button id="convert-button" class="button-style" onclick="convertHexToRgb()">Convert</button>
|
||||||
|
<div style="display: flex; flex-direction: row; justify-content: center; align-items: center; place-items: center;">
|
||||||
|
<div id="result"></div>
|
||||||
|
<div>
|
||||||
|
<button id="copyButton" style="display: none; padding: 5px 10px 5px 10px; background-color: #7d7d7d; border-radius: 5px;" onclick="copyToClipboard()">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function hexToRgb(hex) {
|
||||||
|
hex = hex.replace(/^#/, '');
|
||||||
|
if (hex.length === 3) {
|
||||||
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
||||||
|
}
|
||||||
|
var bigint = parseInt(hex, 16);
|
||||||
|
var r = (bigint >> 16) & 255;
|
||||||
|
var g = (bigint >> 8) & 255;
|
||||||
|
var b = bigint & 255;
|
||||||
|
return [r, g, b];
|
||||||
|
}
|
||||||
|
function visibleColor(){
|
||||||
|
var hexColorCode = document.getElementById('hex').value;
|
||||||
|
document.getElementById('convert-button').style.backgroundColor = hexColorCode;
|
||||||
|
}
|
||||||
|
function convertHexToRgb() {
|
||||||
|
var hexColor = document.getElementById('hex').value;
|
||||||
|
var rgbArray = hexToRgb(hexColor);
|
||||||
|
var red = rgbArray[0];
|
||||||
|
var green = rgbArray[1];
|
||||||
|
var blue = rgbArray[2];
|
||||||
|
|
||||||
|
document.getElementById('result').textContent = "HEX " + hexColor + " is equivalent to RGB(" + red + ", " + green + ", " + blue + ")";
|
||||||
|
|
||||||
|
document.getElementById('copyButton').style.display = 'inline-block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard() {
|
||||||
|
var rgbText = document.getElementById('result').textContent.split('equivalent to ')[1];
|
||||||
|
var textarea = document.createElement('textarea');
|
||||||
|
textarea.value = rgbText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'RGB values copied successfully';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container-dzx {
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0px 0px 10px 0px #FFFFFF80;
|
||||||
|
padding: 20px;
|
||||||
|
max-width: 500px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
transform: translate(-50%, -70%);
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
input[type="number"] {
|
||||||
|
width: 100px;
|
||||||
|
padding: 8px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-style{
|
||||||
|
padding: 10px 20px;
|
||||||
|
/* background-color: #7d7d7d; */
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.button-style:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#result {
|
||||||
|
color: #007bff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
84
html-cleaner.php
Normal file
84
html-cleaner.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<div class="page-container">
|
||||||
|
<div class="container-dxc">
|
||||||
|
<h1 style="text-align: center; font-size: 25px;">HTML Remover</h1>
|
||||||
|
<label for="htmlInput">Input Text with HTML:</label>
|
||||||
|
<textarea class="cleanhtml-textarea" id="htmlInput" placeholder="Paste your text with html here..."></textarea>
|
||||||
|
<button class="button-style" onclick="cleanHTML()" style="width: 100%;">Remove</button>
|
||||||
|
|
||||||
|
<label for="cleanedHTML">Cleaned Text:</label>
|
||||||
|
<textarea class="cleanhtml-textarea" id="cleanedHTML" readonly placeholder="Cleaned Text will appear here..."></textarea>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button class="button-style" onclick="copyToClipboard()" style="width: 100%;">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function cleanHTML() {
|
||||||
|
const inputHTML = document.getElementById("htmlInput").value;
|
||||||
|
|
||||||
|
// Create a temporary element to hold the input HTML
|
||||||
|
const tempDiv = document.createElement("div");
|
||||||
|
tempDiv.innerHTML = inputHTML;
|
||||||
|
|
||||||
|
// Remove all HTML tags
|
||||||
|
const plainText = tempDiv.textContent || tempDiv.innerText || "";
|
||||||
|
|
||||||
|
document.getElementById("cleanedHTML").value = plainText;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard() {
|
||||||
|
const cleanedHTML = document.getElementById("cleanedHTML").value;
|
||||||
|
navigator.clipboard.writeText(cleanedHTML)
|
||||||
|
.then(() => {
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Slug copied to clipboard!';
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('Failed to copy: ', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.page-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
/* background-color: #f4f4f4; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-dxc {
|
||||||
|
max-width: 600px;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
padding: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0px 0px 10px rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.cleanhtml-textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 200px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 5px;
|
||||||
|
resize: vertical;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-style{
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.button-style:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
131
image-compressor.php
Normal file
131
image-compressor.php
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<div class="containezx" style="padding: 10px;">
|
||||||
|
<h1 style="font-size: 20px;">Image Compression Tool</h1>
|
||||||
|
<input type="file" id="imageInput" accept="image/*">
|
||||||
|
<br>
|
||||||
|
<label for="qualityInput">Compression Quality:</label>
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
|
<input type="range" id="qualityInput" min="1" max="100" step="1" value="10" />
|
||||||
|
<span id="qualityValue" style="margin-top: -8px; font-size: 20px;">10%</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="image-preview">
|
||||||
|
<img id="preview" src="" alt="" />
|
||||||
|
</div>
|
||||||
|
<span id="imageSize" class="image-size"></span>
|
||||||
|
<br>
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
|
<button class="comp-button" onclick="compressImage()">Compress Image</button>
|
||||||
|
<a class="comp-button" id="downloadLink" href="#" download="compressed_image.jpg" style="display: none; margin-left: 20px;">Download Compressed Image</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function compressImage() {
|
||||||
|
const fileInput = document.getElementById('imageInput');
|
||||||
|
const file = fileInput.files[0];
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
alert('Please select an image file.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = function(event) {
|
||||||
|
const image = new Image();
|
||||||
|
image.src = event.target.result;
|
||||||
|
|
||||||
|
image.onload = function() {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
canvas.width = image.width;
|
||||||
|
canvas.height = image.height;
|
||||||
|
console.log(image.width)
|
||||||
|
ctx.drawImage(image, 0, 0);
|
||||||
|
|
||||||
|
const qualityInput = document.getElementById('qualityInput');
|
||||||
|
const qualityValue = parseFloat(qualityInput.value) / 100; // Normalize quality value to range 0-1
|
||||||
|
|
||||||
|
canvas.toBlob(function(blob) {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const preview = document.getElementById('preview');
|
||||||
|
const downloadLink = document.getElementById('downloadLink');
|
||||||
|
|
||||||
|
preview.src = url;
|
||||||
|
downloadLink.href = url;
|
||||||
|
downloadLink.style.display = 'block';
|
||||||
|
|
||||||
|
const imageSizeSpan = document.getElementById('imageSize');
|
||||||
|
const compressedSize = (blob.size / 1024).toFixed(2); // Convert bytes to kilobytes and round to 2 decimal places
|
||||||
|
imageSizeSpan.textContent = `Compressed Image Size: ${compressedSize} KB`;
|
||||||
|
}, 'image/jpeg', qualityValue); // Pass normalized quality value to toBlob
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('qualityInput').addEventListener('input', function() {
|
||||||
|
document.getElementById('qualityValue').textContent = this.value + "%";
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.containezx {
|
||||||
|
margin-top: 100px;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 100px auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 5px #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="file"] {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="range"] {
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-preview {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#preview {
|
||||||
|
max-width: 100%;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-size {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.comp-button{
|
||||||
|
background-color: #6d6d6d;
|
||||||
|
padding: 10px 20px 10px 20px;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
padding: 10px 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.comp-button:hover{
|
||||||
|
background-color: #8d8d8d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
75
image-to-base64-converter.php
Normal file
75
image-to-base64-converter.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<div class="container-dx">
|
||||||
|
<h2 style="text-align: center; font-size: 25px; margin-bottom: 10px;">Convert Image to Base64</h2>
|
||||||
|
<input type="file" class="image-input" accept="image/*">
|
||||||
|
<div class="preview-container" id="preview" style=""></div>
|
||||||
|
<textarea class="base64-textarea" readonly></textarea>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button class="copy-button">Copy Base64</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.querySelector('.image-input').addEventListener('change', function() {
|
||||||
|
var file = this.files[0];
|
||||||
|
if (file) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function(e) {
|
||||||
|
var base64 = e.target.result;
|
||||||
|
var img = document.createElement('img');
|
||||||
|
img.src = base64;
|
||||||
|
document.getElementById('preview').innerHTML = '';
|
||||||
|
document.getElementById('preview').appendChild(img);
|
||||||
|
document.querySelector('.base64-textarea').value = base64;
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelector('.copy-button').addEventListener('click', function() {
|
||||||
|
var base64TextArea = document.querySelector('.base64-textarea');
|
||||||
|
base64TextArea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Base64 copied to clipboard!';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.container-dx {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
.preview-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.base64-textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 150px;
|
||||||
|
padding: 8px;
|
||||||
|
resize: none;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
}
|
||||||
|
.copy-button {
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.copy-button:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
24
index.php
24
index.php
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
$ROOT = __DIR__; // /var/www/html
|
|
||||||
|
|
||||||
require_once $ROOT.'/.hta_config/conf.php';
|
|
||||||
require_once $ROOT.'/.hta_config/var.php';
|
|
||||||
require_once $ROOT.'/.hta_slug/_header.php';
|
|
||||||
require_once $ROOT.'/.hta_slug/_nav.php';
|
|
||||||
|
|
||||||
$url = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
|
|
||||||
$slug = $url[0] ?? '';
|
|
||||||
|
|
||||||
if ($slug === '') {
|
|
||||||
require_once $ROOT.'/.hta_slug/_home.php';
|
|
||||||
} elseif (file_exists($ROOT.'/.hta_slug/'.$slug.'.php')) {
|
|
||||||
require_once $ROOT.'/.hta_slug/'.$slug.'.php';
|
|
||||||
} else {
|
|
||||||
require_once $ROOT.'/.hta_slug/_404.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once $ROOT.'/.hta_slug/_footer.php';
|
|
||||||
169
letter-case-converter.php
Normal file
169
letter-case-converter.php
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
<div class="container-cc">
|
||||||
|
<div class="content-cc">
|
||||||
|
<h2 class="title-cc">Case Converter</h2>
|
||||||
|
<form class="form-cc">
|
||||||
|
<label class="label-cc" for="inputString">Input Text:</label>
|
||||||
|
<textarea id="inputString" class="textarea-cc" name="inputString" rows="4" cols="50" oninput="convertCase()"></textarea>
|
||||||
|
|
||||||
|
<div class="case-options-cc">
|
||||||
|
<div class="case-option-cc" onclick="setActive(this)" data-case="uppercase">Uppercase</div>
|
||||||
|
<div class="case-option-cc" onclick="setActive(this)" data-case="lowercase">Lowercase</div>
|
||||||
|
<div class="case-option-cc" onclick="setActive(this)" data-case="titlecase">Titlecase</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="result" class="result-cc"></div>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button type="button" class="copy-button-cc" onclick="copyToClipboard()" style="background-color: #7d7d7d; width: 100%; margin-top: 10px;">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function convertCase() {
|
||||||
|
var inputString = document.getElementById("inputString").value;
|
||||||
|
var targetCase = document.querySelector('.case-option-cc.active').getAttribute('data-case');
|
||||||
|
var result = document.getElementById("result");
|
||||||
|
|
||||||
|
if (inputString.trim() === "") {
|
||||||
|
result.innerHTML = "Please enter a string.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetCase === 'uppercase') {
|
||||||
|
result.innerHTML = inputString.toUpperCase();
|
||||||
|
} else if (targetCase === 'lowercase') {
|
||||||
|
result.innerHTML = inputString.toLowerCase();
|
||||||
|
} else if (targetCase === 'titlecase') {
|
||||||
|
result.innerHTML = inputString.replace(/\w\S*/g, function (txt) {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
result.innerHTML = "Invalid target case specified.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setActive(button) {
|
||||||
|
var buttons = document.querySelectorAll('.case-option-cc');
|
||||||
|
buttons.forEach(function(btn) {
|
||||||
|
btn.classList.remove('active');
|
||||||
|
});
|
||||||
|
button.classList.add('active');
|
||||||
|
|
||||||
|
convertCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard() {
|
||||||
|
var result = document.getElementById("result");
|
||||||
|
var range = document.createRange();
|
||||||
|
range.selectNode(result);
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
window.getSelection().addRange(range);
|
||||||
|
document.execCommand("copy");
|
||||||
|
window.getSelection().removeAllRanges();
|
||||||
|
// alert("Copied to clipboard!");
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Copied to clipboard!';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.container-cc {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
/* background-color: #3d3d3d; */
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 30px;
|
||||||
|
/* padding-bottom: 30px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-cc {
|
||||||
|
/* background-color: #7d7d7d; */
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
padding: 20px;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
.content-cc {
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
|
||||||
|
padding: 20px;
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1024px) {
|
||||||
|
.content-cc {
|
||||||
|
width: 800px; /* Width for large screens */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-cc {
|
||||||
|
font-size: 25px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-cc {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-cc {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
/* color: #555; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea-cc {
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
resize: none;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.case-options-cc {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.case-option-cc {
|
||||||
|
flex-grow: 1;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #007bff;
|
||||||
|
color: #FFF;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.case-option-cc:hover {
|
||||||
|
background-color: #007bff;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-cc {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
min-height: 100px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-button-cc {
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-button-cc:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
.active{
|
||||||
|
background-color: #05b3a4;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
198
letter-counter.php
Normal file
198
letter-counter.php
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
<style>
|
||||||
|
/* body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.container-dyz {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 50px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.table-container {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 50px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea-text {
|
||||||
|
width: 100%;
|
||||||
|
height: 150px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
resize: vertical;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
font-size: 16px;
|
||||||
|
background-color: #1d1d1d;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
color: #007bff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.content-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
.content-table th, .content-table td {
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
.content-table .table-head {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="container-dyz">
|
||||||
|
<h1>Text Counter</h1>
|
||||||
|
<label for="inputText">Enter your text:</label><br>
|
||||||
|
<textarea class="textarea-text" id="inputText" placeholder="Type your text here..." oninput="countTextMetrics()"></textarea>
|
||||||
|
<p>Total letters: <span id="letterCount">0</span></p>
|
||||||
|
<p>Total words: <span id="wordCount">0</span></p>
|
||||||
|
<p>Total sentences: <span id="sentenceCount">0</span></p>
|
||||||
|
<p>Total paragraphs: <span id="paragraphCount">0</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="table-container">
|
||||||
|
<h2 style="text-align: center; font-size: 25px; font-weight: bold;">Content Limitations</h2>
|
||||||
|
<table class="content-table">
|
||||||
|
<tr>
|
||||||
|
<th class="name">Name</th>
|
||||||
|
<th class="min-max">Min/Max</th>
|
||||||
|
<th class="limit">Limit</th>
|
||||||
|
<th class="type">Type</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Meta Title</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">55</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Meta Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">160</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Google Ideal Post Content</td>
|
||||||
|
<td class="min-max">Min</td>
|
||||||
|
<td class="limit">300</td>
|
||||||
|
<td class="type">Word</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Instagram Captions/Comments</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">2200</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Twitter Post</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">280</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Twitter Username</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">20</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Wall Post (Truncation)</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">477</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Wall Post (All)</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">63206</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Comment</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">8000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Page Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">255</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Username</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">50</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Messenger Message</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">20000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">YouTube Video Title</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">70</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">YouTube Video Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">5000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Snapchat Caption</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">250</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Pinterest Pin Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">500</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function countTextMetrics() {
|
||||||
|
const text = document.getElementById('inputText').value;
|
||||||
|
|
||||||
|
// Count letters
|
||||||
|
const letterCount = text.replace(/[^a-zA-Z]/g, '').length;
|
||||||
|
document.getElementById('letterCount').textContent = letterCount;
|
||||||
|
|
||||||
|
// Count words
|
||||||
|
const words = text.split(/\s+/).filter(word => word.length > 0);
|
||||||
|
const wordCount = words.length;
|
||||||
|
document.getElementById('wordCount').textContent = wordCount;
|
||||||
|
|
||||||
|
// Count sentences
|
||||||
|
const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);
|
||||||
|
const sentenceCount = sentences.length;
|
||||||
|
document.getElementById('sentenceCount').textContent = sentenceCount;
|
||||||
|
|
||||||
|
// Count paragraphs
|
||||||
|
const paragraphs = text.split(/\n\n+/).filter(paragraph => paragraph.trim().length > 0);
|
||||||
|
const paragraphCount = paragraphs.length;
|
||||||
|
document.getElementById('paragraphCount').textContent = paragraphCount;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
3
location.php
Normal file
3
location.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
echo 'Current Location';
|
||||||
|
?>
|
||||||
121
md5-decryption.php
Normal file
121
md5-decryption.php
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<style>
|
||||||
|
.button-style-md5{
|
||||||
|
padding: 20px 20px;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.button-style-md5:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-container {
|
||||||
|
max-width: 500px;
|
||||||
|
margin: 50px auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0px 0px 10px 0px rgba(255,255,255,0.1);
|
||||||
|
}
|
||||||
|
.custom-heading {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
.custom-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.custom-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.custom-submit {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.custom-submit:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php require_once ('.hta_config/siliconpin_sp.php'); ?>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
try {
|
||||||
|
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||||
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$stmt = $db->prepare("SELECT * FROM md5_data WHERE md5 = :md5");
|
||||||
|
$stmt->bindParam(':md5', $_POST["md5-hash"]);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
echo '<div style="display: flex; justify-content: center;">
|
||||||
|
<div style="display: flex; flex-direction: column; justify-content: center;">
|
||||||
|
<p style="text-align: center; font-size: 25px; ">Given MD5 Vlue: </p>
|
||||||
|
<p style="display: none; text-align: center;" id="copied-notice"></p>
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
|
<input id="output" type="text" readonly value="'.$result['value'].'" style="color: #fff; padding: 10px 10px 10px 10px; font-size: 25px; outline: none;" />
|
||||||
|
<button class="button-style-md5" id="copyButton" onclick="copyOutputText()">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
echo '
|
||||||
|
<script>
|
||||||
|
function copyOutputText() {
|
||||||
|
const outputText = document.getElementById(\'output\').value;
|
||||||
|
const textarea = document.createElement(\'textarea\');
|
||||||
|
textarea.value = outputText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand(\'copy\');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById(\'copied-notice\').style.display = \'block\';
|
||||||
|
document.getElementById(\'copied-notice\').innerHTML = \'MD5 value copied to clipboard!\';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
echo '<div style="display: flex; justify-content: center;">
|
||||||
|
<div style="display: flex; flex-direction: column; justify-content: center;">
|
||||||
|
<p style="text-align: center; font-size: 25px; ">No data found for the given MD5 hash </p>
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
|
<button class="button-style-md5" id="" onclick="tryAgain()">Try Again</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
echo ' <script>
|
||||||
|
function tryAgain() {
|
||||||
|
window.location.href="/tools/md5-decryption";
|
||||||
|
}
|
||||||
|
</script>' ;
|
||||||
|
// echo json_encode(array('success' => false, 'message' => 'No data found for the given MD5 hash'));
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="custom-container">
|
||||||
|
<h2 class="custom-heading">MD5 Decryption</h2>
|
||||||
|
<form method="post" action="">
|
||||||
|
<label for="md5-hash" class="custom-label">Enter Text:</label><br>
|
||||||
|
<input type="text" id="md5-hash" name="md5-hash" class="custom-input"><br><br>
|
||||||
|
<input type="submit" value="Generate MD5 Hash" class="custom-submit" style="background-color: #7d7d7d;">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
118
md5-encryption.php
Normal file
118
md5-encryption.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<style>
|
||||||
|
.button-style-md5{
|
||||||
|
padding: 20px 20px;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.button-style-md5:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
.custom-container {
|
||||||
|
max-width: 500px;
|
||||||
|
margin: 50px auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0px 0px 10px 0px rgba(255,255,255,0.1);
|
||||||
|
}
|
||||||
|
.custom-heading {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 25px;
|
||||||
|
/* color: #333; */
|
||||||
|
}
|
||||||
|
.custom-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.custom-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.custom-submit {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.custom-submit:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php
|
||||||
|
require_once ('.hta_config/siliconpin_sp.php');
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
|
||||||
|
$md5_hash = md5($_POST["md5-text"]);
|
||||||
|
try {
|
||||||
|
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||||
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$stmt = $db->prepare("INSERT INTO md5_data (md5, value) VALUES (:md5, :value)");
|
||||||
|
$stmt->bindParam(':md5', $md5_hash);
|
||||||
|
$stmt->bindParam(':value', $_POST["md5-text"]);
|
||||||
|
$stmt->execute();
|
||||||
|
echo '<div style="display: flex; justify-content: center;">
|
||||||
|
<div style="display: flex; flex-direction: column; justify-content: center;">
|
||||||
|
<p style="text-align: center; font-size: 25px; ">Converted MD5: </p>
|
||||||
|
<p style="display: none; text-align: center;" id="copied-notice"></p>
|
||||||
|
<div style="display: flex; flex-direction: row;">
|
||||||
|
<input id="output" type="text" readonly value="'.$md5_hash.'" style="color: #fff; padding: 10px 10px 10px 10px; font-size: 25px; outline: none;" />
|
||||||
|
<button class="button-style-md5" id="copyButton" onclick="copyOutputText()">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
echo '
|
||||||
|
<script>
|
||||||
|
function copyOutputText() {
|
||||||
|
const outputText = document.getElementById(\'output\').value;
|
||||||
|
const textarea = document.createElement(\'textarea\');
|
||||||
|
textarea.value = outputText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand(\'copy\');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById(\'copied-notice\').style.display = \'block\';
|
||||||
|
document.getElementById(\'copied-notice\').innerHTML = \'MD5 copied to clipboard!\';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
// echo json_encode(array('success' => true, 'message' => 'Data inserted successfully'));
|
||||||
|
// echo '<script>window.location.href="/admin/add-content";</script>';
|
||||||
|
exit();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="custom-container">
|
||||||
|
<h2 class="custom-heading">Generate MD5 Hash</h2>
|
||||||
|
<form method="post">
|
||||||
|
<label for="md5-text" class="custom-label">Enter Text:</label><br>
|
||||||
|
<input type="text" id="md5-text" name="md5-text" class="custom-input"><br><br>
|
||||||
|
<input type="submit" value="Generate MD5 Hash" class="custom-submit" style="background-color: #7d7d7d;">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!-- <script>
|
||||||
|
function copyOutputText() {
|
||||||
|
const outputText = document.getElementById('output').value;
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = outputText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Output text copied to clipboard!';
|
||||||
|
}
|
||||||
|
</script> -->
|
||||||
84
multiple-whitespace-remover.php
Normal file
84
multiple-whitespace-remover.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<div style="padding-bottom: 350px;">
|
||||||
|
<div class="container-dxu">
|
||||||
|
<h2 style="text-align: center; font-size: 25px; padding-bottom: 10px;">Remove Multiple Whitespace</h2>
|
||||||
|
<textarea class="textarea-text" id="textInput" rows="4" cols="50" placeholder="Enter text here..."></textarea>
|
||||||
|
<button class="button-style" onclick="processText()">Remove</button>
|
||||||
|
<div style="display: none;" id="after-procces">
|
||||||
|
<div id="output"></div>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button class="button-style" id="copyButton" onclick="copyOutputText()">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function removeMultipleWhitespace(text) {
|
||||||
|
return text.replace(/\s+/g, ' ').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function processText() {
|
||||||
|
const inputText = document.getElementById('textInput').value;
|
||||||
|
const cleanedText = removeMultipleWhitespace(inputText);
|
||||||
|
document.getElementById('output').innerText = cleanedText;
|
||||||
|
document.getElementById('after-procces').style.display='block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyOutputText() {
|
||||||
|
const outputText = document.getElementById('output').innerText;
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = outputText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Output text copied to clipboard!';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.container-dxu {
|
||||||
|
max-width: 600px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 8px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea-text {
|
||||||
|
width: calc(100% );
|
||||||
|
height: 100px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
}
|
||||||
|
.button-style{
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.button-style:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
#output {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
293
open-graph-meta-generator.php
Normal file
293
open-graph-meta-generator.php
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
<div class="meta-container">
|
||||||
|
<h1 class="og-title">Open Graph Meta Generator</h1>
|
||||||
|
<form class="form" id="metaForm">
|
||||||
|
<label for="ogTitle" class="form-label">Title:</label>
|
||||||
|
<input type="text" id="ogTitle" name="ogTitle" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="ogDescription" class="form-label">Description:</label>
|
||||||
|
<textarea id="ogDescription" name="ogDescription" class="form-input form-textarea" rows="4" required></textarea>
|
||||||
|
|
||||||
|
<label for="ogImage" class="form-label">Image URL:</label>
|
||||||
|
<input type="url" id="ogImage" name="ogImage" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="ogUrl" class="form-label">URL:</label>
|
||||||
|
<input type="url" id="ogUrl" name="ogUrl" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="author" class="form-label">Author:</label>
|
||||||
|
<input type="text" id="author" name="author" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="keywords" class="form-label">Keywords:</label>
|
||||||
|
<input type="text" id="keywords" name="keywords" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="twitterTitle" class="form-label">Twitter Title:</label>
|
||||||
|
<input type="text" id="twitterTitle" name="twitterTitle" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="twitterDescription" class="form-label">Twitter Description:</label>
|
||||||
|
<textarea id="twitterDescription" name="twitterDescription" class="form-input form-textarea" rows="4" required></textarea>
|
||||||
|
|
||||||
|
<label for="twitterImage" class="form-label">Twitter Image URL:</label>
|
||||||
|
<input type="url" id="twitterImage" name="twitterImage" class="form-input" required>
|
||||||
|
|
||||||
|
<label for="twitterCard" class="form-label">Twitter Card Type:</label>
|
||||||
|
<select id="twitterCard" name="twitterCard" class="form-input" required>
|
||||||
|
<option value="summary">Summary</option>
|
||||||
|
<option value="summary_large_image">Summary Large Image</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="submit" class="button-style" style="width: 100%; background-color: #7d7d7d;">Generate</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div style="display: none;" class="generated-meta-tags" id="generatedMetaTags"></div>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button id="copyButton" class="button-style" onclick="copyToClipboard()">Copy</button>
|
||||||
|
</div>
|
||||||
|
<div class="table-container">
|
||||||
|
<h2 style="text-align: center; font-size: 25px; font-weight: bold;">Content Limitations</h2>
|
||||||
|
<table class="content-table">
|
||||||
|
<tr>
|
||||||
|
<th class="name">Name</th>
|
||||||
|
<th class="min-max">Min/Max</th>
|
||||||
|
<th class="limit">Limit</th>
|
||||||
|
<th class="type">Type</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Meta Title</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">55</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Meta Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">160</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Google Ideal Post Content</td>
|
||||||
|
<td class="min-max">Min</td>
|
||||||
|
<td class="limit">300</td>
|
||||||
|
<td class="type">Word</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Instagram Captions/Comments</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">2200</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Twitter Post</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">280</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Twitter Username</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">20</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Wall Post (Truncation)</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">477</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Wall Post (All)</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">63206</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Comment</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">8000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Page Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">255</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Username</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">50</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Facebook Messenger Message</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">20000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">YouTube Video Title</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">70</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">YouTube Video Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">5000</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Snapchat Caption</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">250</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name">Pinterest Pin Description</td>
|
||||||
|
<td class="min-max">Max</td>
|
||||||
|
<td class="limit">500</td>
|
||||||
|
<td class="type">Letter</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const form = document.getElementById('metaForm');
|
||||||
|
const generatedMetaTags = document.getElementById('generatedMetaTags');
|
||||||
|
|
||||||
|
form.addEventListener('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const ogTitle = document.getElementById('ogTitle').value.trim();
|
||||||
|
const ogDescription = document.getElementById('ogDescription').value.trim();
|
||||||
|
const ogImage = document.getElementById('ogImage').value.trim();
|
||||||
|
const ogUrl = document.getElementById('ogUrl').value.trim();
|
||||||
|
const author = document.getElementById('author').value.trim();
|
||||||
|
const keywords = document.getElementById('keywords').value.trim();
|
||||||
|
const twitterTitle = document.getElementById('twitterTitle').value.trim();
|
||||||
|
const twitterDescription = document.getElementById('twitterDescription').value.trim();
|
||||||
|
const twitterImage = document.getElementById('twitterImage').value.trim();
|
||||||
|
const twitterCard = document.getElementById('twitterCard').value.trim();
|
||||||
|
|
||||||
|
const metaTags = `
|
||||||
|
<title>${ogTitle}</title>
|
||||||
|
<meta name="description" content="${ogDescription}">
|
||||||
|
<meta name="keywords" content="${keywords}">
|
||||||
|
<meta name="author" content="${author}">
|
||||||
|
<meta property="og:title" content="${ogTitle}">
|
||||||
|
<meta property="og:description" content="${ogDescription}">
|
||||||
|
<meta property="og:image" content="${ogImage}">
|
||||||
|
<meta property="og:url" content="${ogUrl}">
|
||||||
|
<meta name="twitter:title" content="${twitterTitle}">
|
||||||
|
<meta name="twitter:description" content="${twitterDescription}">
|
||||||
|
<meta name="twitter:image" content="${twitterImage}">
|
||||||
|
<meta name="twitter:card" content="${twitterCard}">
|
||||||
|
`;
|
||||||
|
if(metaTags.length>20){
|
||||||
|
document.getElementById('generatedMetaTags').style.display= "block";
|
||||||
|
}
|
||||||
|
generatedMetaTags.innerText = `${metaTags}`;
|
||||||
|
|
||||||
|
});
|
||||||
|
function copyToClipboard() {
|
||||||
|
const metaTags = document.getElementById('generatedMetaTags');
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = metaTags.innerText;
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Meta tags copied to clipboard!';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.meta-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 700px;
|
||||||
|
margin: 20px auto; /* Added to center horizontally */
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header Styles */
|
||||||
|
.og-title {
|
||||||
|
margin-top: 0;
|
||||||
|
font-size: 24px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Styles */
|
||||||
|
.form {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 16px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-textarea {
|
||||||
|
resize: vertical;
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-style{
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.button-style:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generated Meta Tags Styles */
|
||||||
|
.generated-meta-tags {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.generated-meta-tags {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
width: 100%; /* Ensure the width spans the container */
|
||||||
|
box-sizing: border-box; /* Include padding and border in the width */
|
||||||
|
overflow: auto; /* Enable scrolling if content overflows */
|
||||||
|
}
|
||||||
|
.table-container {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 50px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.content-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
.content-table th, .content-table td {
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
.content-table .table-head {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<input type="file" name="pdfFile" accept=".pdf">
|
<input type="file" name="pdfFile" accept=".pdf">
|
||||||
<button type="submit" name="submit"><span>Upload PDF</span></button>
|
<button type="submit" name="submit">Upload PDF</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
File diff suppressed because one or more lines are too long
30
random-password-generator.php
Normal file
30
random-password-generator.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
$time=time();
|
||||||
|
$gen_pass=rand(100,360).$time.rand(100,999);
|
||||||
|
$rand_pass = base_convert($gen_pass,10,36);
|
||||||
|
?>
|
||||||
|
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 20px;">
|
||||||
|
<h1 style="font-size: 25px;">Get a random password</h1>
|
||||||
|
<div style="display: flex; flex-direction: row; margin-top: 20px;">
|
||||||
|
<p style="border: 2px solid #ddd; border-radius: 6px; padding: 5px;">Password: <span id="randPassword"> <?php echo $rand_pass; ?></span></p> <button id="copyButton" style="background-color: #7d7d7d; border-radius: 6px; padding: 0px 10px 0px 10px;">Copy</button>
|
||||||
|
</div>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
</div>
|
||||||
|
<!-- <div id="copyText">This text will be copied when clicked.</div> -->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.getElementById("copyButton").addEventListener("click", function() {
|
||||||
|
// Select the text
|
||||||
|
var copyText = document.getElementById("randPassword");
|
||||||
|
var selection = window.getSelection();
|
||||||
|
var range = document.createRange();
|
||||||
|
range.selectNodeContents(copyText);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
|
||||||
|
// Copy to clipboard
|
||||||
|
document.execCommand("copy");
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Text copied to clipboard!';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -1,27 +1,26 @@
|
|||||||
<section class="diZContainer diZmxAuto diZmt8">
|
<div style="padding-bottom: 350px;">
|
||||||
<h1 class="diZBorderBottom">RGB to HEX Converter</h1>
|
<div class="container-dzx">
|
||||||
<div class="diZmxAuto toolsSection diZMaxW600 diZmy20" >
|
<h1>RGB to HEX Converter</h1>
|
||||||
<div class="diZFlexColumn"><br>
|
<label for="red">Red:</label><br>
|
||||||
<label for="red">Red:</label>
|
<input type="number" id="red" min="0" max="255" required>
|
||||||
<input style="width: 97%;" type="number" id="red" min="0" max="255" required>
|
<br>
|
||||||
|
<label for="green">Green:</label><br>
|
||||||
|
<input type="number" id="green" min="0" max="255" required>
|
||||||
|
<br>
|
||||||
|
<label for="blue">Blue:</label><br>
|
||||||
|
<input type="number" id="blue" min="0" max="255" required>
|
||||||
|
<br>
|
||||||
|
<button class="button-style" onclick="convert()">Convert</button>
|
||||||
|
<div style="display: flex; flex-direction: row; justify-content: center; align-items: center; place-items: center;">
|
||||||
|
<div id="result"></div>
|
||||||
|
<div>
|
||||||
|
<button id="copyButton" style="display: none; padding: 5px 10px 5px 10px; background-color: #7d7d7d; border-radius: 5px;" onclick="copyToClipboard()">Copy</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="diZFlexColumn"><br>
|
<span style="display: none;" id="copied-notice"></span>
|
||||||
<label for="green">Green:</label>
|
|
||||||
<input style="width: 97%;" type="number" id="green" min="0" max="255" required>
|
|
||||||
</div>
|
|
||||||
<div class="diZFlexColumn"><br>
|
|
||||||
<label for="blue">Blue:</label>
|
|
||||||
<input style="width: 97%;" type="number" id="blue" min="0" max="255" required>
|
|
||||||
</div>
|
|
||||||
<div id="result"></div>
|
|
||||||
<div class="diZFlexBetween">
|
|
||||||
<button class="" onclick="convert()"><span>Convert</span></button>
|
|
||||||
<button id="copyButton" onclick="copyToClipboard()"><span>Copy</span></button>
|
|
||||||
</div>
|
|
||||||
<span class="diZDisplayNone" id="copied-notice"></span>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</div>
|
||||||
<!-- diZJustifyCenter diZItemsCenter -->
|
|
||||||
<script>
|
<script>
|
||||||
function rgbToHex(r, g, b) {
|
function rgbToHex(r, g, b) {
|
||||||
r = Math.max(0, Math.min(255, r));
|
r = Math.max(0, Math.min(255, r));
|
||||||
68
slug-generator.php
Normal file
68
slug-generator.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<div class="container-dxe">
|
||||||
|
<h1 style="text-align: center; font-size: 25px; padding-bottom: 6px;">Slug Generator</h1>
|
||||||
|
<input class="slug-input" type="text" id="inputText" placeholder="Enter text">
|
||||||
|
<button class="button-style" onclick="generateSlug()">Generate Slug</button>
|
||||||
|
<div id="slugOutput" style="border: 2px solid #ddd; display: none; padding: 6px; border-radius: 6px; margin-top: 10px;"></div>
|
||||||
|
<P style="display: none; text-align: center;" id="copied-notice"></P>
|
||||||
|
<button class="button-style" style="margin-top: 10px; width: 100%; display: none;" id="copyBtn" onclick="copyToClipboard()">Copy Slug</button>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function generateSlug() {
|
||||||
|
const inputText = document.getElementById('inputText').value;
|
||||||
|
const slugOutput = document.getElementById('slugOutput');
|
||||||
|
|
||||||
|
// Generate slug
|
||||||
|
const slug = inputText.trim().toLowerCase().replace(/[^\w\s-]/g, '').replace(/\s+/g, '-');
|
||||||
|
// console.log(slug.length)
|
||||||
|
// Update output
|
||||||
|
if(slug.length > 0){
|
||||||
|
document.getElementById('copyBtn').style.display = 'block';
|
||||||
|
document.getElementById('slugOutput').style.display = 'block';
|
||||||
|
}
|
||||||
|
slugOutput.textContent = slug;
|
||||||
|
|
||||||
|
}
|
||||||
|
function copyToClipboard() {
|
||||||
|
const slugOutput = document.getElementById('slugOutput');
|
||||||
|
const textArea = document.createElement('textarea');
|
||||||
|
textArea.value = slugOutput.textContent;
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
document.getElementById('copied-notice').style.display = 'block';
|
||||||
|
document.getElementById('copied-notice').innerHTML = 'Slug copied to clipboard!';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.container-dxe {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 50px auto;
|
||||||
|
background-color: #3d3d3d;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slug-input {
|
||||||
|
width: calc(100%);
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-style{
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #7d7d7d;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.button-style:hover {
|
||||||
|
background-color: #9d9d9d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Internet Speed Test</h1>
|
<h1>Internet Speed Test</h1>
|
||||||
<button onclick="runSpeedTest()"><span>Run Speed Test</span></button>
|
<button onclick="runSpeedTest()">Run Speed Test</button>
|
||||||
<div id="result"></div>
|
<div id="result"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('.htac_header.php');
|
require_once('.hta_config/siliconpin_sp.php');
|
||||||
require_once('.hta_config/db_config.php');
|
require_once('.htac_header.php');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section class="container-zz mx-auto">
|
<section class="container-zz mx-auto">
|
||||||
@@ -10,7 +10,7 @@ echo 'Weather Report';
|
|||||||
<option value="Kolkata">Kolkata</option>
|
<option value="Kolkata">Kolkata</option>
|
||||||
<option value="Delhi">Delhi</option>
|
<option value="Delhi">Delhi</option>
|
||||||
</select> -->
|
</select> -->
|
||||||
<button type="submit" name="submit" onsubmit="getCity();"><span>Click</span></button>
|
<button type="submit" name="submit" onsubmit="getCity();">Click</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
14
what-is-my-dns.php
Normal file
14
what-is-my-dns.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
$host_name = $_SERVER['HTTP_HOST'];
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container-zz mx-auto">
|
||||||
|
<p>Hosting Name:</p>
|
||||||
|
<p><?php echo $host_name; ?></p>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.container-zz{width:100%}@media (min-width: 640px){.container-zz{max-width:640px}}@media (min-width: 768px){.container-zz{max-width:768px}}@media (min-width: 1024px){.container-zz{max-width:1024px}}@media (min-width: 1280px){.container-zz{max-width:1280px}}@media (min-width: 1536px){.container-zz{max-width:1536px}}
|
||||||
|
.mx-auto{margin-left:auto;margin-right:auto}
|
||||||
|
.my-20{margin-top:5rem;margin-bottom:5rem}
|
||||||
|
</style>
|
||||||
19
what-is-my-ip.php
Normal file
19
what-is-my-ip.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
// Get the IPv4 address of the client
|
||||||
|
// echo $_SERVER['REMOTE_ADDR'];
|
||||||
|
$ipv4 = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
// Get the IPv6 address of the client if available
|
||||||
|
$ipv6 = $_SERVER['REMOTE_ADDR'];
|
||||||
|
if (strpos($ipv6, ":") !== false) {
|
||||||
|
// IPv6 address detected
|
||||||
|
$ipv6 = explode("%", $ipv6)[0]; // Remove interface suffix, if any
|
||||||
|
} else {
|
||||||
|
// No IPv6 address detected
|
||||||
|
$ipv6 = "IPv6 not available";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display IPv4 and IPv6 addresses
|
||||||
|
echo "IPv4 Address: " . $ipv4 . "<br>";
|
||||||
|
echo "IPv6 Address: " . $ipv6 . "<br>";
|
||||||
|
?>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user