Plugin Directory

Changeset 2473929


Ignore:
Timestamp:
02/12/2021 07:15:47 PM (5 years ago)
Author:
digilan
Message:

better wifi4eu support

Location:
digilan-token/trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • digilan-token/trunk/admin/digilan-admin.php

    r2293612 r2473929  
    3030    }
    3131
    32     public static function getAdminUrl($view = 'access-point')
    33     {
    34         return add_query_arg(array(
    35             'page' => 'digilan-token-plugin',
    36             'view' => $view
    37         ), admin_url('admin.php'));
     32    public static function getAdminBaseUrl()
     33    {
     34        $url_query = array('page' => 'digilan-token-plugin');
     35        $admin_url = admin_url('admin.php');
     36        return add_query_arg($url_query, $admin_url);
     37    }
     38
     39    public static function getAdminUrl($view)
     40    {
     41        $url_query = array('page' => 'digilan-token-plugin');
     42        if ($view) {
     43            $url_query['view'] = $view;
     44        }
     45        $base_admin_url = self::getAdminBaseUrl();
     46        return add_query_arg($url_query, $base_admin_url);
    3847    }
    3948
     
    140149                    }
    141150                }
    142                 wp_redirect(self::getAdminUrl());
     151                wp_redirect(self::getAdminBaseUrl());
    143152                exit();
    144153            }
     
    164173                }
    165174            }
    166            
     175
    167176            $view = DigilanTokenSanitize::sanitize_request('view');
    168177            if (substr($view, 0, 9) == 'provider-') {
     
    253262                    self::validate_ap_settings($hostname, $ssid, $country_code, $intervals);
    254263                }
    255                
     264
    256265            } else if ($view == 'logs') {
    257266                if (isset($_POST['digilan-download'])) {
     
    281290                    DigilanTokenConnection::download_mails_csv($start, $end);
    282291                }
    283             } else if ($view == 'settings') { 
     292            } else if ($view == 'settings') {
    284293                $cityscope_cloud = DigilanTokenSanitize::sanitize_post('cityscope-backend');
    285294                if (false === $cityscope_cloud) {
     
    290299                self::updateCityscopeCloud($cityscope_cloud);
    291300            }
    292             wp_redirect(self::getAdminUrl());
     301            wp_redirect(self::getAdminBaseUrl());
    293302            exit();
    294303        }
     
    414423            'portal-page' => $portal_page
    415424        );
    416         if (DigilanToken::isRouter()) {
     425        if (DigilanToken::isFromCitybox()) {
    417426            if (null == json_decode($schedule) || false == json_decode($schedule)) {
    418427                \DLT\Notices::addError(sprintf(__('%s is an invalid timetable data.'), $schedule));
     
    535544        $endpoint .= '/version';
    536545        $args = array (
    537             'timeout' => 3 
     546            'timeout' => 3
    538547        );
    539548        $request = wp_remote_get($endpoint, $args);
  • digilan-token/trunk/admin/templates/access-point.php

    r2293612 r2473929  
    9090      </table>
    9191
    92 <?php if (DigilanToken::isRouter()) : ?>
     92<?php if (DigilanToken::isFromCitybox()) : ?>
    9393      <h2><?php _e('Schedule configuration', 'digilan-token'); ?></h2>
    9494      <table class="form-table">
  • digilan-token/trunk/admin/templates/connections.php

    r2293612 r2473929  
    1818$re = '/^[0-9A-Za-z]{32}$/';
    1919$secret = get_option('digilan_token_secret');
    20 if (DigilanToken::isRouter() || preg_match($re, $secret) == 1) :
     20if (DigilanToken::isFromCitybox() || preg_match($re, $secret) == 1) :
    2121?>
    2222  <div class="dlt-admin-content">
  • digilan-token/trunk/admin/templates/header.php

    r2293612 r2473929  
    2121    <div class="dlt-admin-header">
    2222        <h1>
    23             <a href="<?php echo DigilanTokenAdmin::getAdminUrl(); ?>">
     23            <a href="<?php echo DigilanTokenAdmin::getAdminBaseUrl(); ?>">
    2424                <img src="<?php echo plugins_url('images/mrwifi.png', DLT_ADMIN_PATH) ?>" width="64" height="64" alt="Digilan Token" />
    2525                Monsieur WiFi</a>
  • digilan-token/trunk/admin/templates/menu.php

    r2293612 r2473929  
    2121?>
    2222<div class="dlt-admin-nav-bar">
    23     <?php if (DigilanToken::isRouter()) : ?>
     23    <?php if (DigilanToken::isFromCitybox()) : ?>
    2424        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('access-point'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'access-point') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Configuration', 'digilan-token'); ?></a>
    25         <a href="<?php echo DigilanTokenAdmin::getAdminUrl(); ?>" class="dlt-admin-nav-tab<?php if ($view === 'providers') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Providers', 'digilan-token'); ?></a>
     25        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('providers'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'providers') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Providers', 'digilan-token'); ?></a>
    2626        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('connections'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'connections') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Connections', 'digilan-token'); ?></a>
    2727        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('settings'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'settings') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Settings', 'digilan-token'); ?></a>
    2828    <?php elseif (preg_match($re, $secret) == 1) : ?>
    29         <a href="<?php echo DigilanTokenAdmin::getAdminUrl(); ?>" class="dlt-admin-nav-tab<?php if ($view === 'access-point') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Configuration', 'digilan-token'); ?></a>
     29        <a href="<?php echo DigilanTokenAdmin::getAdminBaseUrl(); ?>" class="dlt-admin-nav-tab<?php if ($view === 'access-point') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Configuration', 'digilan-token'); ?></a>
    3030        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('providers'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'providers') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Providers', 'digilan-token'); ?></a>
    3131        <a href="<?php echo DigilanTokenAdmin::getAdminUrl('connections'); ?>" class="dlt-admin-nav-tab<?php if ($view === 'connections') : ?> dlt-admin-nav-tab-active<?php endif; ?>"><?php _e('Connections', 'digilan-token'); ?></a>
  • digilan-token/trunk/admin/templates/providers.php

    r2293612 r2473929  
    1717$secret = get_option('digilan_token_secret');
    1818$re = '/^[0-9A-Za-z]{32}$/';
    19 if (DigilanToken::isRouter() || preg_match($re, $secret) == 1) :
     19if (DigilanToken::isFromCitybox() || preg_match($re, $secret) == 1) :
    2020?>
    2121  <div class="dlt-dashboard-providers-container">
  • digilan-token/trunk/digilan-token.php

    r2293612 r2473929  
    44 * Plugin URI: https://www.citypassenger.com
    55 * Description: This plugin helps transform a WordPress into a third party authenticator services.
    6  * Version: 1
     6 * Version: 2.8
    77 * Author: Citypassenger
    88 * Text Domain: digilan
     
    7676{
    7777
    78     public static $digilan_version = 2.7;
     78    public static $digilan_version = 2.8;
    7979
    8080    /** @var DigilanTokenSettings */
     
    199199    }
    200200
    201     public static function isRouter()
     201    public static function isFromCitybox()
    202202    {
    203203        if (!defined('ABSPATH')) {
     
    316316                    __('Sun', 'digilan-token')
    317317                );
    318                 if (self::isRouter()) {
     318                if (self::isFromCitybox()) {
    319319                    wp_register_script('dlt-access-point-router', plugins_url('/js/admin/access-point-router.js', __FILE__), array(
    320320                        'jquery'
     
    451451    {
    452452        global $wpdb;
    453         $query = "SELECT post_name FROM wp_posts WHERE post_name = '%s'";
     453        $query = "SELECT post_name FROM {$wpdb->prefix}posts WHERE post_name = '%s'";
    454454        $query = $wpdb->prepare($query, 'digilan-token-error');
    455455        if (null === $wpdb->get_row($query, ARRAY_A)) {
     
    471471    {
    472472        global $wpdb;
    473         $query = "SELECT post_name FROM wp_posts WHERE post_name = '%s'";
     473        $query = "SELECT post_name FROM {$wpdb->prefix}posts WHERE post_name = '%s'";
    474474        $query = $wpdb->prepare($query, 'captive-portal');
    475475        if (null === $wpdb->get_row($query, ARRAY_A)) {
     
    495495                $wifi4eu_img = '<img id="wifi4eu-placeholder" src="https://collection.wifi4eu.ec.europa.eu/media/banner/Wifi4EU-FR.svg">';
    496496            }
    497         } 
     497        }
    498498        $wifi4eu_id = get_option('digilan_token_wifi4eu');
    499         $data = array(
    500             'networkIdentifier' => $wifi4eu_id,
    501             'language' => substr(get_locale(), 0, 2)
    502         );
    503         wp_register_script('wifi4eu_info', plugins_url('/js/wifi4eu_info.js', __FILE__));
    504         wp_enqueue_script('wifi4eu_info');
    505         wp_localize_script('wifi4eu_info', 'wifi4eu_data', $data);
    506         wp_enqueue_script('wifi4eu_script', 'https://collection.wifi4eu.ec.europa.eu/wifi4eu.min.js');
     499        if ($wifi4eu_id) {
     500            wp_register_script('wifi4eu_info', '');
     501            wp_enqueue_script('wifi4eu_info');
     502            $wifi4eu_script  = 'var wifi4euTimerStart = Date.now();';
     503            $wifi4eu_script .= 'var wifi4euNetworkIdentifier = '. json_encode($wifi4eu_id).';';
     504            $wifi4eu_script .= 'var wifi4euLanguage = '. json_encode(substr(get_locale(), 0, 2)) .';';
     505            wp_add_inline_script('wifi4eu_info', $wifi4eu_script);
     506        } else {
     507            error_log("WIFI4EU snippet issue: no wifi4eu key defined (key provided : ' . $wifi4eu_id . ')");
     508        }
     509        wp_enqueue_script('wifi4eu_script', 'https://collection.wifi4eu.ec.europa.eu/wifi4eu.min.js'); # need for banner auto load
    507510        return $wifi4eu_img;
    508511    }
     
    535538    static function nextClosingDay($closed_time_period,$x)
    536539    {
    537         for ($index = 0; $index < 6; $index++) 
     540        for ($index = 0; $index < 6; $index++)
    538541        {
    539542            $id = self::getNextDay(self::nextDays($x)[$index]);
     
    551554        return $day;
    552555    }
    553  
     556
    554557    public static function getNextOpeningDate($closed_time_period, $next)
    555558    {
     
    613616    public static function isWifiClosed($session_id)
    614617    {
     618        if (self::isFromCitybox()) { #TODO local diff here
     619            return false;
     620        }
    615621        $aps = self::$settings->get('access-points');
    616622        $keys = array_keys($aps);
     
    704710        $idx = $keys[$query_source_access_point];
    705711        $access_point = $access_points[$idx];
    706         if (self::isRouter()) {
     712        if (self::isFromCitybox()) {
    707713            if ($mac) {
    708714                $next = self::isWifiClosed($sid);
     
    729735                }
    730736            }
    731             if (self::isRouter()) {
     737            if (self::isFromCitybox()) {
    732738                if ($mac) {
    733739                    $closed_time_period = json_decode($closed_time_period, true);
    734740                    $next_opening_date = self::getNextOpeningDate($closed_time_period, $next);
    735741                } else {
    736                     $next_opening_date = self::getNextOpeningDate($router_schedule, $next); 
     742                    $next_opening_date = self::getNextOpeningDate($router_schedule, $next);
    737743                }
    738744            } else {
     
    742748            $msg = __('Wifi will be available ', 'digilan-token');
    743749            if ($next_opening_date === 'closed') {
    744                 $msg = __('Wifi is currently closed for an undefined period of time', 'digilan-token');   
     750                $msg = __('Wifi is currently closed for an undefined period of time', 'digilan-token');
    745751            } elseif ($next_opening_date === 'tomorrow') {
    746752                $msg = __('Wifi will be opened tomorrow', 'digilan-token');
     
    789795        $ret = '<center><div class="dlt-container ' . self::$styles[$style]['container'] . '">' . $heading . $buttons . '</div>';
    790796        $ret .= '<div id="dlt-gtu" style="color:' . $textcolor . ';font-size: ' . $textsize . 'px; text-shadow: 1px 1px #000000;"><input type="checkbox" id="dlt-tos" unchecked>' . $text_below . '</div></center>';
    791         wp_enqueue_script('dlt-terms', plugins_url('/js/terms-and-conditions.js', DLT_PLUGIN_BASENAME));
     797        wp_enqueue_script( 'jquery' );
     798        wp_enqueue_script('dlt-terms', plugins_url('/js/terms-and-conditions.js', DLT_PLUGIN_BASENAME), array('jquery'));
    792799        return $ret;
    793800    }
     
    809816            'access-points' => $access_points
    810817        );
    811         if (self::isRouter()) {
     818        if (self::isFromCitybox()) {
    812819            $data['schedule-router'] = self::$settings->get('schedule_router');
    813820        }
     
    10201027    public static function getDigilanVersion()
    10211028    {
    1022         wp_die(self::$digilan_version, '', 200);
     1029        status_header( 200 );
     1030        echo self::$digilan_version;
     1031        die;
    10231032    }
    10241033
  • digilan-token/trunk/includes/digilan-activator.php

    r2293612 r2473929  
    2424        $secret = get_option('digilan_token_secret');
    2525        $mode = get_option('digilan_token_mode');
    26         if (DigilanToken::isRouter()) {
     26        if (DigilanToken::isFromCitybox()) {
    2727            $mode = 2;
    2828        }
  • digilan-token/trunk/includes/digilan-connection.php

    r2293612 r2473929  
    5858               {$wpdb->prefix}digilan_token_connections_$version.authentication_mode,
    5959               {$wpdb->prefix}digilan_token_users_$version.social_id,
    60                {$wpdb->prefix}digilan_token_users_$version.mac   
     60               {$wpdb->prefix}digilan_token_users_$version.mac
    6161        FROM {$wpdb->prefix}digilan_token_connections_$version
    6262        LEFT JOIN {$wpdb->prefix}digilan_token_users_$version ON {$wpdb->prefix}digilan_token_connections_$version.user_id = {$wpdb->prefix}digilan_token_users_$version.id
     
    103103               {$wpdb->prefix}digilan_token_active_sessions_$version.authentication_mode,
    104104               {$wpdb->prefix}digilan_token_users_$version.social_id,
    105                {$wpdb->prefix}digilan_token_users_$version.mac   
     105               {$wpdb->prefix}digilan_token_users_$version.mac
    106106        FROM {$wpdb->prefix}digilan_token_active_sessions_$version
    107107        LEFT JOIN {$wpdb->prefix}digilan_token_users_$version ON {$wpdb->prefix}digilan_token_active_sessions_$version.user_id = {$wpdb->prefix}digilan_token_users_$version.id
     
    400400        $digilan_token_secret = DigilanTokenSanitize::sanitize_get('digilan-token-secret');
    401401        $digilan_token_wp_secret = get_option('digilan_token_secret');
    402         if (DigilanToken::isRouter()) {
     402        if (DigilanToken::isFromCitybox()) {
    403403            if ($digilan_token_wp_secret === $digilan_token_secret) {
    404404                return true;
    405405            }
    406             return 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' == $digilan_token_secret;
     406            return false;
    407407        }
    408408        return $digilan_token_wp_secret == $digilan_token_secret;
     
    472472                'auth_type' => $auth_mode
    473473            );
     474            if (DigilanToken::isFromCitybox()) {
     475                $settings = DigilanToken::$settings;
     476                $langing_page = $settings->get('landing-page');
     477                $data_array += array(
     478                    'landing_page' => $langing_page
     479                );
     480            }
    474481            $response = wp_json_encode($data_array);
    475482        }
  • digilan-token/trunk/includes/digilan-db.php

    r2293612 r2473929  
    4444    }
    4545
    46     private static $sql_users = "CREATE TABLE %sdigilan_token_users_1 (
    47     id INT AUTO_INCREMENT PRIMARY KEY,
    48     mac BIGINT,
    49     social_id CHAR(254),
    50     creation DATETIME DEFAULT CURRENT_TIMESTAMP
    51     )";
     46    function wp_digilan_token_users() {
     47        global $wpdb;
     48        $sql_users = "CREATE TABLE %sdigilan_token_users_1 (
     49                id INT NOT NULL AUTO_INCREMENT,
     50                mac BIGINT,
     51                social_id CHAR(254),
     52                creation DATETIME DEFAULT CURRENT_TIMESTAMP
     53                PRIMARY KEY  (id)
     54                )";
     55        return sprintf($sql_users, $wpdb->prefix);
     56    }
    5257
    53     private static $sql_connections = "CREATE TABLE %sdigilan_token_connections_1 (
    54     id INT AUTO_INCREMENT PRIMARY KEY,
    55     user_ip BIGINT,
    56     ap_mac BIGINT,
    57     creation DATETIME DEFAULT CURRENT_TIMESTAMP,
    58     ap_validation DATETIME,
    59     wp_validation DATETIME,
    60     secret CHAR(32) NOT NULL,
    61     authentication_mode CHAR(254),
    62     sessionid CHAR(32) NOT NULL,
    63     user_id INT,
    64     FOREIGN KEY `fk_digilan_token_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
    65     )";
     58    function wp_digilan_token_connections_current() {
     59        global $wpdb;
     60        $sql_current_connections = "CREATE TABLE %sdigilan_token_active_sessions_1 (
     61                id INT NOT NULL AUTO_INCREMENT,
     62                user_ip BIGINT,
     63                ap_mac BIGINT,
     64                creation DATETIME DEFAULT CURRENT_TIMESTAMP,
     65                ap_validation DATETIME,
     66                wp_validation DATETIME,
     67                secret CHAR(32) NOT NULL,
     68                authentication_mode CHAR(254),
     69                sessionid CHAR(32) NOT NULL,
     70                user_id INT,
     71                PRIMARY KEY  (id),
     72                FOREIGN KEY `fk_%sdigilan_token_curr_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
     73                )";
     74        return sprintf($sql_current_connections, $wpdb->prefix, $wpdb->prefix, $wpdb->prefix);
     75    }
    6676
    67     private static $sql_current_connections = "CREATE TABLE %sdigilan_token_active_sessions_1 (
    68     id INT AUTO_INCREMENT PRIMARY KEY,
    69     user_ip BIGINT,
    70     ap_mac BIGINT,
    71     creation DATETIME DEFAULT CURRENT_TIMESTAMP,
    72     ap_validation DATETIME,
    73     wp_validation DATETIME,
    74     secret CHAR(32) NOT NULL,
    75     authentication_mode CHAR(254),
    76     sessionid CHAR(32) NOT NULL,
    77     user_id INT,
    78     FOREIGN KEY `fk_digilan_token_curr_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
    79     )";
     77    function wp_digilan_token_connections() {
     78        global $wpdb;
     79        $sql_connections = "CREATE TABLE %sdigilan_token_connections_1 (
     80            id INT NOT NULL AUTO_INCREMENT,
     81            user_ip BIGINT,
     82            ap_mac BIGINT,
     83            creation DATETIME DEFAULT CURRENT_TIMESTAMP,
     84            ap_validation DATETIME,
     85            wp_validation DATETIME,
     86            secret CHAR(32) NOT NULL,
     87            authentication_mode CHAR(254),
     88            sessionid CHAR(32) NOT NULL,
     89            user_id INT,
     90            PRIMARY KEY  (id),
     91            FOREIGN KEY `fk_%sdigilan_token_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
     92            )";
     93        return sprintf($sql_connections, $wpdb->prefix, $wpdb->prefix, $wpdb->prefix);
     94    }
    8095
    81     private static $sql_version = "CREATE TABLE %sdigilan_token_version (
    82     version INT NOT NULL
    83     )";
     96    function wp_digilan_token_version() {
     97        global $wpdb;
     98        return sprintf("CREATE TABLE %sdigilan_token_version (
     99            version INT NOT NULL
     100            )", $wpdb->prefix);
     101    }
    84102
    85     private static $sql_social_users = "CREATE TABLE %sdigilan_token_social_users_1 (
    86     `ID` int(11) NOT NULL,
    87     `type` varchar(20) NOT NULL,
    88     `identifier` varchar(100) NOT NULL,
    89     KEY `ID` (`ID`,`type`)
    90     );";
     103    function wp_digilan_token_logs() {
     104        global $wpdb;
     105        return sprintf("CREATE TABLE %sdigilan_token_logs (
     106                        `date` DATETIME,
     107                        `user_id` INT,
     108                        `domain` VARCHAR(253),
     109                        FOREIGN KEY `fk_%sdigilan_token_logs_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
     110        );", $wpdb->prefix, $wpdb->prefix, $wpdb->prefix);
     111    }
    91112
    92     private static $sql_logs = "CREATE TABLE %sdigilan_token_logs (
    93     `date` DATETIME,
    94     `user_id` INT,
    95     `domain` VARCHAR(253),
    96     FOREIGN KEY `fk_digilan_token_logs_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
    97     );";
    98113
    99     private static $sql_archive_logs = "CREATE TABLE %sdigilan_token_logs_archive (
    100     `date` DATETIME,
    101     `user_id` INT,
    102     `domain` VARCHAR(253),
    103     FOREIGN KEY `fk_digilan_token_logs_archive_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
    104     );";
     114    function wp_digilan_token_archive_logs() {
     115        global $wpdb;
     116        return sprintf("CREATE TABLE %sdigilan_token_logs_archive (
     117                        `date` DATETIME,
     118                        `user_id` INT,
     119                        `domain` VARCHAR(253),
     120                        FOREIGN KEY `fk_%sdigilan_token_logs_archive_1` (user_id) REFERENCES %sdigilan_token_users_1(id)
     121            );", $wpdb->prefix, $wpdb->prefix, $wpdb->prefix);
     122    }
     123
     124    function wp_digilan_social_users() {
     125        global $wpdb;
     126        return sprintf("CREATE TABLE %sdigilan_token_social_users_1 (
     127                `ID` int(11) NOT NULL,
     128                `type` varchar(20) NOT NULL,
     129                `identifier` varchar(100) NOT NULL,
     130                KEY `ID` (`ID`,`type`)
     131            );", $wpdb->prefix);
     132    }
    105133
    106134    public static function install_plugin_tables()
     
    109137        $installed_version = self::$installed_version;
    110138        $sqls = array(
    111             "wp_digilan_token_users" => sprintf(self::$sql_users, $wpdb->prefix),
    112             "wp_digilan_token_connections_current" => sprintf(self::$sql_current_connections, $wpdb->prefix, $wpdb->prefix),
    113             "wp_digilan_token_connections" => sprintf(self::$sql_connections, $wpdb->prefix, $wpdb->prefix),
    114             "wp_digilan_token_version" => sprintf(self::$sql_version, $wpdb->prefix),
    115             "wp_digilan_token_logs" => sprintf(self::$sql_logs, $wpdb->prefix, $wpdb->prefix),
    116             "wp_digilan_token_archive_logs" => sprintf(self::$sql_archive_logs, $wpdb->prefix, $wpdb->prefix),
    117             "wp_digilan_social_users" => sprintf(self::$sql_social_users, $wpdb->prefix)
     139            "wp_digilan_token_users" => self::wp_digilan_token_users(),
     140            "wp_digilan_token_connections_current" => self::wp_digilan_token_connections_current(),
     141            "wp_digilan_token_connections" => self::wp_digilan_token_connections(),
     142            "wp_digilan_token_version" => self::wp_digilan_token_version(),
     143            "wp_digilan_token_logs" => self::wp_digilan_token_logs(),
     144            "wp_digilan_token_archive_logs" => self::wp_digilan_token_archive_logs(),
     145            "wp_digilan_social_users" => self::wp_digilan_social_users()
    118146        );
    119147        $charset_collate = $wpdb->get_charset_collate();
  • digilan-token/trunk/includes/digilan-logs.php

    r2293612 r2473929  
    1818class DigilanTokenLogs
    1919{
     20    # user_id in _digilan_token_users_ is int(11)
     21    static $bigint = array("options" => array("min_range" => 0, "max_range" => 2147483648));
    2022
    2123    public static function store_dns_logs()
    2224    {
     25        global $wpdb;
    2326        $is_valid_secret = DigilanTokenConnection::validate_wordpress_AP_secret();
    2427        if (!$is_valid_secret) {
     
    3336        $logs = json_decode($logs);
    3437        if (empty($logs)) {
    35             $data = array(
    36                 'message' => 'Empty or invalid data sent.'
    37             );
    38             $data = wp_json_encode($data);
    39             wp_die($data, '', 500);
     38            wp_send_json(array('message' => 'POST successful.'));
     39            die;
    4040        }
    4141        $timezone = get_option('gmt_offset');
     42        $inserts_logs = array();
     43        $groupstoinsertnum = 0; # number row to insert in db
    4244        foreach ($logs as $log) {
    43             $date = $log->date;
    44             $user_id = $log->user_id;
    45             $domain = $log->domain;
    46             $date_time = new DateTime($date);
     45            try {
     46                $date_time = new DateTime($log->date);
     47            } catch (Exception $e) {
     48                error_log('store_dns_logs/check_domain : Invalid date. Command `new DateTime(' .$log->date. ')`' . $e);
     49                continue;
     50            }
    4751            $date_time->modify('+' . $timezone . 'hours');
    48             $log_date = $date_time->format('Y-m-d H:i:s');
    49             $result = self::insert_dns_log($log_date, $user_id, $domain);
    50             if (!$result) {
    51                 error_log('Failed to insert row in ' . $wpdb->prefix . 'digilan_token_log table.');
    52             }
    53         }
    54         $data = array(
    55             'message' => 'POST successful.'
    56         );
    57         $data = wp_json_encode($data);
    58         wp_die($data, '', 200);
    59     }
    60 
    61     private static function insert_dns_log($date, $user_id, $domain)
    62     {
    63         global $wpdb;
    64         if (!strtotime($date)) {
    65             error_log('insert_dns_log: Invalid date.');
    66             return false;
    67         }
    68         $re = '/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i';
    69         if (preg_match($re, $domain) != 1) {
    70             error_log('Invalid chars in domain.');
    71             return false;
    72         }
    73         $re = '/^.{1,253}$/';
    74         if (preg_match($re, $domain) != 1) {
    75             error_log('Invalid overall domain length.');
    76             return false;
    77         }
    78         $re = '/^[^\.]{1,63}(\.[^\.]{1,63})*$/';
    79         if (preg_match($re, $domain) != 1) {
    80             error_log('Invalid length in >=1 domain labels.');
    81             return false;
    82         }
    83         $installed_version = get_option('digilan_token_version');
    84         $query = "SELECT id FROM {$wpdb->prefix}digilan_token_users_$installed_version WHERE id=%s";
    85         $query = $wpdb->prepare($query, $user_id);
    86         $id = $wpdb->get_var($query);
    87         if (null === $id) {
    88             error_log('Client with this id does not exist in the table.');
    89             return false;
    90         }
    91         $data = array(
    92             'date' => $date,
    93             'user_id' => $user_id,
    94             'domain' => $domain
    95         );
    96         $format = array(
    97             '%s',
    98             '%s',
    99             '%s'
    100         );
    101         $re = $wpdb->insert($wpdb->prefix . 'digilan_token_logs', $data, $format);
    102         return $re > 0;
     52            if (false === filter_var('http://' . $log->domain, FILTER_VALIDATE_URL)) {
     53                error_log('store_dns_logs/check_domain : Invalid domain ' . $log->domain);
     54                continue;
     55            }
     56            if (false === filter_var($log->user_id, FILTER_VALIDATE_INT, $bigint)) {
     57                error_log('store_dns_logs/check_domain : Invalid user_id ' . $log->user_id);
     58                continue;
     59            }
     60            array_push($inserts_logs, $date_time->format('Y-m-d H:i:s'), $log->user_id, $log->domain);
     61            $groupstoinsertnum++;
     62        }
     63        if ($groupstoinsertnum < 1) {
     64            wp_send_json(array('message' => 'POST successful.'));
     65            die;
     66        }
     67        # Be carefull to respect number of element need to insert on each db row
     68        $query = "INSERT INTO " . $wpdb->prefix . 'digilan_token_logs'
     69            . " (`date`, `user_id`, `domain`) VALUES "
     70            . str_repeat("( %s, %s, %s),", $groupstoinsertnum - 1)
     71            . "( %s, %s, %s)";
     72        $sql = $wpdb->prepare("$query", $inserts_logs);
     73        if ($wpdb->query($sql)) {
     74            wp_send_json(array('message' => 'POST successful.'));
     75            die;
     76        } else {
     77            error_log('store_dns_logs/check_domain : catastrophic failure inserting log');
     78            wp_die('', '', 500);
     79        }
    10380    }
    10481
  • digilan-token/trunk/js/terms-and-conditions.js

    r2293612 r2473929  
    11(function ($) {
    2     $(".dlt-auth").click(function (e) {
    3         if (!$("#dlt-tos").prop("checked")) {
    4             $("#dlt-tos").focus();
    5             e.preventDefault();
    6         }
    7     })
     2    $(document).ready(function () {
     3        $(".dlt-auth").click(function (e) {
     4            if (!$("#dlt-tos").prop("checked")) {
     5                $("#dlt-tos").focus();
     6                e.preventDefault();
     7            }
     8        })
     9    });
    810})(jQuery);
  • digilan-token/trunk/providers/transparent/transparent.php

    r2293612 r2473929  
    2828        $this->id = 'transparent';
    2929        $this->label = 'Transparent';
    30         $this->login_label = 'Continue to <b>Internet</b>';
     30        $this->login_label = 'Accéder à <b>Internet</b>';
    3131        $this->optionKey = 'dlt_' . $this->id;
    3232
     
    134134}
    135135$defaultSettings = array(
    136     'login_label' => 'Continue to <b>Internet</b>'
     136    'login_label' => 'Accéder à <b>Internet</b>'
    137137);
    138138DigilanToken::addProvider(new DigilanTokenProviderTransparent($defaultSettings));
  • digilan-token/trunk/readme.txt

    r2293612 r2473929  
    44Tags: digilan, token, third party, authenticator
    55Requires at least: 4.9.8
    6 Tested up to: 5.3
     6Tested up to: 5.5.3
    77Requires PHP: 7.0
    8 Stable tag: 2.7
     8Stable tag: 2.8
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6161 * Fix timetables
    6262
     63= 2.8 =
     64 * Fix isFromCitybox landing page
     65 * Fix wifi4eu script
Note: See TracChangeset for help on using the changeset viewer.