Changeset 2473929
- Timestamp:
- 02/12/2021 07:15:47 PM (5 years ago)
- Location:
- digilan-token/trunk
- Files:
-
- 2 added
- 14 edited
-
LICENSE (added)
-
admin/digilan-admin.php (modified) (8 diffs)
-
admin/templates/access-point.php (modified) (1 diff)
-
admin/templates/connections.php (modified) (1 diff)
-
admin/templates/header.php (modified) (1 diff)
-
admin/templates/menu.php (modified) (1 diff)
-
admin/templates/providers.php (modified) (1 diff)
-
digilan-token.php (modified) (16 diffs)
-
includes/digilan-activator.php (modified) (1 diff)
-
includes/digilan-connection.php (modified) (4 diffs)
-
includes/digilan-db.php (modified) (2 diffs)
-
includes/digilan-logs.php (modified) (2 diffs)
-
js/terms-and-conditions.js (modified) (1 diff)
-
providers/transparent/transparent.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
version.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
digilan-token/trunk/admin/digilan-admin.php
r2293612 r2473929 30 30 } 31 31 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); 38 47 } 39 48 … … 140 149 } 141 150 } 142 wp_redirect(self::getAdmin Url());151 wp_redirect(self::getAdminBaseUrl()); 143 152 exit(); 144 153 } … … 164 173 } 165 174 } 166 175 167 176 $view = DigilanTokenSanitize::sanitize_request('view'); 168 177 if (substr($view, 0, 9) == 'provider-') { … … 253 262 self::validate_ap_settings($hostname, $ssid, $country_code, $intervals); 254 263 } 255 264 256 265 } else if ($view == 'logs') { 257 266 if (isset($_POST['digilan-download'])) { … … 281 290 DigilanTokenConnection::download_mails_csv($start, $end); 282 291 } 283 } else if ($view == 'settings') { 292 } else if ($view == 'settings') { 284 293 $cityscope_cloud = DigilanTokenSanitize::sanitize_post('cityscope-backend'); 285 294 if (false === $cityscope_cloud) { … … 290 299 self::updateCityscopeCloud($cityscope_cloud); 291 300 } 292 wp_redirect(self::getAdmin Url());301 wp_redirect(self::getAdminBaseUrl()); 293 302 exit(); 294 303 } … … 414 423 'portal-page' => $portal_page 415 424 ); 416 if (DigilanToken::is Router()) {425 if (DigilanToken::isFromCitybox()) { 417 426 if (null == json_decode($schedule) || false == json_decode($schedule)) { 418 427 \DLT\Notices::addError(sprintf(__('%s is an invalid timetable data.'), $schedule)); … … 535 544 $endpoint .= '/version'; 536 545 $args = array ( 537 'timeout' => 3 546 'timeout' => 3 538 547 ); 539 548 $request = wp_remote_get($endpoint, $args); -
digilan-token/trunk/admin/templates/access-point.php
r2293612 r2473929 90 90 </table> 91 91 92 <?php if (DigilanToken::is Router()) : ?>92 <?php if (DigilanToken::isFromCitybox()) : ?> 93 93 <h2><?php _e('Schedule configuration', 'digilan-token'); ?></h2> 94 94 <table class="form-table"> -
digilan-token/trunk/admin/templates/connections.php
r2293612 r2473929 18 18 $re = '/^[0-9A-Za-z]{32}$/'; 19 19 $secret = get_option('digilan_token_secret'); 20 if (DigilanToken::is Router() || preg_match($re, $secret) == 1) :20 if (DigilanToken::isFromCitybox() || preg_match($re, $secret) == 1) : 21 21 ?> 22 22 <div class="dlt-admin-content"> -
digilan-token/trunk/admin/templates/header.php
r2293612 r2473929 21 21 <div class="dlt-admin-header"> 22 22 <h1> 23 <a href="<?php echo DigilanTokenAdmin::getAdmin Url(); ?>">23 <a href="<?php echo DigilanTokenAdmin::getAdminBaseUrl(); ?>"> 24 24 <img src="<?php echo plugins_url('images/mrwifi.png', DLT_ADMIN_PATH) ?>" width="64" height="64" alt="Digilan Token" /> 25 25 Monsieur WiFi</a> -
digilan-token/trunk/admin/templates/menu.php
r2293612 r2473929 21 21 ?> 22 22 <div class="dlt-admin-nav-bar"> 23 <?php if (DigilanToken::is Router()) : ?>23 <?php if (DigilanToken::isFromCitybox()) : ?> 24 24 <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> 26 26 <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> 27 27 <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> 28 28 <?php elseif (preg_match($re, $secret) == 1) : ?> 29 <a href="<?php echo DigilanTokenAdmin::getAdmin Url(); ?>" 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> 30 30 <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> 31 31 <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 17 17 $secret = get_option('digilan_token_secret'); 18 18 $re = '/^[0-9A-Za-z]{32}$/'; 19 if (DigilanToken::is Router() || preg_match($re, $secret) == 1) :19 if (DigilanToken::isFromCitybox() || preg_match($re, $secret) == 1) : 20 20 ?> 21 21 <div class="dlt-dashboard-providers-container"> -
digilan-token/trunk/digilan-token.php
r2293612 r2473929 4 4 * Plugin URI: https://www.citypassenger.com 5 5 * Description: This plugin helps transform a WordPress into a third party authenticator services. 6 * Version: 16 * Version: 2.8 7 7 * Author: Citypassenger 8 8 * Text Domain: digilan … … 76 76 { 77 77 78 public static $digilan_version = 2. 7;78 public static $digilan_version = 2.8; 79 79 80 80 /** @var DigilanTokenSettings */ … … 199 199 } 200 200 201 public static function is Router()201 public static function isFromCitybox() 202 202 { 203 203 if (!defined('ABSPATH')) { … … 316 316 __('Sun', 'digilan-token') 317 317 ); 318 if (self::is Router()) {318 if (self::isFromCitybox()) { 319 319 wp_register_script('dlt-access-point-router', plugins_url('/js/admin/access-point-router.js', __FILE__), array( 320 320 'jquery' … … 451 451 { 452 452 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'"; 454 454 $query = $wpdb->prepare($query, 'digilan-token-error'); 455 455 if (null === $wpdb->get_row($query, ARRAY_A)) { … … 471 471 { 472 472 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'"; 474 474 $query = $wpdb->prepare($query, 'captive-portal'); 475 475 if (null === $wpdb->get_row($query, ARRAY_A)) { … … 495 495 $wifi4eu_img = '<img id="wifi4eu-placeholder" src="https://collection.wifi4eu.ec.europa.eu/media/banner/Wifi4EU-FR.svg">'; 496 496 } 497 } 497 } 498 498 $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 507 510 return $wifi4eu_img; 508 511 } … … 535 538 static function nextClosingDay($closed_time_period,$x) 536 539 { 537 for ($index = 0; $index < 6; $index++) 540 for ($index = 0; $index < 6; $index++) 538 541 { 539 542 $id = self::getNextDay(self::nextDays($x)[$index]); … … 551 554 return $day; 552 555 } 553 556 554 557 public static function getNextOpeningDate($closed_time_period, $next) 555 558 { … … 613 616 public static function isWifiClosed($session_id) 614 617 { 618 if (self::isFromCitybox()) { #TODO local diff here 619 return false; 620 } 615 621 $aps = self::$settings->get('access-points'); 616 622 $keys = array_keys($aps); … … 704 710 $idx = $keys[$query_source_access_point]; 705 711 $access_point = $access_points[$idx]; 706 if (self::is Router()) {712 if (self::isFromCitybox()) { 707 713 if ($mac) { 708 714 $next = self::isWifiClosed($sid); … … 729 735 } 730 736 } 731 if (self::is Router()) {737 if (self::isFromCitybox()) { 732 738 if ($mac) { 733 739 $closed_time_period = json_decode($closed_time_period, true); 734 740 $next_opening_date = self::getNextOpeningDate($closed_time_period, $next); 735 741 } else { 736 $next_opening_date = self::getNextOpeningDate($router_schedule, $next); 742 $next_opening_date = self::getNextOpeningDate($router_schedule, $next); 737 743 } 738 744 } else { … … 742 748 $msg = __('Wifi will be available ', 'digilan-token'); 743 749 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'); 745 751 } elseif ($next_opening_date === 'tomorrow') { 746 752 $msg = __('Wifi will be opened tomorrow', 'digilan-token'); … … 789 795 $ret = '<center><div class="dlt-container ' . self::$styles[$style]['container'] . '">' . $heading . $buttons . '</div>'; 790 796 $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')); 792 799 return $ret; 793 800 } … … 809 816 'access-points' => $access_points 810 817 ); 811 if (self::is Router()) {818 if (self::isFromCitybox()) { 812 819 $data['schedule-router'] = self::$settings->get('schedule_router'); 813 820 } … … 1020 1027 public static function getDigilanVersion() 1021 1028 { 1022 wp_die(self::$digilan_version, '', 200); 1029 status_header( 200 ); 1030 echo self::$digilan_version; 1031 die; 1023 1032 } 1024 1033 -
digilan-token/trunk/includes/digilan-activator.php
r2293612 r2473929 24 24 $secret = get_option('digilan_token_secret'); 25 25 $mode = get_option('digilan_token_mode'); 26 if (DigilanToken::is Router()) {26 if (DigilanToken::isFromCitybox()) { 27 27 $mode = 2; 28 28 } -
digilan-token/trunk/includes/digilan-connection.php
r2293612 r2473929 58 58 {$wpdb->prefix}digilan_token_connections_$version.authentication_mode, 59 59 {$wpdb->prefix}digilan_token_users_$version.social_id, 60 {$wpdb->prefix}digilan_token_users_$version.mac 60 {$wpdb->prefix}digilan_token_users_$version.mac 61 61 FROM {$wpdb->prefix}digilan_token_connections_$version 62 62 LEFT JOIN {$wpdb->prefix}digilan_token_users_$version ON {$wpdb->prefix}digilan_token_connections_$version.user_id = {$wpdb->prefix}digilan_token_users_$version.id … … 103 103 {$wpdb->prefix}digilan_token_active_sessions_$version.authentication_mode, 104 104 {$wpdb->prefix}digilan_token_users_$version.social_id, 105 {$wpdb->prefix}digilan_token_users_$version.mac 105 {$wpdb->prefix}digilan_token_users_$version.mac 106 106 FROM {$wpdb->prefix}digilan_token_active_sessions_$version 107 107 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 … … 400 400 $digilan_token_secret = DigilanTokenSanitize::sanitize_get('digilan-token-secret'); 401 401 $digilan_token_wp_secret = get_option('digilan_token_secret'); 402 if (DigilanToken::is Router()) {402 if (DigilanToken::isFromCitybox()) { 403 403 if ($digilan_token_wp_secret === $digilan_token_secret) { 404 404 return true; 405 405 } 406 return 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' == $digilan_token_secret;406 return false; 407 407 } 408 408 return $digilan_token_wp_secret == $digilan_token_secret; … … 472 472 'auth_type' => $auth_mode 473 473 ); 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 } 474 481 $response = wp_json_encode($data_array); 475 482 } -
digilan-token/trunk/includes/digilan-db.php
r2293612 r2473929 44 44 } 45 45 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 } 52 57 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 } 66 76 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 } 80 95 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 } 84 102 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 } 91 112 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 );";98 113 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 } 105 133 106 134 public static function install_plugin_tables() … … 109 137 $installed_version = self::$installed_version; 110 138 $sqls = array( 111 "wp_digilan_token_users" => s printf(self::$sql_users, $wpdb->prefix),112 "wp_digilan_token_connections_current" => s printf(self::$sql_current_connections, $wpdb->prefix, $wpdb->prefix),113 "wp_digilan_token_connections" => s printf(self::$sql_connections, $wpdb->prefix, $wpdb->prefix),114 "wp_digilan_token_version" => s printf(self::$sql_version, $wpdb->prefix),115 "wp_digilan_token_logs" => s printf(self::$sql_logs, $wpdb->prefix, $wpdb->prefix),116 "wp_digilan_token_archive_logs" => s printf(self::$sql_archive_logs, $wpdb->prefix, $wpdb->prefix),117 "wp_digilan_social_users" => s printf(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() 118 146 ); 119 147 $charset_collate = $wpdb->get_charset_collate(); -
digilan-token/trunk/includes/digilan-logs.php
r2293612 r2473929 18 18 class DigilanTokenLogs 19 19 { 20 # user_id in _digilan_token_users_ is int(11) 21 static $bigint = array("options" => array("min_range" => 0, "max_range" => 2147483648)); 20 22 21 23 public static function store_dns_logs() 22 24 { 25 global $wpdb; 23 26 $is_valid_secret = DigilanTokenConnection::validate_wordpress_AP_secret(); 24 27 if (!$is_valid_secret) { … … 33 36 $logs = json_decode($logs); 34 37 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; 40 40 } 41 41 $timezone = get_option('gmt_offset'); 42 $inserts_logs = array(); 43 $groupstoinsertnum = 0; # number row to insert in db 42 44 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 } 47 51 $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 } 103 80 } 104 81 -
digilan-token/trunk/js/terms-and-conditions.js
r2293612 r2473929 1 1 (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 }); 8 10 })(jQuery); -
digilan-token/trunk/providers/transparent/transparent.php
r2293612 r2473929 28 28 $this->id = 'transparent'; 29 29 $this->label = 'Transparent'; 30 $this->login_label = ' Continue to<b>Internet</b>';30 $this->login_label = 'Accéder à <b>Internet</b>'; 31 31 $this->optionKey = 'dlt_' . $this->id; 32 32 … … 134 134 } 135 135 $defaultSettings = array( 136 'login_label' => ' Continue to<b>Internet</b>'136 'login_label' => 'Accéder à <b>Internet</b>' 137 137 ); 138 138 DigilanToken::addProvider(new DigilanTokenProviderTransparent($defaultSettings)); -
digilan-token/trunk/readme.txt
r2293612 r2473929 4 4 Tags: digilan, token, third party, authenticator 5 5 Requires at least: 4.9.8 6 Tested up to: 5. 36 Tested up to: 5.5.3 7 7 Requires PHP: 7.0 8 Stable tag: 2. 78 Stable tag: 2.8 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 61 61 * Fix timetables 62 62 63 = 2.8 = 64 * Fix isFromCitybox landing page 65 * Fix wifi4eu script
Note: See TracChangeset
for help on using the changeset viewer.