Skip to content

Commit

Permalink
[TASK] Adapt command for updating IP database automatically to create…
Browse files Browse the repository at this point in the history
… transient directory if not existing, update static IP database SQL file, update documentation
  • Loading branch information
davkraid committed Jan 6, 2025
1 parent 3e0e446 commit b201b29
Show file tree
Hide file tree
Showing 5 changed files with 860,998 additions and 53 deletions.
3 changes: 3 additions & 0 deletions Classes/Command/UpdateIpDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ private function validateArguments(): bool
}

$this->path = Environment::getVarPath() . '/transient';
if (!is_dir($this->path)) {
mkdir($this->path, 0775);
}
if (is_writable($this->path)) {
if ($this->table === 'static_ip2country_v4') {
$this->databaseCode = 'DB1LITECSV';
Expand Down
45 changes: 44 additions & 1 deletion Documentation/Admin/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ composer setups. If your TYPO3 is not running in composer mode, you have to prov
Updating the IP Database
========================

We try to update the supplied IP database every quarter. For this update we provide a new patchlevel release of this extension.
We try to update the supplied IP database at least every major update.
After this new version has been installed, you can update your local database via the Extension Manager module in your TYPO3
backend as shown below.

Expand All @@ -99,6 +99,49 @@ backend as shown below.

You can update your local IP tables via the Extension Manager module.

You also can update the IP database automatically via console command or scheduler task.

.. _admin-updatingIPDatabase-token:

Get Download-Token from ip2location.com
---------------------------------------

To update the IP database automatically, you have to generate a Download-Token from https://lite.ip2location.com/.
Frist, sign up at https://lite.ip2location.com/sign-up. After creating an account, you can login and access the page
https://lite.ip2location.com/database-download. There you can find the Download-Token.

.. figure:: ../Images/download-token.png
:alt: Download-Token from ip2location.com
:class: with-shadow

.. _admin-updatingIPDatabase-command:

Update database via console command
-----------------------------------

You can update the IP database via console command.

.. code-block:: bash
vendor/bin/typo3 locate:updateIpDatabase TOKEN [static_ip2country_v4|static_ip2country_v6]
Replace "TOKEN" with your own Download-Token and choose a database table you want to update. You can choose between
"static_ip2country_v4" for IPv4 or "static_ip2country_v6" for IPv6.

.. _admin-updatingIPDatabase-scheduler:

Update database via scheduler task
----------------------------------

You also can add a scheduler task to update the IP database periodically. Add a scheduler task in the TYPO3 backend:

.. figure:: ../Images/scheduler-task.png
:alt: Add Scheduler Task
:class: with-shadow

Set "token" with your own Download-Token and choose a database "table" you want to update. You can choose between
"static_ip2country_v4" for IPv4 or "static_ip2country_v6" for IPv6.

.. _admin-enablingExtension:

Enabling this Extension
Expand Down
Loading

0 comments on commit b201b29

Please sign in to comment.