From 210c855033d327e53341f476f882563f8c05d645 Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Sun, 9 Aug 2020 10:12:37 +0100 Subject: [PATCH] Fix Maxmind Geoip invalid Type Error Fix error that occurs if a null value is provided to the Geoip Library, also set default Geoip value for variables that are missing it in the admin theme and the forum module --- src/bb-library/Box/TwigExtensions.php | 6 ++- .../Forum/html_admin/mod_forum_topic.phtml | 14 ++--- .../html/mod_activity_index.phtml | 2 +- .../html/mod_client_manage.phtml | 54 +++++++++---------- .../html/mod_invoice_transaction.phtml | 22 ++++---- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/bb-library/Box/TwigExtensions.php b/src/bb-library/Box/TwigExtensions.php index c7c32230c..519b2bfa0 100644 --- a/src/bb-library/Box/TwigExtensions.php +++ b/src/bb-library/Box/TwigExtensions.php @@ -97,6 +97,10 @@ class Box_TwigExtensions extends Twig\Extension\AbstractExtension implements \Bo function twig_ipcountryname_filter($value) { + if (empty($value)) { + return ''; + } + try { $record = $this->di['geoip']->country($value); return $record->country->name; @@ -286,4 +290,4 @@ function twig_bbmd_filter(Twig_Environment $env, $value) { $value = twig_markdown_filter($env, $value); return $value; -} \ No newline at end of file +} diff --git a/src/bb-modules/Forum/html_admin/mod_forum_topic.phtml b/src/bb-modules/Forum/html_admin/mod_forum_topic.phtml index 418baf118..62527fa6b 100644 --- a/src/bb-modules/Forum/html_admin/mod_forum_topic.phtml +++ b/src/bb-modules/Forum/html_admin/mod_forum_topic.phtml @@ -25,7 +25,7 @@ {{ topic.forum.title }} - + {{ topic.title }} @@ -47,7 +47,7 @@ {{ mf.status_name(topic.status) }} - + {{ mf.q(topic.sticky) }} @@ -131,9 +131,9 @@ - + - + @@ -182,7 +182,7 @@
@@ -200,7 +200,7 @@ - {{ message.ip|default('-') }} {{ message.ip|ipcountryname }} + {{ message.ip|default('-') }} {{ message.ip|ipcountryname|default('Unknown') }} @@ -235,4 +235,4 @@ {% endblock %} -{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} \ No newline at end of file +{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} diff --git a/src/bb-themes/admin_default/html/mod_activity_index.phtml b/src/bb-themes/admin_default/html/mod_activity_index.phtml index bd35235e4..11a9ad62e 100644 --- a/src/bb-themes/admin_default/html/mod_activity_index.phtml +++ b/src/bb-themes/admin_default/html/mod_activity_index.phtml @@ -36,7 +36,7 @@
{{ event.message }}
{{ event.ip }} - {{ event.ip|ipcountryname }} + {{ event.ip|ipcountryname|default('Unknown') }} {{ event.created_at|date('Y-m-d H:i') }} diff --git a/src/bb-themes/admin_default/html/mod_client_manage.phtml b/src/bb-themes/admin_default/html/mod_client_manage.phtml index b48b3735b..97e5f78d5 100644 --- a/src/bb-themes/admin_default/html/mod_client_manage.phtml +++ b/src/bb-themes/admin_default/html/mod_client_manage.phtml @@ -34,7 +34,7 @@
{{ client.first_name }} {{ client.last_name }}
- + @@ -69,7 +69,7 @@ - + @@ -158,7 +158,7 @@
  • - +
    @@ -179,12 +179,12 @@
  • -
    +
    - +
    {% trans 'Address and contact details' %}
    @@ -238,9 +238,9 @@
  • - -
    -
    + + +
    @@ -251,25 +251,25 @@
    - +
    {% trans 'Additional settings' %}
    -
    -
    +
    +
    - +
    {{ mf.selectbox('currency', guest.currency_get_pairs, client.currency, 0, 'Select currency') }} -
    +
    - +
    @@ -296,7 +296,7 @@
    - +

    {% trans 'Change password' %}

    @@ -327,7 +327,7 @@

    {% trans 'Custom fields' %}

    {% trans 'Use these fields to define custom client details' %}

    - +
    {% for i in 1..10 %} @@ -386,7 +386,7 @@
    IP:{{ client.ip|default('-') }} {{ client.ip|ipcountryname }}{{ client.ip|default('-') }} {{ client.ip|ipcountryname|default('Unknown') }}
    API Key:
    - +

    {% trans 'Add funds for client' %}

    @@ -400,7 +400,7 @@
    - +
    @@ -448,7 +448,7 @@ {% endfor %} - + @@ -492,7 +492,7 @@ {% endfor %} - + @@ -517,7 +517,7 @@   - + {% set tickets = admin.support_ticket_get_list({"per_page":"20", "client_id":client.id}) %} {% for ticket in tickets.list %} @@ -534,7 +534,7 @@ {% endfor %} - + @@ -544,12 +544,12 @@
    - +

    {% trans 'Logins history' %}

    - + @@ -564,7 +564,7 @@ {% for i, login in logins.list %} - + {% else %} @@ -682,7 +682,7 @@ - + @@ -745,4 +745,4 @@ function onAfterInvoicePrepared(id) { bb.redirect("{{'invoice/manage/'|alink}}/"+id); } -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/bb-themes/admin_default/html/mod_invoice_transaction.phtml b/src/bb-themes/admin_default/html/mod_invoice_transaction.phtml index 815e47037..687143521 100644 --- a/src/bb-themes/admin_default/html/mod_invoice_transaction.phtml +++ b/src/bb-themes/admin_default/html/mod_invoice_transaction.phtml @@ -37,7 +37,7 @@ {% endif%} - +
    {{login.ip}}{{login.ip|ipcountryname}}{{login.ip|ipcountryname|default('Unknown')}} {{login.created_at|date('l, d F Y')}}
    IP:{{ client.ip }} {{ client.ip|ipcountryname }}{{ client.ip }} {{ client.ip|ipcountryname|default('Unknown') }}
    Address:
    @@ -69,7 +69,7 @@ - + @@ -77,7 +77,7 @@ - + {% if transaction.note %} @@ -140,7 +140,7 @@
    - +
    {% trans 'Transaction processing information' %}
    @@ -159,7 +159,7 @@
    - +
    {% trans 'Transaction information on payment gateway' %}
    @@ -212,7 +212,7 @@
    - +

    {% trans 'GET' %}

    @@ -233,7 +233,7 @@
    {% endif %} - +

    {% trans 'POST' %}

    @@ -253,7 +253,7 @@

    {% trans 'No POST parameters received' %}

    {% endif %} - +

    {% trans 'SERVER' %}

    @@ -273,8 +273,8 @@

    {% trans 'No SERVER parameters logged' %}

    {% endif %} - - + +

    {{ 'http_raw_post_data'|upper}}

    @@ -294,4 +294,4 @@
    -{% endblock %} \ No newline at end of file +{% endblock %}
    {% trans 'Transaction status on payment gateway' %} {{ mf.status_name(transaction.txn_status) }}
    {% trans 'Status' %} {{ mf.status_name(transaction.status) }}
    {% trans 'IP' %}{{ transaction.ip }} {{ transaction.ip|ipcountryname }}{{ transaction.ip }} {{ transaction.ip|ipcountryname|default('Unknown') }}