Plugin Directory

Changeset 3089405


Ignore:
Timestamp:
05/20/2024 11:52:06 AM (22 months ago)
Author:
wtsec
Message:

2.4.26

  • Feedback user issue has been fixed
  • Internal improvements
Location:
wt-security
Files:
449 added
7 edited

Legend:

Unmodified
Added
Removed
  • wt-security/trunk/includes/templates/reports_form.html.twig

    r3077409 r3089405  
    3434                            jQuery('.wtotem_reports-list').show();
    3535                            jQuery('.wtotem_reports-no-data').hide();
     36                            jQuery('.wtotem_reports-modal').removeClass('wtotem_reports-modal--active');
     37                            jQuery('body').removeClass('lock');
     38                            jQuery('#wtotem_reports_form-messages').html('');
    3639
     40                        } else {
     41                            jQuery('#wtotem_reports_form-messages').html(data.massage);
    3742                        }
    38                         jQuery('#wtotem_reports_form-messages').html(data.massage);
     43
    3944                    }
    4045                });
  • wt-security/trunk/lib/API.php

    r3077409 r3089405  
    6767  public static function getApiUrl($prefix){
    6868    $urls = [
    69         'P' => '.wtotem.com',
    70         'C' => '.webtotem.kz',
     69      'P' => '.wtotem.com',
     70      'C' => '.webtotem.kz',
    7171    ];
    7272
  • wt-security/trunk/lib/Helper.php

    r3077409 r3089405  
    11101110
    11111111      $more = [
    1112           'ip' => $log['ip'],
    1113           'proxy_ip' => $log['proxyIp'],
    1114           'source' => $log['source'],
    1115           'request' => htmlspecialchars(urldecode($log['request'])),
    1116           'user_agent' => $log['userAgent'],
    1117           'time' => self::dateFormatter($log['time']),
    1118           'type' => $log['type'],
    1119           'category' => $log['category'],
    1120           'country' => $log['location']['country']['nameEn'],
    1121           'payload' => htmlspecialchars(urldecode($log['payload'])),
     1112        'ip' => $log['ip'],
     1113        'proxy_ip' => $log['proxyIp'],
     1114        'source' => $log['source'],
     1115        'request' => htmlspecialchars(urldecode($log['request'])),
     1116        'user_agent' => $log['userAgent'],
     1117        'time' => self::dateFormatter($log['time']),
     1118        'type' => $log['type'],
     1119        'category' => $log['category'],
     1120        'country' => $log['location']['country']['nameEn'],
     1121        'payload' => htmlspecialchars(urldecode($log['payload'])),
    11221122      ];
    11231123
  • wt-security/trunk/lib/Template.php

    r3077409 r3089405  
    22
    33if (!defined('WEBTOTEM_INIT') || WEBTOTEM_INIT !== true) {
    4     if (!headers_sent()) {
    5         header('HTTP/1.1 403 Forbidden');
    6     }
    7     die("Protected By WebTotem!");
     4    if (!headers_sent()) {
     5        header('HTTP/1.1 403 Forbidden');
     6    }
     7    die("Protected By WebTotem!");
    88}
    99
     
    1717 * Read, parse and handle everything related with the templates.
    1818 */
    19 class WebTotemTemplate {
    20 
    21     protected $loader;
    22     protected $page_nonce;
    23     protected $images_path;
    24   protected $menu_url;
    25   protected $domain;
    26 
    27     function __construct() {
     19class WebTotemTemplate
     20{
     21
     22    protected $loader;
     23    protected $page_nonce;
     24    protected $images_path;
     25    protected $menu_url;
     26    protected $domain;
     27
     28    function __construct()
     29    {
    2830        if (class_exists('\Twig\Loader\FilesystemLoader')) {
    29             $this->loader = new FilesystemLoader( WEBTOTEM_PLUGIN_PATH . '/includes/templates/');
    30         }
    31         $this->page_nonce = wp_create_nonce('wtotem_page_nonce');
    32         $this->images_path = WebTotem::getImagePath('');
     31            $this->loader = new FilesystemLoader(WEBTOTEM_PLUGIN_PATH . '/includes/templates/');
     32        }
     33        $this->page_nonce = wp_create_nonce('wtotem_page_nonce');
     34        $this->images_path = WebTotem::getImagePath('');
    3335        $this->menu_url = WebTotem::adminURL('admin.php?page=wtotem');
    3436        $this->domain = WEBTOTEM_SITE_DOMAIN;
    35     }
    36 
    37     /**
    38      * Rendering a template using twig and filling in data.
    39      *
    40      * @param string $template
    41      * @param array $variables
    42      *
    43      * @return bool|string
    44      * @throws LoaderError
    45      * @throws RuntimeError
    46      * @throws SyntaxError
    47      */
    48     public function twigRender( $template, $variables = []) {
    49 
    50         $twig = new Environment($this->loader);
    51 
    52         if(!file_exists(WEBTOTEM_PLUGIN_PATH . '/includes/templates/' . $template)) {
    53             WebTotemOption::setNotification('error', __('There is no template: ', 'wtotem') . $template);
    54             return FALSE;
    55         }
    56 
    57         // Default values of some variables
    58         $variables['images_path'] = $this->images_path;
    59         $variables['days'] = (isset($variables['days'])) ? $variables['days'] : 7;
    60         $variables['page_nonce'] = $this->page_nonce;
     37    }
     38
     39    /**
     40     * Rendering a template using twig and filling in data.
     41     *
     42     * @param string $template
     43     * @param array $variables
     44     *
     45     * @return bool|string
     46     * @throws LoaderError
     47     * @throws RuntimeError
     48     * @throws SyntaxError
     49     */
     50    public function twigRender($template, $variables = [])
     51    {
     52
     53        $twig = new Environment($this->loader);
     54
     55        if (!file_exists(WEBTOTEM_PLUGIN_PATH . '/includes/templates/' . $template)) {
     56            WebTotemOption::setNotification('error', __('There is no template: ', 'wtotem') . $template);
     57            return FALSE;
     58        }
     59
     60        // Default values of some variables
     61        $variables['images_path'] = $this->images_path;
     62        $variables['days'] = (isset($variables['days'])) ? $variables['days'] : 7;
     63        $variables['page_nonce'] = $this->page_nonce;
    6164        $variables['menu_url'] = $this->menu_url;
    6265        $variables['domain'] = $this->domain;
    6366        $variables['user_email'] = WebTotem::getUserEmail();
    6467
    65         if( WebTotem::isMultiSite() ){
    66             $variables['is_multisite'] = WebTotem::isMultiSite();
    67             $variables['is_super_admin'] = is_super_admin();
    68             $variables['hid'] = (WebTotemRequest::get('hid')) ? '&hid=' . WebTotemRequest::get('hid') : '';
    69         }
    70 
    71         $twig->addFilter(new \Twig\TwigFilter('trans', array( $this, 'translate' )));
    72         $twig->addFunction(new \Twig\TwigFunction('plural', array( $this, 'plural' )));
    73         $twig->addFilter(new \Twig\TwigFilter('t', array( $this, 'translate' )));
    74 
    75         return $twig->render($template, $variables);
    76     }
    77 
    78     /**
    79      * Page rendering based on array data.
    80      *
    81      * @param $params
    82      *
    83      * @return bool|string
    84      * @throws LoaderError
    85      * @throws RuntimeError
    86      * @throws SyntaxError
    87      */
    88     public function arrayRender($params) {
    89 
    90         $render = '';
    91         if(is_array($params)){
    92 
    93             if(array_key_exists('template', $params)){
    94                 $template = $params['template'] . '.html.twig';
    95                 $variables = (isset($params['variables'])) ? $params['variables'] : [];
    96 
    97                 $render = $this->twigRender($template, $variables) ?: '';
    98             } else {
    99                 foreach ($params as $param){
    100                     $template = $param['template'] . '.html.twig';
    101                     $variables = (isset($param['variables'])) ? $param['variables'] : [];
    102 
    103                     $render .= $this->twigRender($template, $variables) ?: '';
    104                 }
    105             }
    106 
    107         }
    108 
    109         return $render;
    110     }
    111 
    112     /**
    113      * Generate a page based on a basic template and content.
    114      *
    115      * @param $page_content
    116      *
    117      * @return bool|string
    118      * @throws LoaderError
    119      * @throws RuntimeError
    120      * @throws SyntaxError
    121      */
    122     public function baseTemplate($page_content) {
    123 
    124         if(WebTotemRequest::get('hid')){
    125             WebTotemOption::setSessionOptions(['host_id' => WebTotemRequest::get('hid')]);
    126         }
    127 
    128         $variables['menu_url'] = WebTotem::adminURL('admin.php?page=wtotem');
    129 
    130         $page = str_replace(['wtotem', '_'], '', WebTotemRequest::get('page'));
    131         $page = $page ?: 'dashboard';
    132         $variables['is_active'][$page] = 'wtotem_nav__link_active';
    133         $variables['page'] = $page;
    134 
    135     if($page != 'activation'){
    136       $user_feedback = WebTotemAPI::getFeedback();
    137       if(!isset($user_feedback['score'])){
    138         $variables['user_feedback'] = true;
    139       } else {
    140         $variables['user_feedback'] = (bool)$user_feedback['score'];
    141       }
    142     } else {
    143       $variables['user_feedback'] = true;
    144     }
    145 
    146         $variables['theme_mode'] = WebTotem::getThemeMode();
    147         $variables['notifications'] = WebTotem::getNotifications();
    148         $variables['current_year'] = date('Y');
    149     $variables['content'] = $page_content;
    150 
    151         return $this->twigRender('layout.html.twig', $variables);
    152     }
    153 
    154 
    155     /**
    156      * String translation.
    157      *
    158      * @param $string
    159      * @param array $params
    160      *
    161      * @return string
    162      */
    163     public static function translate($string, array $params = []) {
    164 
    165         global $locale;
    166 
    167         $string = ('en_US' !== $locale) ? translate($string, 'wtotem') : $string;
    168 
    169         if($params){
    170             foreach ($params as $key => $value){
    171                 $string = str_replace($key, $value, $string);
    172             }
    173         }
    174 
    175         return (string) $string;
    176     }
    177 
    178     /**
    179      * @param array $params [single, plural, number]
    180      *
    181      * usage example
    182      * {{ plural({'single' : '%s month', 'plural' : '%s months', 'number' : 1}) }}
    183      *
    184      * @return string
    185      */
    186     public static function plural( array $params): string {
    187 
    188         $string = _n( $params['single'], $params['plural'], $params['number'],'wtotem' );
    189         $string = str_replace('%s', $params['number'], $string);
    190 
    191         return (string) $string;
    192     }
     68        if (WebTotem::isMultiSite()) {
     69            $variables['is_multisite'] = WebTotem::isMultiSite();
     70            $variables['is_super_admin'] = is_super_admin();
     71            $variables['hid'] = (WebTotemRequest::get('hid')) ? '&hid=' . WebTotemRequest::get('hid') : '';
     72        }
     73
     74        $twig->addFilter(new \Twig\TwigFilter('trans', array($this, 'translate')));
     75        $twig->addFunction(new \Twig\TwigFunction('plural', array($this, 'plural')));
     76        $twig->addFilter(new \Twig\TwigFilter('t', array($this, 'translate')));
     77
     78        return $twig->render($template, $variables);
     79    }
     80
     81    /**
     82     * Page rendering based on array data.
     83     *
     84     * @param $params
     85     *
     86     * @return bool|string
     87     * @throws LoaderError
     88     * @throws RuntimeError
     89     * @throws SyntaxError
     90     */
     91    public function arrayRender($params)
     92    {
     93
     94        $render = '';
     95        if (is_array($params)) {
     96
     97            if (array_key_exists('template', $params)) {
     98                $template = $params['template'] . '.html.twig';
     99                $variables = (isset($params['variables'])) ? $params['variables'] : [];
     100
     101                $render = $this->twigRender($template, $variables) ?: '';
     102            } else {
     103                foreach ($params as $param) {
     104                    $template = $param['template'] . '.html.twig';
     105                    $variables = (isset($param['variables'])) ? $param['variables'] : [];
     106
     107                    $render .= $this->twigRender($template, $variables) ?: '';
     108                }
     109            }
     110
     111        }
     112
     113        return $render;
     114    }
     115
     116    /**
     117     * Generate a page based on a basic template and content.
     118     *
     119     * @param $page_content
     120     *
     121     * @return bool|string
     122     * @throws LoaderError
     123     * @throws RuntimeError
     124     * @throws SyntaxError
     125     */
     126    public function baseTemplate($page_content)
     127    {
     128
     129        if (WebTotemRequest::get('hid')) {
     130            WebTotemOption::setSessionOptions(['host_id' => WebTotemRequest::get('hid')]);
     131        }
     132
     133        $variables['menu_url'] = WebTotem::adminURL('admin.php?page=wtotem');
     134
     135        $page = str_replace(['wtotem', '_'], '', WebTotemRequest::get('page'));
     136        $page = $page ?: 'dashboard';
     137        $variables['is_active'][$page] = 'wtotem_nav__link_active';
     138        $variables['page'] = $page;
     139
     140        if ($page != 'activation') {
     141            $user_feedback = WebTotemAPI::getFeedback();
     142            if(is_array($user_feedback) and array_key_exists('score', $user_feedback)){
     143                $variables['user_feedback'] = (bool)$user_feedback['score'];
     144            } else {
     145                $variables['user_feedback'] = true;
     146            }
     147        } else {
     148            $variables['user_feedback'] = true;
     149        }
     150
     151        $variables['theme_mode'] = WebTotem::getThemeMode();
     152        $variables['notifications'] = WebTotem::getNotifications();
     153        $variables['current_year'] = date('Y');
     154        $variables['content'] = $page_content;
     155
     156        return $this->twigRender('layout.html.twig', $variables);
     157    }
     158
     159
     160    /**
     161     * String translation.
     162     *
     163     * @param $string
     164     * @param array $params
     165     *
     166     * @return string
     167     */
     168    public static function translate($string, array $params = [])
     169    {
     170
     171        global $locale;
     172
     173        $string = ('en_US' !== $locale) ? translate($string, 'wtotem') : $string;
     174
     175        if ($params) {
     176            foreach ($params as $key => $value) {
     177                $string = str_replace($key, $value, $string);
     178            }
     179        }
     180
     181        return (string)$string;
     182    }
     183
     184    /**
     185     * @param array $params [single, plural, number]
     186     *
     187     * usage example
     188     * {{ plural({'single' : '%s month', 'plural' : '%s months', 'number' : 1}) }}
     189     *
     190     * @return string
     191     */
     192    public static function plural(array $params): string
     193    {
     194
     195        $string = _n($params['single'], $params['plural'], $params['number'], 'wtotem');
     196        $string = str_replace('%s', $params['number'], $string);
     197
     198        return (string)$string;
     199    }
    193200
    194201    /**
     
    197204     * @return string|bool
    198205     */
    199     public function getHtml($template) {
     206    public function getHtml($template)
     207    {
    200208        $templatePath = WEBTOTEM_PLUGIN_PATH . '/includes/templates/' . $template . '.html.twig';
    201         if(!file_exists($templatePath)) {
     209        if (!file_exists($templatePath)) {
    202210            return FALSE;
    203211        }
  • wt-security/trunk/readme.txt

    r3077409 r3089405  
    77Tested up to: 6.5
    88Requires PHP: 7.1
     9Requires at least: 6.0
     10Stable tag: 2.4.26
    911
    1012WebTotem is a SaaS which provides powerful tools for securing and monitoring your website in one place in easy and flexible way.
     
    2830* **Technology Scanner:** Accurately identifies your site's technology stack and its versions, aiding in keeping your systems up-to-date.
    2931
    30 
    3132## Highlight Features: ##
    3233* **Vulnerability Scanner:** A cornerstone feature that scans for known vulnerabilities within the Common Vulnerabilities and Exposures (CVE) database, enabling swift remediation to boost your site's security.
     
    8687
    8788== Changelog ==
     89= 2.4.26 =
     90* Feedback user issue has been fixed
     91* Internal improvements
     92
    8893= 2.4.25 =
    8994* The api-key entry page has been fixed
  • wt-security/trunk/src/Common.php

    r3023313 r3089405  
    66    }
    77    die("Protected By WebTotem!");
     8}
     9/**
     10 * Creating a marker file after updating the plugin.
     11 */
     12
     13add_action( 'upgrader_process_complete', 'wt_security_upgrade_complete', 10, 2 );
     14
     15function wt_security_upgrade_complete( $upgrader, $hook_extra ){
     16    if($upgrader->result['destination_name'] == 'wt-security'){
     17        WebTotemAgentManager::generateMarkerFile();
     18    }
    819}
    920
     
    1728            add_action('admin_enqueue_scripts', 'WebTotemInterface::enqueueScripts', 1);
    1829    }
    19 
    2030
    2131    add_filter('pre_current_active_plugins', 'WebTotemInterface::registerDeletePrompt');
  • wt-security/trunk/wt-security.php

    r3077409 r3089405  
    77 * Text Domain: wtotem
    88 * Domain Path: /lang
    9  * Version: 2.4.25
     9 * Version: 2.4.26
    1010 * License: GPL v2 or later
    1111 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     
    5555 * Current version of the plugin's code.
    5656 */
    57 define('WEBTOTEM_VERSION', '2.4.25');
     57define('WEBTOTEM_VERSION', '2.4.26');
    5858
    5959/**
Note: See TracChangeset for help on using the changeset viewer.