Plugin Directory

Changeset 3441603


Ignore:
Timestamp:
01/17/2026 02:00:09 PM (5 weeks ago)
Author:
switcorp
Message:

update

Location:
winterlock
Files:
414 added
2 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • winterlock/trunk/README.txt

    r3419393 r3441603  
    55Requires at least: 5.0
    66Tested up to: 6.9
    7 Stable tag: 1.2.7
     7Stable tag: 1.2.8
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    143143== Changelog ==
    144144
     145= 1.2.8 =
     146* Security fix
     147
    145148= 1.2.7 =
    146149* Security fix
  • winterlock/trunk/application/controllers/Wal_cloudintegration.php

    r3227676 r3441603  
    278278    public function datatable()
    279279    {
     280
     281        if ( ! current_user_can( 'administrator' ) ) {
     282            exit();
     283        }
     284       
     285        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     286
     287
    280288        //$this->enable_error_reporting();
    281289        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Wal_controlsecurity.php

    r3227676 r3441603  
    1818    public function datatable()
    1919    {
     20        if ( ! current_user_can( 'administrator' ) ) {
     21            exit();
     22        }
     23       
     24        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     25       
    2026        //$this->enable_error_reporting();
    2127        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Wal_disabledlogs.php

    r2620073 r3441603  
    1818    public function datatable()
    1919    {
     20        if ( ! current_user_can( 'administrator' ) ) {
     21            exit();
     22        }
     23       
     24        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     25       
    2026        //$this->enable_error_reporting();
    2127        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Wal_history.php

    r3227676 r3441603  
    7272    public function datatable()
    7373    {
     74
     75        if ( ! current_user_can( 'administrator' ) ) {
     76            exit();
     77        }
     78       
     79        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     80       
    7481        //$this->enable_error_reporting();
    7582        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
     
    245252   
    246253    public function filter_save ($id = NULL, $redirect='1') {
     254        if ( ! current_user_can( 'administrator' ) ) {
     255            exit();
     256        }
     257       
     258        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     259       
    247260        if(!wal_access_allowed('winterlock_logs'))
    248261        {
     
    292305   
    293306    public function filter_get ($id = NULL, $redirect='1') {
     307        if ( ! current_user_can( 'administrator' ) ) {
     308            exit();
     309        }
     310       
     311        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     312
    294313        if(!wal_access_allowed('winterlock_logs'))
    295314        {
     
    329348   
    330349    public function filter_remove ($id = NULL, $redirect='1') {
     350        if ( ! current_user_can( 'administrator' ) ) {
     351            exit();
     352        }
     353       
     354        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     355
    331356        if(!wal_access_allowed('winterlock_logs'))
    332357        {
     
    352377        }
    353378       
    354         $ajax_output['results'] = $results;
     379        $ajax_output['results'] = $results ?? '';
    355380        $ajax_output['success'] = true;
    356381        $json_output = json_encode($ajax_output);
  • winterlock/trunk/application/controllers/Wal_logalerts.php

    r2620073 r3441603  
    1818    public function datatable()
    1919    {
     20
     21        if ( ! current_user_can( 'administrator' ) ) {
     22            exit();
     23        }
     24       
     25        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     26       
    2027        //$this->enable_error_reporting();
    2128        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Wal_reports.php

    r3227676 r3441603  
    130130    public function datatable()
    131131    {
     132
     133        if ( ! current_user_can( 'administrator' ) ) {
     134            exit();
     135        }
     136       
     137        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     138       
    132139        //$this->enable_error_reporting();
    133140        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Wal_usersessions.php

    r3227676 r3441603  
    2828    public function datatable()
    2929    {
     30
     31        if ( ! current_user_can( 'administrator' ) ) {
     32            exit();
     33        }
     34       
     35        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     36       
    3037        //$this->enable_error_reporting();
    3138        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
  • winterlock/trunk/application/controllers/Winteractivitylog.php

    r3227676 r3441603  
    8080    public function datatable()
    8181    {
     82
     83        if ( ! current_user_can( 'administrator' ) ) {
     84            exit();
     85        }
     86       
     87        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     88       
    8289        //$this->enable_error_reporting();
    8390        remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
     
    250257   
    251258    public function filter_save ($id = NULL, $redirect='1') {
     259        if ( ! current_user_can( 'administrator' ) ) {
     260            exit();
     261        }
     262       
     263        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
    252264        if(!wal_access_allowed('winterlock_logs'))
    253265        {
     
    297309   
    298310    public function filter_get ($id = NULL, $redirect='1') {
     311        if ( ! current_user_can( 'administrator' ) ) {
     312            exit();
     313        }
     314       
     315        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     316
    299317        if(!wal_access_allowed('winterlock_logs'))
    300318        {
     
    334352   
    335353    public function filter_remove ($id = NULL, $redirect='1') {
     354        if ( ! current_user_can( 'administrator' ) ) {
     355            exit();
     356        }
     357       
     358        check_ajax_referer('winterlock_secure_ajax', 'winterlock_secure');
     359       
    336360        if(!wal_access_allowed('winterlock_logs'))
    337361        {
  • winterlock/trunk/application/views/wal_cloudintegration/index.php

    r3419393 r3441603  
    1818<div class="wrap winterlock_wrap">
    1919
    20 <h1><?php echo __('Cloud integration', 'winter-activity-log'); ?>
    21 <a href="<?php menu_page_url( 'wal_cloudintegration', true ); ?>&function=cloud_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php echo __('Add New Papertrail Cloud','sw_win')?></a>
    22 <a href="<?php menu_page_url( 'wal_cloudintegration', true ); ?>&function=mysql_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php echo __('Add New External MySQL Connection','sw_win')?></a>
     20<h1><?php
     21echo __( 'Cloud integration', 'winter-activity-log' );
     22?>
     23<a href="<?php
     24menu_page_url( 'wal_cloudintegration', true );
     25?>&function=cloud_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php
     26echo __( 'Add New Papertrail Cloud', 'sw_win' );
     27?></a>
     28<a href="<?php
     29menu_page_url( 'wal_cloudintegration', true );
     30?>&function=mysql_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php
     31echo __( 'Add New External MySQL Connection', 'sw_win' );
     32?></a>
    2333
    2434</h1>
     
    2838    <div class="panel panel-default">
    2939        <div class="panel-heading">
    30             <h3 class="panel-title"><?php echo __('Manage Cloud integration Data','winter-activity-log'); ?></h3>
     40            <h3 class="panel-title"><?php
     41echo __( 'Manage Cloud integration Data', 'winter-activity-log' );
     42?></h3>
    3143        </div>
    3244        <div class="panel-body">
     
    3951                            <tr>
    4052                                <th data-priority="1">#</th>
    41                                 <th data-priority="2"><?php echo __('Title', 'winter-activity-log'); ?></th>
    42                                 <th data-priority="3"><?php echo __('Component', 'winter-activity-log'); ?></th>
    43                                 <th data-priority="4"><?php echo __('Program name', 'winter-activity-log'); ?></th>
     53                                <th data-priority="2"><?php
     54echo __( 'Title', 'winter-activity-log' );
     55?></th>
     56                                <th data-priority="3"><?php
     57echo __( 'Component', 'winter-activity-log' );
     58?></th>
     59                                <th data-priority="4"><?php
     60echo __( 'Program name', 'winter-activity-log' );
     61?></th>
    4462                                <th data-priority="5"><i class="glyphicon glyphicon-edit"></i></th>
    4563                                <th><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
     
    6381            </div>
    6482            <div class="footer-btns">
    65                 <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php echo __('Bulk remove','winter-activity-log')?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
    66                 <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php echo __('Clear all filters','winter-activity-log')?></a>
     83                <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php
     84echo __( 'Bulk remove', 'winter-activity-log' );
     85?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
     86                <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php
     87echo __( 'Clear all filters', 'winter-activity-log' );
     88?></a>
    6789            </div>
    6890        </div>
    6991    </div>
    7092
    71     <div class="alert alert-info" role="alert"><?php echo __('Here you can configure cloud loging to Papertrail app', 'winter-activity-log'); ?></div>
     93    <div class="alert alert-info" role="alert"><?php
     94echo __( 'Here you can configure cloud loging to Papertrail app', 'winter-activity-log' );
     95?></div>
    7296
    7397    <?php
    74     if ( winteractivitylog()->is__premium_only() ) {
    75     if ( !winteractivitylog()->is_plan_or_trial('premium') ){ ?>
    76         <div class="alert alert-danger" role="alert"><?php echo __('Min. premium package is required for cloud integration', 'winter-activity-log'); ?></div>
    77     <?php }} ?>
    78 
    79     <?php if(get_option('wal_checkbox_disable_hints', '0') == '0'): ?>
     98?>
     99
     100    <?php
     101if ( get_option( 'wal_checkbox_disable_hints', '0' ) == '0' ) {
     102    ?>
    80103
    81104    <iframe width="560" height="315" src="https://www.youtube.com/embed/4QvmA3HkdDY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    82105
    83     <?php endif; ?>
     106    <?php
     107}
     108?>
    84109</div>
    85110</div>
     
    87112
    88113
    89 <?php
    90 
    91 wp_enqueue_style('winter-activity-log_basic_wrapper');
     114<?php
     115wp_enqueue_style( 'winter-activity-log_basic_wrapper' );
    92116wp_enqueue_script( 'datatables' );
    93117wp_enqueue_script( 'dataTables-responsive' );
    94118wp_enqueue_script( 'dataTables-select' );
    95 
    96119wp_enqueue_style( 'dataTables-select' );
    97120?>
     
    121144        if(count == 0)
    122145        {
    123             alert('<?php echo esc_attr__('Please select reports to remove', 'winter-activity-log'); ?>');
     146            alert('<?php
     147echo esc_attr__( 'Please select reports to remove', 'winter-activity-log' );
     148?>');
    124149            load_indicator_opc.addClass('hidden_opacity');
    125150            return false;
     
    128153        {
    129154
    130             if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     155            if(confirm('<?php
     156esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     157?>'))
    131158            {
    132159                $('img#ajax-indicator-masking').show();
     
    136163
    137164                // ajax to remove rows
    138                 $.post('<?php menu_page_url( 'wal_cloudintegration', true ); ?>&function=bulk_remove&_wpnonce=<?php echo esc_js(wp_create_nonce( 'winteractivitylog-bulk'));?>', { cloud_ids: ids }, function(data) {
     165                $.post('<?php
     166menu_page_url( 'wal_cloudintegration', true );
     167?>&function=bulk_remove&_wpnonce=<?php
     168echo esc_js( wp_create_nonce( 'winteractivitylog-bulk' ) );
     169?>', { cloud_ids: ids }, function(data) {
    139170
    140171                    $('img#ajax-indicator-masking').hide();
     
    170201                        "page": 'wal_cloudintegration',
    171202                        "function": 'datatable',
    172                         "action": 'winter_activity_log_action'
     203                        "action": 'winter_activity_log_action',
     204                        "winterlock_secure": '<?php
     205echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     206?>'
    173207                    } );
    174208                }
    175209            },
    176210            "language": {
    177                 search: "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    178                 searchPlaceholder: "<?php esc_js(__('Enter here filter tag for any column', 'winter-activity-log')); ?>"
     211                search: "<?php
     212esc_js( __( 'Search', 'winter-activity-log' ) );
     213?>",
     214                searchPlaceholder: "<?php
     215esc_js( __( 'Enter here filter tag for any column', 'winter-activity-log' ) );
     216?>"
    179217            },
    180218            "fnDrawCallback": function (oSettings){
    181219                $('a.delete_button').click(function(){
    182220                   
    183                     if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     221                    if(confirm('<?php
     222esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     223?>'))
    184224                    {
    185225                       // ajax to remove row
     
    275315                    'sNext': '<i class="fa fa-angle-right"></i>'
    276316                },
    277                 'sSearch': "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    278                 "sLengthMenu": "<?php esc_js(__('Show _MENU_ entries', 'winter-activity-log')); ?>",
    279                 "sInfoEmpty": "<?php esc_js(__('Showing 0 to 0 of 0 entries', 'winter-activity-log')); ?>",
    280                 "sInfo": "<?php esc_js( __('Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log')); ?>",
    281                 "sEmptyTable": "<?php esc_js(__('No data available in table', 'winter-activity-log')); ?>",
     317                'sSearch': "<?php
     318esc_js( __( 'Search', 'winter-activity-log' ) );
     319?>",
     320                "sLengthMenu": "<?php
     321esc_js( __( 'Show _MENU_ entries', 'winter-activity-log' ) );
     322?>",
     323                "sInfoEmpty": "<?php
     324esc_js( __( 'Showing 0 to 0 of 0 entries', 'winter-activity-log' ) );
     325?>",
     326                "sInfo": "<?php
     327esc_js( __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log' ) );
     328?>",
     329                "sEmptyTable": "<?php
     330esc_js( __( 'No data available in table', 'winter-activity-log' ) );
     331?>",
    282332            },
    283333            'dom': "<'row'<'col-sm-7 col-md-5'f><'col-sm-5 col-md-6'l>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>"
  • winterlock/trunk/application/views/wal_controlsecurity/index.php

    r3227676 r3441603  
    177177                        "page": 'wal_controlsecurity',
    178178                        "function": 'datatable',
    179                         "action": 'winter_activity_log_action'
     179                        "action": 'winter_activity_log_action',
     180                        "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    180181                    } );
    181182                }
  • winterlock/trunk/application/views/wal_disabledlogs/index.php

    r3227676 r3441603  
    171171                        "page": 'wal_disabledlogs',
    172172                        "function": 'datatable',
    173                         "action": 'winter_activity_log_action'
     173                        "action": 'winter_activity_log_action',
     174                        "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    174175                    } );
    175176                }
  • winterlock/trunk/application/views/wal_history/index.php

    r3227676 r3441603  
    242242            'function': 'filter_get',
    243243            "action": 'winter_activity_log_action',
     244            "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    244245        };
    245246
     
    295296                    "action": 'winter_activity_log_action',
    296297                    "filter_id": $(this).attr('data-fielderid') || '',
     298                    "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    297299                };
    298300                sw_log_notify('<?php echo __('Removing filter', 'winter-activity-log'); ?> '+title, 'loading');
     
    350352                            "action": 'winter_activity_log_action',
    351353                            "filter_name": filter_name,
    352                             "filter_param": generate_json_filter()
     354                            "filter_param": generate_json_filter(),
     355                             "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    353356                        };
    354357
     
    481484                    "page": 'wal_history',
    482485                    "function": 'datatable',
    483                     "action": 'winter_activity_log_action'
     486                    "action": 'winter_activity_log_action',
     487                    "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    484488                } );
    485489
  • winterlock/trunk/application/views/wal_logalerts/index.php

    r3227676 r3441603  
    171171                        "page": 'wal_logalerts',
    172172                        "function": 'datatable',
    173                         "action": 'winter_activity_log_action'
     173                        "action": 'winter_activity_log_action',
     174                        "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    174175                    } );
    175176                }
  • winterlock/trunk/application/views/wal_reports/index.php

    r3419393 r3441603  
    1818<div class="wrap winterlock_wrap">
    1919
    20 <h1><?php echo __('Reports','winter-activity-log'); ?> <a href="<?php menu_page_url( 'wal_reports', true ); ?>&function=report_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php echo __('Add New','sw_win')?></a></h1>
     20<h1><?php
     21echo __( 'Reports', 'winter-activity-log' );
     22?> <a href="<?php
     23menu_page_url( 'wal_reports', true );
     24?>&function=report_edit" class="page-title-action"><i class="fa fa-plus"></i>&nbsp;&nbsp;<?php
     25echo __( 'Add New', 'sw_win' );
     26?></a></h1>
    2127
    2228
     
    2430    <div class="panel panel-default">
    2531        <div class="panel-heading">
    26             <h3 class="panel-title"><?php echo __('Manage Reports Data','winter-activity-log'); ?></h3>
     32            <h3 class="panel-title"><?php
     33echo __( 'Manage Reports Data', 'winter-activity-log' );
     34?></h3>
    2735        </div>
    2836        <div class="panel-body">
     
    3543                            <tr>
    3644                                <th data-priority="1">#</th>
    37                                 <th data-priority="2"><?php echo __('Name', 'winter-activity-log'); ?></th>
    38                                 <th data-priority="3"><?php echo __('Email', 'winter-activity-log'); ?></th>
    39                                 <th data-priority="4"><?php echo __('Scheduling period', 'winter-activity-log'); ?></th>
    40                                 <th data-priority="5"><?php echo __('Format', 'winter-activity-log'); ?></th>
     45                                <th data-priority="2"><?php
     46echo __( 'Name', 'winter-activity-log' );
     47?></th>
     48                                <th data-priority="3"><?php
     49echo __( 'Email', 'winter-activity-log' );
     50?></th>
     51                                <th data-priority="4"><?php
     52echo __( 'Scheduling period', 'winter-activity-log' );
     53?></th>
     54                                <th data-priority="5"><?php
     55echo __( 'Format', 'winter-activity-log' );
     56?></th>
    4157                                <th data-priority="6"><i class="glyphicon glyphicon-search"></i></th>
    4258                                <th><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
     
    6177            </div>
    6278            <div class="footer-btns">
    63                 <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php echo __('Bulk remove','winter-activity-log')?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
    64                 <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php echo __('Clear all filters','winter-activity-log')?></a>
     79                <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php
     80echo __( 'Bulk remove', 'winter-activity-log' );
     81?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
     82                <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php
     83echo __( 'Clear all filters', 'winter-activity-log' );
     84?></a>
    6585            </div>
    6686        </div>
    6787    </div>
    6888
    69     <div class="alert alert-info" role="alert"><?php echo __('Here you can define regular or scheduling reports', 'winter-activity-log'); ?></div>
     89    <div class="alert alert-info" role="alert"><?php
     90echo __( 'Here you can define regular or scheduling reports', 'winter-activity-log' );
     91?></div>
    7092
    7193    <?php
    72     if ( winteractivitylog()->is__premium_only() ) {
    73     if ( !winteractivitylog()->is_plan_or_trial('standard') ){ ?>
    74         <div class="alert alert-danger" role="alert"><?php echo __('Min. standard package is required for log repors', 'winter-activity-log'); ?></div>
    75     <?php }} ?>
    76 
    77     <?php if(get_option('wal_checkbox_disable_hints', '0') == '0'): ?>
     94?>
     95
     96    <?php
     97if ( get_option( 'wal_checkbox_disable_hints', '0' ) == '0' ) {
     98    ?>
    7899   
    79100    <iframe width="560" height="315" src="https://www.youtube.com/embed/YF2VesF1NC8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    80101       
    81     <?php endif; ?>
     102    <?php
     103}
     104?>
    82105
    83106</div>
     
    86109
    87110
    88 <?php
    89 
    90 wp_enqueue_style('winter-activity-log_basic_wrapper');
     111<?php
     112wp_enqueue_style( 'winter-activity-log_basic_wrapper' );
    91113wp_enqueue_script( 'datatables' );
    92114wp_enqueue_script( 'dataTables-responsive' );
    93115wp_enqueue_script( 'dataTables-select' );
    94 
    95116wp_enqueue_style( 'dataTables-select' );
    96117?>
     
    120141        if(count == 0)
    121142        {
    122             alert('<?php echo esc_attr__('Please select reports to remove', 'winter-activity-log'); ?>');
     143            alert('<?php
     144echo esc_attr__( 'Please select reports to remove', 'winter-activity-log' );
     145?>');
    123146            load_indicator_opc.addClass('hidden_opacity');
    124147            return false;
     
    127150        {
    128151
    129             if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     152            if(confirm('<?php
     153esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     154?>'))
    130155            {
    131156                $('img#ajax-indicator-masking').show();
     
    135160
    136161                // ajax to remove rows
    137                 $.post('<?php menu_page_url( 'wal_reports', true ); ?>&function=bulk_remove&_wpnonce=<?php echo esc_js(wp_create_nonce( 'winteractivitylog-bulk'));?>', { report_ids: ids }, function(data) {
     162                $.post('<?php
     163menu_page_url( 'wal_reports', true );
     164?>&function=bulk_remove&_wpnonce=<?php
     165echo esc_js( wp_create_nonce( 'winteractivitylog-bulk' ) );
     166?>', { report_ids: ids }, function(data) {
    138167
    139168                    $('img#ajax-indicator-masking').hide();
     
    169198                        "page": 'wal_reports',
    170199                        "function": 'datatable',
    171                         "action": 'winter_activity_log_action'
     200                        "action": 'winter_activity_log_action',
     201                        "winterlock_secure": '<?php
     202echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     203?>'
    172204                    } );
    173205                }
    174206            },
    175207            "language": {
    176                 search: "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    177                 searchPlaceholder: "<?php esc_js(__('Enter here filter tag for any column', 'winter-activity-log')); ?>"
     208                search: "<?php
     209esc_js( __( 'Search', 'winter-activity-log' ) );
     210?>",
     211                searchPlaceholder: "<?php
     212esc_js( __( 'Enter here filter tag for any column', 'winter-activity-log' ) );
     213?>"
    178214            },
    179215            "fnDrawCallback": function (oSettings){
    180216                $('a.delete_button').click(function(){
    181217                   
    182                     if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     218                    if(confirm('<?php
     219esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     220?>'))
    183221                    {
    184222                       // ajax to remove row
     
    279317                    'sNext': '<i class="fa fa-angle-right"></i>'
    280318                },
    281                 'sSearch': "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    282                 "sLengthMenu": "<?php esc_js(__('Show _MENU_ entries', 'winter-activity-log')); ?>",
    283                 "sInfoEmpty": "<?php esc_js(__('Showing 0 to 0 of 0 entries', 'winter-activity-log')); ?>",
    284                 "sInfo": "<?php esc_js( __('Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log')); ?>",
    285                 "sEmptyTable": "<?php esc_js(__('No data available in table', 'winter-activity-log')); ?>",
     319                'sSearch': "<?php
     320esc_js( __( 'Search', 'winter-activity-log' ) );
     321?>",
     322                "sLengthMenu": "<?php
     323esc_js( __( 'Show _MENU_ entries', 'winter-activity-log' ) );
     324?>",
     325                "sInfoEmpty": "<?php
     326esc_js( __( 'Showing 0 to 0 of 0 entries', 'winter-activity-log' ) );
     327?>",
     328                "sInfo": "<?php
     329esc_js( __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log' ) );
     330?>",
     331                "sEmptyTable": "<?php
     332esc_js( __( 'No data available in table', 'winter-activity-log' ) );
     333?>",
    286334            },
    287335            'dom': "<'row'<'col-sm-7 col-md-5'f><'col-sm-5 col-md-6'l>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>"
  • winterlock/trunk/application/views/wal_usersessions/index.php

    r3227676 r3441603  
    169169                        "page": 'wal_usersessions',
    170170                        "function": 'datatable',
    171                         "action": 'winter_activity_log_action'
     171                        "action": 'winter_activity_log_action',
     172                        "winterlock_secure": '<?php echo esc_js(wp_create_nonce( 'winterlock_secure_ajax' ));?>'
    172173                    } );
    173174                }
  • winterlock/trunk/application/views/winteractivitylog/index.php

    r3419393 r3441603  
    1414?>
    1515
    16 <?php
     16<?php 
    1717$def_col_level = 0;
    1818$def_col_date = 0;
     
    2222$def_col_description = 0;
    2323$def_col_select = 1;
    24 $def_cols = ['level','date','avatar','user','ip','description'];
    25 foreach ($def_cols as $def_column){
    26     if(sw_wal_log_is_visible_table_column($def_column)){
     24$def_cols = [
     25    'level',
     26    'date',
     27    'avatar',
     28    'user',
     29    'ip',
     30    'description'
     31];
     32foreach ( $def_cols as $def_column ) {
     33    if ( sw_wal_log_is_visible_table_column( $def_column ) ) {
    2734        $s_plus = false;
    28         foreach ($def_cols as $col) {
    29             if($col == $def_column) $s_plus = true;
    30             if($s_plus)
    31                 ${'def_col_'.$col}++;
     35        foreach ( $def_cols as $col ) {
     36            if ( $col == $def_column ) {
     37                $s_plus = true;
     38            }
     39            if ( $s_plus ) {
     40                ${'def_col_' . $col}++;
     41            }
    3242        }
    3343        $def_col_select++;
    3444    }
    3545}
    36 
    3746?>
    3847
     
    4251
    4352<h1>
    44     <?php echo __('Activity log','winter-activity-log'); ?>
    45     <?php if(get_option('wal_checkbox_disable_hints', '0') == '0'): ?>
    46         <a href="#popup_tutorial" id="popup_tutorial" class="page-title-action pull-right"><i class="fa fa-video-camera"></i>&nbsp;&nbsp;<?php echo __('Need help? Check Video tutorials!','winter-activity-log'); ?></a>
    47     <?php endif; ?>
     53    <?php
     54echo __( 'Activity log', 'winter-activity-log' );
     55?>
     56    <?php
     57if ( get_option( 'wal_checkbox_disable_hints', '0' ) == '0' ) {
     58    ?>
     59        <a href="#popup_tutorial" id="popup_tutorial" class="page-title-action pull-right"><i class="fa fa-video-camera"></i>&nbsp;&nbsp;<?php
     60    echo __( 'Need help? Check Video tutorials!', 'winter-activity-log' );
     61    ?></a>
     62    <?php
     63}
     64?>
    4865</h1>
    4966
     
    5168    <div class="panel panel-default">
    5269        <div class="panel-heading flex">
    53             <h3 class="panel-title"><?php echo __('Logged data','winter-activity-log'); ?></h3>
     70            <h3 class="panel-title"><?php
     71echo __( 'Logged data', 'winter-activity-log' );
     72?></h3>
    5473        </div>
    5574        <div class="panel-body">
     
    6180                            <tr>
    6281                                <th data-priority="1" width="40px">#</th>
    63                                 <?php if(sw_wal_log_is_visible_table_column('level')):?>
    64                                 <th data-priority="2" width="40px"><?php echo __('Level', 'winter-activity-log'); ?></th>
    65                                 <?php endif;?>
    66                                 <?php if(sw_wal_log_is_visible_table_column('date')):?>
    67                                     <th data-priority="4"><?php echo __('Date', 'winter-activity-log'); ?></th>
    68                                 <?php endif;?>
    69                                 <?php if(sw_wal_log_is_visible_table_column('avatar')):?>
    70                                     <th data-priority="2"><?php echo __('Avatar', 'winter-activity-log'); ?></th>
    71                                 <?php endif;?>
    72                                 <?php if(sw_wal_log_is_visible_table_column('user')):?>
    73                                     <th data-priority="2"><?php echo __('User', 'winter-activity-log'); ?></th>
    74                                 <?php endif;?>
    75                                 <?php if(sw_wal_log_is_visible_table_column('ip')):?>
    76                                     <th><?php echo __('IP', 'winter-activity-log'); ?></th>
    77                                 <?php endif;?>
    78                                 <?php if(sw_wal_log_is_visible_table_column('description')):?>
    79                                     <th><?php echo __('Description', 'winter-activity-log'); ?></th>
    80                                 <?php endif;?>
     82                                <?php
     83if ( sw_wal_log_is_visible_table_column( 'level' ) ) {
     84    ?>
     85                                <th data-priority="2" width="40px"><?php
     86    echo __( 'Level', 'winter-activity-log' );
     87    ?></th>
     88                                <?php
     89}
     90?>
     91                                <?php
     92if ( sw_wal_log_is_visible_table_column( 'date' ) ) {
     93    ?>
     94                                    <th data-priority="4"><?php
     95    echo __( 'Date', 'winter-activity-log' );
     96    ?></th>
     97                                <?php
     98}
     99?>
     100                                <?php
     101if ( sw_wal_log_is_visible_table_column( 'avatar' ) ) {
     102    ?>
     103                                    <th data-priority="2"><?php
     104    echo __( 'Avatar', 'winter-activity-log' );
     105    ?></th>
     106                                <?php
     107}
     108?>
     109                                <?php
     110if ( sw_wal_log_is_visible_table_column( 'user' ) ) {
     111    ?>
     112                                    <th data-priority="2"><?php
     113    echo __( 'User', 'winter-activity-log' );
     114    ?></th>
     115                                <?php
     116}
     117?>
     118                                <?php
     119if ( sw_wal_log_is_visible_table_column( 'ip' ) ) {
     120    ?>
     121                                    <th><?php
     122    echo __( 'IP', 'winter-activity-log' );
     123    ?></th>
     124                                <?php
     125}
     126?>
     127                                <?php
     128if ( sw_wal_log_is_visible_table_column( 'description' ) ) {
     129    ?>
     130                                    <th><?php
     131    echo __( 'Description', 'winter-activity-log' );
     132    ?></th>
     133                                <?php
     134}
     135?>
    81136                                <th data-priority="3" width="100px"></th>
    82137                                <th width="10px"><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
     
    88143                        <tfoot>
    89144                            <tr>
    90                                 <th><input type="text" name="filter_id" class="dinamic_par"  placeholder="<?php echo __('Filter #', 'winter-activity-log'); ?>" /></th>
    91                                 <?php if(sw_wal_log_is_visible_table_column('level')):?>
    92                                 <th><input type="text" name="filter_level" class="dinamic_par" placeholder="<?php echo __('Filter Level', 'winter-activity-log'); ?>" /></th>
    93                                 <?php endif;?>
    94                                 <?php if(sw_wal_log_is_visible_table_column('date')):?>
    95                                 <th><input type="text" id="filter_date" name="filter_date" class="dinamic_par" placeholder="<?php echo __('Filter Date From', 'winter-activity-log'); ?>" /></th>
    96                                 <?php endif;?>
    97                                 <?php if(sw_wal_log_is_visible_table_column('avatar')):?>
     145                                <th><input type="text" name="filter_id" class="dinamic_par"  placeholder="<?php
     146echo __( 'Filter #', 'winter-activity-log' );
     147?>" /></th>
     148                                <?php
     149if ( sw_wal_log_is_visible_table_column( 'level' ) ) {
     150    ?>
     151                                <th><input type="text" name="filter_level" class="dinamic_par" placeholder="<?php
     152    echo __( 'Filter Level', 'winter-activity-log' );
     153    ?>" /></th>
     154                                <?php
     155}
     156?>
     157                                <?php
     158if ( sw_wal_log_is_visible_table_column( 'date' ) ) {
     159    ?>
     160                                <th><input type="text" id="filter_date" name="filter_date" class="dinamic_par" placeholder="<?php
     161    echo __( 'Filter Date From', 'winter-activity-log' );
     162    ?>" /></th>
     163                                <?php
     164}
     165?>
     166                                <?php
     167if ( sw_wal_log_is_visible_table_column( 'avatar' ) ) {
     168    ?>
    98169                                <th></th>
    99                                 <?php endif;?>
    100                                 <?php if(sw_wal_log_is_visible_table_column('user')):?>
    101                                 <th><input type="text" id="filter_user" name="filter_user" value="<?php echo esc_attr(wmvc_show_data('filter_user', $_GET, '')); ?>" class="dinamic_par" placeholder="<?php echo __('Filter User', 'winter-activity-log'); ?>" /></th>
    102                                 <?php endif;?>
    103                                 <?php if(sw_wal_log_is_visible_table_column('ip')):?>
    104                                 <th><input type="text" name="filter_ip" class="dinamic_par" placeholder="<?php echo __('Filter IP', 'winter-activity-log'); ?>" /></th>
    105                                 <?php endif;?>
    106                                 <?php if(sw_wal_log_is_visible_table_column('description')):?>
    107                                 <th><input type="text" name="filter_description" class="dinamic_par" placeholder="<?php echo __('Filter Description', 'winter-activity-log'); ?>" /></th>
    108                                 <?php endif;?>
     170                                <?php
     171}
     172?>
     173                                <?php
     174if ( sw_wal_log_is_visible_table_column( 'user' ) ) {
     175    ?>
     176                                <th><input type="text" id="filter_user" name="filter_user" value="<?php
     177    echo esc_attr( wmvc_show_data( 'filter_user', $_GET, '' ) );
     178    ?>" class="dinamic_par" placeholder="<?php
     179    echo __( 'Filter User', 'winter-activity-log' );
     180    ?>" /></th>
     181                                <?php
     182}
     183?>
     184                                <?php
     185if ( sw_wal_log_is_visible_table_column( 'ip' ) ) {
     186    ?>
     187                                <th><input type="text" name="filter_ip" class="dinamic_par" placeholder="<?php
     188    echo __( 'Filter IP', 'winter-activity-log' );
     189    ?>" /></th>
     190                                <?php
     191}
     192?>
     193                                <?php
     194if ( sw_wal_log_is_visible_table_column( 'description' ) ) {
     195    ?>
     196                                <th><input type="text" name="filter_description" class="dinamic_par" placeholder="<?php
     197    echo __( 'Filter Description', 'winter-activity-log' );
     198    ?>" /></th>
     199                                <?php
     200}
     201?>
    109202                                <th colspan="2">
    110203                                    <div class="winterlock_save_search_filter">
    111204                                        <div class="winterlock_save_search_filter_btn">
    112                                             <a href="#" class="btn btn_save"><?php echo __('Save', 'winter-activity-log'); ?></a>
     205                                            <a href="#" class="btn btn_save"><?php
     206echo __( 'Save', 'winter-activity-log' );
     207?></a>
    113208                                            <a href="#" class="btn-toggle"><i class="fa fa-angle-down"></i></a>
    114209                                        </div>
     
    124219
    125220            <div class="form-inline">
    126                 <div class="checkbox  <?php if ( !winteractivitylog()->is_plan_or_trial('standard') ) echo 'wal-pro'; ?>">
     221                <div class="checkbox  <?php
     222if ( !winteractivitylog()->is_plan_or_trial( 'standard' ) ) {
     223    echo 'wal-pro';
     224}
     225?>">
    127226                    <label>
    128                         <input id="wal_live_monitoring" type="checkbox"> <?php echo __('Live monitoring enable (autorefresh each 10 sec)', 'winter-activity-log'); ?>
     227                        <input id="wal_live_monitoring" type="checkbox"> <?php
     228echo __( 'Live monitoring enable (autorefresh each 10 sec)', 'winter-activity-log' );
     229?>
    129230                    </label>
    130231                </div>
    131232               
    132233                <div class="footer-btns">
    133                     <a href="<?php echo admin_url("admin.php?page=wal_reports&function=report_edit"); ?>" class="btn btn-warning pull-right"><i class="fa fa-download"></i>&nbsp;&nbsp;<?php echo __('Export/Generate Report','winter-activity-log')?></a>
    134                     <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php echo __('Bulk remove','winter-activity-log')?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
    135                     <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php echo __('Clear all filters','winter-activity-log')?></a>
     234                    <a href="<?php
     235echo admin_url( "admin.php?page=wal_reports&function=report_edit" );
     236?>" class="btn btn-warning pull-right"><i class="fa fa-download"></i>&nbsp;&nbsp;<?php
     237echo __( 'Export/Generate Report', 'winter-activity-log' );
     238?></a>
     239                    <a href="#bulk_remove-form" id="bulk_remove" class="btn btn-danger pull-right popup-with-form"><i class="fa fa-remove"></i>&nbsp;&nbsp;<?php
     240echo __( 'Bulk remove', 'winter-activity-log' );
     241?><i class="fa fa-spinner fa-spin fa-custom-ajax-indicator-opc ajax-indicator-masking hidden_opacity"></i></a>
     242                    <a href="#clear_filters" id="clear_filters" class="btn btn-danger pull-right "><i class="fa fa-trash"></i>&nbsp;&nbsp;<?php
     243echo __( 'Clear all filters', 'winter-activity-log' );
     244?></a>
    136245                </div>
    137246            </div>
     
    140249
    141250    <?php
    142     if ( winteractivitylog()->is__premium_only() ) {
    143     if ( !winteractivitylog()->is_plan_or_trial('standard') ){ ?>
    144         <div class="alert alert-danger" role="alert"><?php echo __('Min. standard package is required for live monitoring feature', 'winter-activity-log'); ?></div>
    145     <?php }} ?>
     251?>
    146252   
    147253</div>
     
    149255
    150256
    151 <?php
    152 
    153 wp_enqueue_style('winter-activity-log_basic_wrapper');
     257<?php
     258wp_enqueue_style( 'winter-activity-log_basic_wrapper' );
    154259wp_enqueue_script( 'datatables' );
    155260wp_enqueue_script( 'dataTables-responsive' );
    156261wp_enqueue_script( 'dataTables-select' );
    157 
    158262wp_enqueue_style( 'dataTables-select' );
    159263?>
     
    179283    });
    180284
    181     <?php if(sw_wal_log_is_visible_table_column('date')):?>
     285    <?php
     286if ( sw_wal_log_is_visible_table_column( 'date' ) ) {
     287    ?>
    182288    $("#filter_date").on("dp.change", function (e) {
    183289        $("#filter_date").trigger('change');
    184         table.columns(<?php $def_col_date;?>).search( $('#filter_date').val() ).draw();
     290        table.columns(<?php
     291    $def_col_date;
     292    ?>).search( $('#filter_date').val() ).draw();
    185293    });
    186     <?php endif;?>
     294    <?php
     295}
     296?>
    187297       
    188298    /* winterlock_save_search_filter */
     
    243353            'function': 'filter_get',
    244354            "action": 'winter_activity_log_action',
     355             "winterlock_secure": '<?php
     356echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     357?>'
    245358        };
    246359
    247         $.post('<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>', data,
     360        $.post('<?php
     361echo esc_url( admin_url( 'admin-ajax.php' ) );
     362?>', data,
    248363        function(data){
    249364            var html ='';
     
    283398                setTimeout(function(){jQuery('.dinamic_par[name=\"sw_log_search\"]').trigger('change');},1500);
    284399
    285                 sw_log_notify('<?php echo __('Loaded filter', 'winter-activity-log'); ?> '+$(this).contents()[0].textContent);
     400                sw_log_notify('<?php
     401echo __( 'Loaded filter', 'winter-activity-log' );
     402?> '+$(this).contents()[0].textContent);
    286403                $(this).closest('.winterlock_save_search_filter').removeClass('show');
    287404        })
     
    296413                    "action": 'winter_activity_log_action',
    297414                    "filter_id": $(this).attr('data-fielderid') || '',
     415                     "winterlock_secure": '<?php
     416echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     417?>'
    298418                };
    299                 sw_log_notify('<?php echo __('Removing filter', 'winter-activity-log'); ?> '+title, 'loading');
    300 
    301                 $.post('<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>', data,
     419                sw_log_notify('<?php
     420echo __( 'Removing filter', 'winter-activity-log' );
     421?> '+title, 'loading');
     422
     423                $.post('<?php
     424echo esc_url( admin_url( 'admin-ajax.php' ) );
     425?>', data,
    302426                function(data){
    303427
    304428                }, "json").success(function(){
    305                     sw_log_notify('<?php echo __('Removed filter', 'winter-activity-log'); ?> '+title);
     429                    sw_log_notify('<?php
     430echo __( 'Removed filter', 'winter-activity-log' );
     431?> '+title);
    306432                    reload_filters();
    307433                });
     
    319445       
    320446        if(is_empty) {
    321             sw_log_notify('<?php echo __('Fitlers are empty', 'winter-activity-log'); ?>', 'error');
     447            sw_log_notify('<?php
     448echo __( 'Fitlers are empty', 'winter-activity-log' );
     449?>', 'error');
    322450            return false;   
    323451        }
     
    327455            boxWidth: '400px',
    328456            useBootstrap: false,
    329             title: '<?php echo __('Save', 'winter-activity-log'); ?>',
     457            title: '<?php
     458echo __( 'Save', 'winter-activity-log' );
     459?>',
    330460            content: '' +
    331461            '<form action="" class="winterlock_list_filters_form formName">' +
    332462            '<div class="form-group">' +
    333             '<label><?php echo __('Filter name', 'winter-activity-log'); ?></label>' +
    334             '<input type="text" placeholder="<?php echo __('Filter name', 'winter-activity-log'); ?>" class="filter_name form-control" required />' +
     463            '<label><?php
     464echo __( 'Filter name', 'winter-activity-log' );
     465?></label>' +
     466            '<input type="text" placeholder="<?php
     467echo __( 'Filter name', 'winter-activity-log' );
     468?>" class="filter_name form-control" required />' +
    335469            '</div>' +
    336470            '</form>',
    337471            buttons: {
    338472                formSubmit: {
    339                     text: '<?php echo __('Save', 'winter-activity-log'); ?>',
     473                    text: '<?php
     474echo __( 'Save', 'winter-activity-log' );
     475?>',
    340476                    btnClass: 'btn-blue',
    341477                    action: function () {
     
    351487                            "action": 'winter_activity_log_action',
    352488                            "filter_name": filter_name,
    353                             "filter_param": generate_json_filter()
     489                            "filter_param": generate_json_filter(),
     490                             "winterlock_secure": '<?php
     491echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     492?>'
    354493                        };
    355494
    356                         $.post('<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>', data,
     495                        $.post('<?php
     496echo esc_url( admin_url( 'admin-ajax.php' ) );
     497?>', data,
    357498                        function(data){
    358499                        }, "json").success(function(){
    359                             sw_log_notify('<?php echo __('Saved filter', 'winter-activity-log'); ?> '+filter_name);
     500                            sw_log_notify('<?php
     501echo __( 'Saved filter', 'winter-activity-log' );
     502?> '+filter_name);
    360503                            reload_filters();
    361504                        } );
     
    364507                },
    365508                cancel: {
    366                     text: '<?php echo __('Cancel', 'winter-activity-log'); ?>',
     509                    text: '<?php
     510echo __( 'Cancel', 'winter-activity-log' );
     511?>',
    367512                    action: function () {
    368513                    }
     
    434579        if(count == 0)
    435580        {
    436             alert('<?php echo esc_attr__('Please select listings to remove', 'winter-activity-log'); ?>');
     581            alert('<?php
     582echo esc_attr__( 'Please select listings to remove', 'winter-activity-log' );
     583?>');
    437584            load_indicator_opc.addClass('hidden_opacity');
    438585            return false;
     
    441588        {
    442589
    443             if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     590            if(confirm('<?php
     591esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     592?>'))
    444593            {
    445594                $('img#ajax-indicator-masking').show();
     
    449598
    450599                // ajax to remove rows
    451                 $.post('<?php menu_page_url( 'winteractivitylog', true ); ?>&function=bulk_remove&_wpnonce=<?php echo esc_js(wp_create_nonce( 'winteractivitylog-bulk'));?>', { log_ids: ids }, function(data) {
     600                $.post('<?php
     601menu_page_url( 'winteractivitylog', true );
     602?>&function=bulk_remove&_wpnonce=<?php
     603echo esc_js( wp_create_nonce( 'winteractivitylog-bulk' ) );
     604?>', { log_ids: ids }, function(data) {
    452605
    453606                    $('img#ajax-indicator-masking').hide();
     
    495648                        "page": 'winteractivitylog',
    496649                        "function": 'datatable',
    497                         "action": 'winter_activity_log_action'
     650                        "action": 'winter_activity_log_action',
     651                        "winterlock_secure": '<?php
     652echo esc_js( wp_create_nonce( 'winterlock_secure_ajax' ) );
     653?>',
    498654                    } );
    499655
     
    502658            },
    503659            "language": {
    504                 search: "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    505                 searchPlaceholder: "<?php esc_js(__('Enter here filter tag for any column', 'winter-activity-log')); ?>"
     660                search: "<?php
     661esc_js( __( 'Search', 'winter-activity-log' ) );
     662?>",
     663                searchPlaceholder: "<?php
     664esc_js( __( 'Enter here filter tag for any column', 'winter-activity-log' ) );
     665?>"
    506666            },
    507667            "initComplete": function(settings, json) {
     
    512672                {
    513673                    sw_log_s_table_load_counter++;
    514                     <?php if(sw_wal_log_is_visible_table_column('user')):?> 
     674                    <?php
     675if ( sw_wal_log_is_visible_table_column( 'user' ) ) {
     676    ?> 
    515677                    if($('#filter_user').val() != '')
    516                     setTimeout(function(){ table.columns(<?php echo intval($def_col_user);?>).search( $('#filter_user').val() ).draw(); }, 1000);
    517                     <?php endif;?>
     678                    setTimeout(function(){ table.columns(<?php
     679    echo intval( $def_col_user );
     680    ?>).search( $('#filter_user').val() ).draw(); }, 1000);
     681                    <?php
     682}
     683?>
    518684                   
    519685                }
     
    521687                $('a.delete_button').click(function(){
    522688                   
    523                     if(confirm('<?php esc_js(__('Are you sure?', 'winter-activity-log')); ?>'))
     689                    if(confirm('<?php
     690esc_js( __( 'Are you sure?', 'winter-activity-log' ) );
     691?>'))
    524692                    {
    525693                       // ajax to remove row
     
    563731            'columns': [
    564732                { data: "idlog" },
    565                 <?php if(sw_wal_log_is_visible_table_column('level')):?>
     733                <?php
     734if ( sw_wal_log_is_visible_table_column( 'level' ) ) {
     735    ?>
    566736                    { data: "level" },
    567                 <?php endif;?>
    568                 <?php if(sw_wal_log_is_visible_table_column('date')):?>
     737                <?php
     738}
     739?>
     740                <?php
     741if ( sw_wal_log_is_visible_table_column( 'date' ) ) {
     742    ?>
    569743                    { data: "date"   },
    570                 <?php endif;?>
    571                 <?php if(sw_wal_log_is_visible_table_column('avatar')):?>
     744                <?php
     745}
     746?>
     747                <?php
     748if ( sw_wal_log_is_visible_table_column( 'avatar' ) ) {
     749    ?>
    572750                    { data: "avatar"  },
    573                 <?php endif;?>
    574                 <?php if(sw_wal_log_is_visible_table_column('user')):?>
     751                <?php
     752}
     753?>
     754                <?php
     755if ( sw_wal_log_is_visible_table_column( 'user' ) ) {
     756    ?>
    575757                    { data: "user_info"  },
    576                 <?php endif;?>
    577                 <?php if(sw_wal_log_is_visible_table_column('ip')):?>
     758                <?php
     759}
     760?>
     761                <?php
     762if ( sw_wal_log_is_visible_table_column( 'ip' ) ) {
     763    ?>
    578764                    { data: "ip"   },
    579                 <?php endif;?>
    580                 <?php if(sw_wal_log_is_visible_table_column('description')):?>
     765                <?php
     766}
     767?>
     768                <?php
     769if ( sw_wal_log_is_visible_table_column( 'description' ) ) {
     770    ?>
    581771                    { data: "description"},
    582                 <?php endif;?>
     772                <?php
     773}
     774?>
    583775               
    584776                { data: "edit"    },
     
    597789            order: [[ 0, 'desc' ]],
    598790            columnDefs: [   
    599                             <?php if(sw_wal_log_is_visible_table_column('avatar')):?>
     791                            <?php
     792if ( sw_wal_log_is_visible_table_column( 'avatar' ) ) {
     793    ?>
    600794                            {
    601                                 targets: <?php echo intval($def_col_avatar);?>,
     795                                targets: <?php
     796    echo intval( $def_col_avatar );
     797    ?>,
    602798                                orderable: false
    603799                            },
    604                             <?php endif;?>       
     800                            <?php
     801}
     802?>       
    605803                            {
    606804                                //className: 'control',
     
    609807                                targets:   0
    610808                            },
    611                             <?php if(sw_wal_log_is_visible_table_column('user')):?>       
     809                            <?php
     810if ( sw_wal_log_is_visible_table_column( 'user' ) ) {
     811    ?>       
    612812                            {
    613813                                //className: 'control',
    614814                                //className: 'details-control',
    615815                                orderable: false,
    616                                 targets:   <?php echo intval($def_col_user);?>
     816                                targets:   <?php
     817    echo intval( $def_col_user );
     818    ?>
    617819                            },
    618                             <?php endif;?>       
    619                             <?php if(sw_wal_log_is_visible_table_column('ip')):?>     
     820                            <?php
     821}
     822?>       
     823                            <?php
     824if ( sw_wal_log_is_visible_table_column( 'ip' ) ) {
     825    ?>     
    620826                            {
    621                                 targets: <?php echo intval($def_col_ip);?>,
     827                                targets: <?php
     828    echo intval( $def_col_ip );
     829    ?>,
    622830                                orderable: false,
    623831                                defaultContent: '2',
    624832                            },
    625                             <?php endif;?>
    626                             <?php if(sw_wal_log_is_visible_table_column('description')):?>
     833                            <?php
     834}
     835?>
     836                            <?php
     837if ( sw_wal_log_is_visible_table_column( 'description' ) ) {
     838    ?>
    627839                            {
    628                                 targets: <?php echo intval($def_col_description);?>,
     840                                targets: <?php
     841    echo intval( $def_col_description );
     842    ?>,
    629843                                orderable: false
    630844                            },
    631                             <?php endif;?>       
     845                            <?php
     846}
     847?>       
    632848                            {
    633                                 targets: <?php echo intval($def_col_select);?>,
     849                                targets: <?php
     850echo intval( $def_col_select );
     851?>,
    634852                                orderable: false
    635853                            },
     
    638856                                orderable: false,
    639857                                defaultContent: '',
    640                                 targets:   <?php echo intval($def_col_select+1);?>
     858                                targets:   <?php
     859echo intval( $def_col_select + 1 );
     860?>
    641861                            }
    642862            ],
     
    650870                    'sNext': '<i class="fa fa-angle-right"></i>'
    651871                },
    652                 'sSearch': "<?php esc_js(__('Search', 'winter-activity-log')); ?>",
    653                 "sLengthMenu": "<?php esc_js(__('Show _MENU_ entries', 'winter-activity-log')); ?>",
    654                 "sInfoEmpty": "<?php esc_js(__('Showing 0 to 0 of 0 entries', 'winter-activity-log')); ?>",
    655                 "sInfo": "<?php esc_js( __('Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log')); ?>",
    656                 "sEmptyTable": "<?php esc_js(__('No data available in table', 'winter-activity-log')); ?>",
     872                'sSearch': "<?php
     873esc_js( __( 'Search', 'winter-activity-log' ) );
     874?>",
     875                "sLengthMenu": "<?php
     876esc_js( __( 'Show _MENU_ entries', 'winter-activity-log' ) );
     877?>",
     878                "sInfoEmpty": "<?php
     879esc_js( __( 'Showing 0 to 0 of 0 entries', 'winter-activity-log' ) );
     880?>",
     881                "sInfo": "<?php
     882esc_js( __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'winter-activity-log' ) );
     883?>",
     884                "sEmptyTable": "<?php
     885esc_js( __( 'No data available in table', 'winter-activity-log' ) );
     886?>",
    657887            },
    658888            'dom': "<'row'<'col-sm-7 col-md-5'f><'col-sm-5 col-md-6'l>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>"
     
    7831013            draggable: true,
    7841014            backgroundDismiss: true, // this will just close the modal
    785             title: '<?php echo esc_html__('Tutorials', 'winter-activity-log');?>',
     1015            title: '<?php
     1016echo esc_html__( 'Tutorials', 'winter-activity-log' );
     1017?>',
    7861018            content: '<div class="winterlock_wrap wl_popup_tutorial">' +
    787                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=VWI1WvlQQa8&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to use quick search filtering?', 'winter-activity-log'); ?></a></div>'+
    788                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=v8jJcRkEfjI&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to Live Montor with auto refresh and detect login users?', 'winter-activity-log'); ?></a></div>'+
    789                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=utDuznzhsHg&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to check Login History and Block Failed Login Attempts?', 'winter-activity-log'); ?></a></div>'+
    790                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=bLG_HZrpEX0&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to Block IP, Username, some words in title or any other criteria?', 'winter-activity-log'); ?></a></div>'+
    791                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=v9dJ8F9ekVI&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to Log Content Editing and check Revisions?', 'winter-activity-log'); ?></a></div>'+
    792                 '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=rVwcz6pbBWM&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php echo __('How to Detect File Changes?', 'winter-activity-log'); ?></a></div>'+
     1019                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=VWI1WvlQQa8&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1020echo __( 'How to use quick search filtering?', 'winter-activity-log' );
     1021?></a></div>'+
     1022                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=v8jJcRkEfjI&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1023echo __( 'How to Live Montor with auto refresh and detect login users?', 'winter-activity-log' );
     1024?></a></div>'+
     1025                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=utDuznzhsHg&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1026echo __( 'How to check Login History and Block Failed Login Attempts?', 'winter-activity-log' );
     1027?></a></div>'+
     1028                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=bLG_HZrpEX0&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1029echo __( 'How to Block IP, Username, some words in title or any other criteria?', 'winter-activity-log' );
     1030?></a></div>'+
     1031                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=v9dJ8F9ekVI&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1032echo __( 'How to Log Content Editing and check Revisions?', 'winter-activity-log' );
     1033?></a></div>'+
     1034                '<div class="alert alert-warning" role="alert"><a target="_blank" href="https://www.youtube.com/watch?v=rVwcz6pbBWM&list=PL0MjUuUth-hVFykhkW_UN8fsoAYJVbhf2"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php
     1035echo __( 'How to Detect File Changes?', 'winter-activity-log' );
     1036?></a></div>'+
    7931037                '<iframe width="560" height="315" src="https://www.youtube.com/embed/bLG_HZrpEX0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'+
    7941038            '</div>',
    7951039            buttons: {
    7961040                cancel: {
    797                     text: '<?php echo esc_html__('Close', 'winter-activity-log');?>',
     1041                    text: '<?php
     1042echo esc_html__( 'Close', 'winter-activity-log' );
     1043?>',
    7981044                }
    7991045            },
     
    9991245</style>
    10001246
    1001 <?php $this->view('general/footer', $data); ?>
     1247<?php
     1248$this->view( 'general/footer', $data );
  • winterlock/trunk/includes/helper-functions.php

    r3419393 r3441603  
    11<?php
     2
    23// If this file is called directly, abort.
    3 if ( ! defined( 'ABSPATH' ) ) {
    4     die;
    5 }
    6 
    7 
    8 if ( ! function_exists( 'wal_is_single_or_archive_book' ) ):
    9     function wal_is_single_or_archive_book() {
    10         return
    11             (
    12                 is_singular( 'book' )
    13                 ||
    14                 wal_is_archive_book()
    15             )
    16                 ? true
    17                 : false;
    18 
    19     }
    20 endif;
    21 
    22 if ( ! function_exists( 'wal_is_archive_book' ) ):
    23     function wal_is_archive_book() {
    24         return
    25             (
    26                 is_post_type_archive( 'book' )
    27                 || is_tax( 'genre' )
    28             )
    29                 ? true
    30                 : false;
    31 
    32     }
    33 endif;
    34 
    35 if ( ! function_exists( 'wal_get_template_loader' ) ):
    36     function wal_get_template_loader() {
    37         return Winter_Activity_Log_Global::template_loader();
    38     }
    39 endif;
    40 
    41 
    42 if ( ! function_exists( 'wal_get_column_class' ) ):
    43     /**
    44      * @param $int int
    45      *
    46      * @return $css_class string
    47      */
    48     function wal_get_column_class( $int ) {
    49 
    50         switch ( $int ) {
    51 
    52             case( 1 ):
    53                 return 'column-one';
    54                 break;
    55             case( 2 ):
    56                 return 'column-two';
    57                 break;
    58             case( 3 ):
    59                 return 'column-three';
    60                 break;
    61             case( 4 ):
    62                 return 'column-four';
    63                 break;
    64             case( 5 ):
    65                 return 'column-five';
    66                 break;
    67 
    68             default:
    69                 return 'column-three';
    70 
    71         }
    72 
    73     }
    74 endif;
    75 
    76 if ( ! function_exists( 'wal_sanitize_color' ) ):
    77     function wal_sanitize_color( $value ) {
    78 
    79         if ( false === strpos( $value, 'rgba' ) ) {
    80             return sanitize_hex_color( $value );
    81         } else {
    82             // By now we know the string is formatted as an rgba color so we need to further sanitize it.
    83 
    84             $value = trim( $value, ' ' );
    85             $red   = $green = $blue = $alpha = '';
    86             sscanf( $value, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
    87 
    88             return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
    89         }
    90     }
    91 endif;
    92 
    93 
    94 
     4if ( !defined( 'ABSPATH' ) ) {
     5    die;
     6}
     7if ( !function_exists( 'wal_is_single_or_archive_book' ) ) {
     8    function wal_is_single_or_archive_book() {
     9        return ( is_singular( 'book' ) || wal_is_archive_book() ? true : false );
     10    }
     11
     12}
     13if ( !function_exists( 'wal_is_archive_book' ) ) {
     14    function wal_is_archive_book() {
     15        return ( is_post_type_archive( 'book' ) || is_tax( 'genre' ) ? true : false );
     16    }
     17
     18}
     19if ( !function_exists( 'wal_get_template_loader' ) ) {
     20    function wal_get_template_loader() {
     21        return Winter_Activity_Log_Global::template_loader();
     22    }
     23
     24}
     25if ( !function_exists( 'wal_get_column_class' ) ) {
     26    /**
     27     * @param $int int
     28     *
     29     * @return $css_class string
     30     */
     31    function wal_get_column_class(  $int  ) {
     32        switch ( $int ) {
     33            case 1:
     34                return 'column-one';
     35                break;
     36            case 2:
     37                return 'column-two';
     38                break;
     39            case 3:
     40                return 'column-three';
     41                break;
     42            case 4:
     43                return 'column-four';
     44                break;
     45            case 5:
     46                return 'column-five';
     47                break;
     48            default:
     49                return 'column-three';
     50        }
     51    }
     52
     53}
     54if ( !function_exists( 'wal_sanitize_color' ) ) {
     55    function wal_sanitize_color(  $value  ) {
     56        if ( false === strpos( $value, 'rgba' ) ) {
     57            return sanitize_hex_color( $value );
     58        } else {
     59            // By now we know the string is formatted as an rgba color so we need to further sanitize it.
     60            $value = trim( $value, ' ' );
     61            $red = $green = $blue = $alpha = '';
     62            sscanf(
     63                $value,
     64                'rgba(%d,%d,%d,%f)',
     65                $red,
     66                $green,
     67                $blue,
     68                $alpha
     69            );
     70            return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
     71        }
     72    }
     73
     74}
    9575// Display User IP in WordPress
    96  
    97 if ( ! function_exists( 'wal_get_the_user_ip' ) ):
    98     function wal_get_the_user_ip() {
    99         if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
    100             //check ip from share internet
    101             $ip = $_SERVER['HTTP_CLIENT_IP'];
    102         } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    103             //to check ip is pass from proxy
    104             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    105         } else {
    106             $ip = $_SERVER['REMOTE_ADDR'];
    107         }
    108 
    109         if (filter_var($ip, FILTER_VALIDATE_IP)) {
     76if ( !function_exists( 'wal_get_the_user_ip' ) ) {
     77    function wal_get_the_user_ip() {
     78        if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
     79            //check ip from share internet
     80            $ip = $_SERVER['HTTP_CLIENT_IP'];
     81        } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
     82            //to check ip is pass from proxy
     83            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     84        } else {
     85            $ip = $_SERVER['REMOTE_ADDR'];
     86        }
     87        if ( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
    11088            // $ip is a valid IP address"
    11189        } else {
    11290            return '';
    11391        }
    114 
    115         return apply_filters( 'wpb_get_ip', $ip );
    116     }
    117 endif;
    118 
    119 if ( ! function_exists( 'wal_get_uri' ) ):
    120     function wal_get_uri($skip_query_string = FALSE)
    121     {
    122         $filename = $_SERVER['REQUEST_URI'];
    123         $ipos = strpos($filename, "?");
    124         if ( !($ipos === false) && $skip_query_string === TRUE)   $filename = substr($filename, 0, $ipos);
    125         return urldecode($filename);
    126     }
    127 endif;
    128 
    129 function wal_post_for_log()
    130 {
     92        return apply_filters( 'wpb_get_ip', $ip );
     93    }
     94
     95}
     96if ( !function_exists( 'wal_get_uri' ) ) {
     97    function wal_get_uri(  $skip_query_string = FALSE  ) {
     98        $filename = $_SERVER['REQUEST_URI'];
     99        $ipos = strpos( $filename, "?" );
     100        if ( !($ipos === false) && $skip_query_string === TRUE ) {
     101            $filename = substr( $filename, 0, $ipos );
     102        }
     103        return urldecode( $filename );
     104    }
     105
     106}
     107function wal_post_for_log() {
    131108    $log_array = array();
    132 
    133     foreach($_POST as $key => $val)
    134     {
    135         if(is_array($val))
    136         {
    137             return wal_sen_rec($_POST);
    138         }
    139         elseif($key == 'content')
    140         {
    141             $log_array[sanitize_text_field($key)] = wp_kses_post($val);
    142         }
    143         else
    144         {
    145             $log_array[sanitize_text_field($key)] = sanitize_text_field($val);
    146         }
    147     }
    148 
     109    foreach ( $_POST as $key => $val ) {
     110        if ( is_array( $val ) ) {
     111            return wal_sen_rec( $_POST );
     112        } elseif ( $key == 'content' ) {
     113            $log_array[sanitize_text_field( $key )] = wp_kses_post( $val );
     114        } else {
     115            $log_array[sanitize_text_field( $key )] = sanitize_text_field( $val );
     116        }
     117    }
    149118    return $log_array;
    150119}
    151120
    152 function wal_get_for_log()
    153 {
     121function wal_get_for_log() {
    154122    $log_array = array();
    155 
    156     foreach($_GET as $key => $val)
    157     {
    158         if(is_array($val))
    159         {
    160             return wal_sen_rec($_POST);
    161         }
    162         elseif($key == 'newcontent' || $key == 'content')
    163         {
    164             $log_array[sanitize_text_field($key)] = wp_kses_post($val);
    165         }
    166         else
    167         {
    168             $log_array[sanitize_text_field($key)] = sanitize_text_field($val);
    169         }
    170     }
    171 
     123    foreach ( $_GET as $key => $val ) {
     124        if ( is_array( $val ) ) {
     125            return wal_sen_rec( $_POST );
     126        } elseif ( $key == 'newcontent' || $key == 'content' ) {
     127            $log_array[sanitize_text_field( $key )] = wp_kses_post( $val );
     128        } else {
     129            $log_array[sanitize_text_field( $key )] = sanitize_text_field( $val );
     130        }
     131    }
    172132    return $log_array;
    173133}
    174134
    175 function wal_sen_rec($array)
    176 {
     135function wal_sen_rec(  $array  ) {
    177136    $arr_cleaned = array();
    178     foreach($array as $key=>$val)
    179     {
    180         if(is_array($val))
    181         {
    182             $arr_cleaned[sanitize_text_field($key)] = wal_sen_rec($val);
    183         }
    184         elseif($key == 'newcontent' || $key == 'content')
    185         {
    186             $arr_cleaned[sanitize_text_field($key)] = wp_kses_post($val);
    187         }
    188         else
    189         {
    190             $arr_cleaned[sanitize_text_field($key)] = sanitize_text_field($val);
    191         }
    192        
    193     }
    194 
     137    foreach ( $array as $key => $val ) {
     138        if ( is_array( $val ) ) {
     139            $arr_cleaned[sanitize_text_field( $key )] = wal_sen_rec( $val );
     140        } elseif ( $key == 'newcontent' || $key == 'content' ) {
     141            $arr_cleaned[sanitize_text_field( $key )] = wp_kses_post( $val );
     142        } else {
     143            $arr_cleaned[sanitize_text_field( $key )] = sanitize_text_field( $val );
     144        }
     145    }
    195146    //dump($arr_cleaned);
    196 
    197147    return $arr_cleaned;
    198148}
    199149
    200 
    201 
    202 if ( ! function_exists('wal_resolve_level'))
    203 {
    204     function wal_resolve_level($request_uri = NULL, $post = NULL, $get = NULL, $request_method = NULL, $body = NULL, $fixed_level = NULL)
    205     {
    206         if(!empty($fixed_level))
    207         {
    208             return $fixed_level;
    209         }
    210 
    211         $level = 1;
    212 
    213         if($request_uri === NULL && $post === NULL && $get === NULL)
    214         {
    215             $request_uri = wal_get_uri();
    216             $post = wal_post_for_log();
    217             $get = wal_get_for_log();
    218             $request_method = sanitize_text_field($_SERVER['REQUEST_METHOD']);
    219         }
    220 
    221         if($request_method == 'POST' && (count($post) > 0 || is_array($body)))
    222             $level = 2;
    223        
    224         // standard wp ajax requests defined to level q
    225         if(
    226             strpos($request_uri, 'admin-ajax.php') === FALSE &&
    227             strpos($request_uri, 'wp-cron.php') === FALSE &&
    228             strpos($request_uri, 'wp_scrape_nonce') === FALSE &&
    229             strpos($request_uri, 'wp-json') === FALSE
    230             )
    231         {
    232             if(count($post) > 0)
    233                 $level = 3;
    234         }
    235 
    236         // if ajax
    237         if(strpos($request_uri, 'admin-ajax.php') !== FALSE)
    238         {
    239             // action post contain get-
    240             if(substr($post['action'], 0, 4) == 'get-')
    241                 $level = 1;
    242         }
    243        
    244         if(strpos($request_uri, 'post-new.php') !== FALSE)
    245         {
    246             $level = 4;
    247         }
    248 
    249         if(strpos($request_uri, 'edit.php') !== FALSE)
    250         {
    251             $level = 4;
    252         }
    253 
    254         if( isset($body['edit_date']) ||
    255             isset($body['post_type']) ||
    256             isset($body['post_ID']) ||
    257             isset($body['post_status']) ||
    258             isset($body['content']) ||
    259             isset($post['post_type']) ||
    260             isset($post['post_ID']) ||
    261             isset($post['post_status']) ||
    262             isset($post['edit_date']) ||
    263             isset($post['content']) )
    264         {
    265             $level = 4;
    266         }
    267 
    268         if(isset($post['action']) && $post['action'] == 'edit-theme-plugin-file')
    269         {
    270             $level = 4;
    271         }
    272        
    273         if(isset($get['action']) && $get['action'] == 'delete')
    274         {
    275             $level = 4;
    276         }
    277        
    278         if(isset($get['action']) && $get['action'] == 'trash')
    279         {
    280             $level = 4;
    281         }
    282        
    283         if(isset($get['action']) && $get['action'] == 'logout')
    284         {
    285             $level = 2;
    286         }
    287 
    288         if(isset($get['plugin']) || isset($get['deleted']) || isset($get['trashed']))
    289         {
    290             $level = 4;
    291         }
    292 
    293         return $level;
    294     }
    295 }
    296 
    297 if ( ! function_exists('wal_generate_label_by_level'))
    298 {
    299     function wal_generate_label_by_level($level, $message = '')
    300     {
    301         if(empty($message))$message = $level;
    302 
    303         if($level==1)
    304         {
    305             return '<span class="label label-default" title="'.__('Most basic activities log, like when someone open some page','winter-activity-log').'">'.$message.'</span>';
    306         }
    307         if($level==2)
    308         {
    309             return '<span class="label label-primary" title="'.__('Something is sent in POST via ajax, sometimes this mean change in database','winter-activity-log').'">'.$message.'</span>';
    310         }
    311         if($level==3)
    312         {
    313             return '<span class="label label-success" title="'.__('Something general is sent in POST to regular page, mostly this mean change in database','winter-activity-log').'">'.$message.'</span>';
    314         }
    315         if($level==4)
    316         {
    317             return '<span class="label label-info" title="'.__('Editing known contents like post, page or similar','winter-activity-log').'">'.$message.'</span>';
    318         }
    319         if($level==5)
    320         {
    321             return '<span class="label label-warning" title="'.__('Critical tasks like FAILED login','winter-activity-log').'">'.$message.'</span>';
    322         }
    323         if($level==6)
    324         {
    325             return '<span class="label label-danger" title="'.__('Very critical tasks like hacking','winter-activity-log').'">'.$message.'</span>';
    326         }
    327 
    328         return $message;
    329     }
    330 }
    331 
    332 if ( ! function_exists('wal_resolve_wp_menu'))
    333 {
    334     function wal_resolve_wp_menu($page=NULL, $request_uri=NULL)
    335     {
    336         global $submenu, $menu, $pagenow;
    337 
    338         $submenu_c = $submenu;
    339         $menu_c = $menu;
    340         $pagenow_c = $pagenow;
    341        
    342         if(empty($page) && empty($request_uri))return;
    343 
    344         if(!isset($submenu_c))
    345         {
    346             $menu_c = get_option( 'winter-activity-log-menuitems' );
    347             $submenu_c = get_option( 'winter-activity-log-submenuitems' );
    348         }
    349        
    350         $text = '';
    351 
    352         if(is_array($menu_c) && !empty($page))
    353         foreach($menu_c as $key=>$row)
    354         {
    355             if(in_array($page, $row))
    356             {
    357                 $text.=$row[0];
    358             }
    359         }
    360 
    361         if(is_array($submenu_c) && !empty($page))
    362         foreach($submenu_c as $key=>$row)
    363         {
    364             foreach($row as $key2=>$row2)
    365             {
    366                 if(in_array($page, $row2))
    367                 {
    368                     if(empty($text))
    369                     {
    370                         $text.=$row2[0];
    371                     }
    372                     else
    373                     {
    374                         $text.=' > '.$row2[0];
    375                     }
    376                 }
    377                
    378             }           
    379         }
    380 
    381 
    382 
    383         if(strpos($request_uri, 'wp-admin') !== FALSE)
    384             $request_uri = basename($request_uri);
    385 
    386         if(is_array($menu_c) && !empty($request_uri))
    387         foreach($menu_c as $key=>$row)
    388         {
    389             if(in_array($request_uri, $row))
    390             {
    391                 if(empty($text))
    392                 {
    393                     $text.=$row[0];
    394                 }
    395                 else
    396                 {
    397                     $text.=' > '.$row[0];
    398                 }
    399             }
    400         }
    401 
    402         if(is_array($submenu_c) && !empty($request_uri))
    403         foreach($submenu_c as $key=>$row)
    404         {
    405             foreach($row as $key2=>$row2)
    406             {
    407                 if(in_array($request_uri, $row2))
    408                 {
    409                     if(empty($text))
    410                     {
    411                         $text.=$row2[0];
    412                     }
    413                     else
    414                     {
    415                         $text.=' > '.$row2[0];
    416                     }
    417                 }
    418                
    419             }           
    420         }
    421 
    422         if(strpos($request_uri, 'post.php') !== FALSE)
    423         {
    424             if(empty($text))
    425             {
    426                 $text.='Post';
    427             }
    428             else
    429             {
    430                 $text.=' > Post';
    431             }
    432         }
    433 
    434         if(strpos($request_uri, 'plugins.php') !== FALSE)
    435         {
    436             if(empty($text))
    437             {
    438                 $text.='Plugins';
    439             }
    440             else
    441             {
    442                 $text.=' > Plugins';
    443             }
    444         }
    445        
    446         if(strpos($request_uri, 'post-new.php') !== FALSE)
    447         {
    448             if(empty($text))
    449             {
    450                 $text.='Post Created';
    451             }
    452             else
    453             {
    454                 $text.=' > Post Created';
    455             }
    456         }   
    457        
    458         if(strpos($request_uri, 'edit.php') !== FALSE && strpos($request_uri, 'trashed') !== FALSE)
    459         {
    460             if(empty($text))
    461             {
    462                 $text.='Post';
    463             }
    464             else
    465             {
    466                 $text.=' > Post';
    467             }
    468         }   
    469 
    470         if(strpos($request_uri, 'edit.php') !== FALSE && strpos($request_uri, 'deleted') !== FALSE)
    471         {
    472             if(empty($text))
    473             {
    474                 $text.='Post';
    475             }
    476             else
    477             {
    478                 $text.=' > Post';
    479             }
    480         }   
    481 
    482         if(strpos($request_uri, 'edit.php') !== FALSE && strpos($request_uri, 'post_status') !== FALSE)
    483         {
    484             if(empty($text))
    485             {
    486                 $text.='Edit Post';
    487             }
    488             else
    489             {
    490                 $text.=' > Edit Post';
    491             }
    492         }   
    493        
    494         if(!empty($text))return $text;
    495 
    496        
    497         if(strpos($request_uri, 'admin-ajax.php') !== FALSE)
    498         {
    499             return 'Ajax request';
    500         }
    501 
    502         if(strpos($request_uri, 'wp-cron.php') !== FALSE)
    503         {
    504             return 'WP Cron';
    505         }
    506 
    507         if(strpos($request_uri, 'wp_scrape_nonce') !== FALSE)
    508         {
    509             return 'WP Scraping';
    510         }
    511 
    512         if(strpos($request_uri, 'wp-json') !== FALSE)
    513         {
    514             return 'WP JSON';
    515         }
    516        
    517         if(strpos($request_uri, 'post.php?') !== FALSE)
    518         {
    519             return 'Edit post/page';
    520         }
    521        
    522         if(strpos($request_uri, 'wp-login.php') !== FALSE)
    523         {
    524             return 'wp-login.php';
    525         }
    526 
    527         if(strpos($request_uri, 'options.php') !== FALSE)
    528         {
    529             return 'WP Options';
    530         }
    531        
    532        
    533 
    534         return $request_uri;
    535     }
    536 }
    537 
    538 function wal_generate_description($row, $failed_login = false)
    539 {
    540     $desc = '';
    541 
    542     $desc .= wal_resolve_wp_menu($row['page'], $row['request_uri']);
    543 
    544     if(!empty($row['action']))
    545         $desc .= ' > '.$row['action'];
    546 
    547 
    548     //check for "function" query string
    549     $request_data = unserialize($row['request_data']);
    550 
    551     if(isset($request_data['GET']['function']))
    552     {
    553         $desc .= ' > '.$request_data['GET']['function'];
    554     }
    555    
    556     if(isset($request_data['GET']['trashed']))
    557     {
    558         $desc .= ' > Trashed';
    559     }
    560    
    561     if(isset($request_data['GET']['deleted']))
    562     {
    563         $desc .= ' > Deleted';
    564     }
    565 
    566     if(isset($request_data['POST']['post_ID']))
    567     {
    568         $post_link = get_edit_post_link($request_data['POST']['post_ID']);
    569 
    570         $post_title = '';
    571         if(isset($request_data['POST']['post_title']))
    572             $post_title = ' ('.$request_data['POST']['post_title'].')';
    573 
    574         $desc .= ' > '."Editing post with ID: <a target=\"_blank\" href=\"$post_link\">".$request_data['POST']['post_ID'].$post_title.'</a>';
    575     }
    576 
    577     $other_data = unserialize($row['other_data']);
    578     if(isset($other_data['post_revision_id']))
    579     {
    580         $revision_link = get_admin_url().'revision.php?revision='.$other_data['post_revision_id'];
    581 
    582         $desc .= ' > '.'Post revision: <a target="_blank" href="'.$revision_link.'">'.$other_data['post_revision_id'].'</a>';
    583     }
    584 
    585     if($row['action'] == 'edit-theme-plugin-file')
    586     {
    587         if(isset($request_data['POST']['file']))
    588         {
    589             $desc .= ' > '.'File: '.$request_data['POST']['file'];
    590         }
    591     }
    592 
    593     if(isset($request_data['GET']['plugin']))
    594     {
    595         $desc .= ' > Plugin: '.$request_data['GET']['plugin'];
    596     }
    597 
    598     if( (strpos($row['request_uri'], 'wp-login.php') !== FALSE || $row['action'] == 'wordfence_ls_authenticate') && isset($request_data['POST']['pwd']))
    599     {
    600 
    601         if($failed_login)
    602         {
    603             $desc = 'FAILED Login with data';
    604         }
    605         else
    606         {
    607             $desc = 'Login with data';
    608         }
    609 
    610         if(isset($request_data['POST']['log']))
    611             $desc .= ' > Username: '.$request_data['POST']['log'];
    612     }
    613    
    614     if(isset($request_data['GET']['post_type']))
    615     {
    616         $desc .= ' > Post Type: '.$request_data['GET']['post_type'];
    617     }
    618 
    619     if(isset($request_data['GET']['post_status']))
    620     {
    621         $desc .= ' > Post status: '.$request_data['GET']['post_status'];
    622     }
    623 
    624     if(isset($request_data['GET']['ids']))
    625     {
    626         $desc .= ' > Ids: '.$request_data['GET']['ids'];
    627     }
    628 
    629     if(isset($request_data['GET']['post']) && is_numeric($request_data['GET']['post']))
    630     {
    631         $desc .= ' > Post ID: '.$request_data['GET']['post'];
    632     }
    633 
    634     if(isset($request_data['GET']['loggedout']))
    635     {
    636         $desc .= ' > Logged Out: '.$request_data['GET']['loggedout'];
    637     }
    638 
    639 
    640     //$desc .= $row->request_uri;
    641    
    642 
    643     return $desc;
    644 }
    645 
    646 if ( ! function_exists('wal_visitor_type'))
    647 {
    648     function wal_visitor_type($page=NULL, $request_uri=NULL, $user_agent = NULL)
    649     {
    650         if(empty($page) && empty($request_uri))return NULL;
    651 
    652         if(strpos($request_uri, 'wp-cron.php') !== FALSE)
    653         {
    654             return 'system';
    655         }
    656 
    657         if(strpos($request_uri, 'wp_scrape_nonce') !== FALSE)
    658         {
    659             return 'system';
    660         }
    661 
    662         if($user_agent !== NULL)
    663         {
    664             $obj = new Winter_Activity_Log_BrowserDetector($user_agent);
    665 
    666             $info = $obj->detect()->getBrowser();
    667 
    668             if(!empty($info))
    669                 return 'guest';
    670         }
    671 
    672 
    673         return 'unknown';
    674     }
    675 }
    676 
    677 function wal_basic_user_info($user_id)
    678 {
    679     $user_info = get_userdata($user_id);
    680 
    681     $text = '';
    682 
    683     if(isset($user_info->user_login))
    684         $text = "#$user_info->ID <a target=\"_blank\" href=\"".admin_url('user-edit.php?user_id='.$user_info->ID)."\">$user_info->user_login</a> <br /> ".implode(', ', $user_info->roles) . " ";
    685    
    686     if(empty($text))
    687     {
    688         $text = 'IP: '.wal_get_the_user_ip();
    689     }
    690 
    691     return $text;
    692 }
    693 
    694 function wal_user_info($user_id, $header_data = array(), $page=NULL, $request_uri=NULL)
    695 {
    696     $user_info = get_userdata($user_id);
    697 
    698     $text = '';
    699 
    700     if(isset($user_info->user_login))
    701         $text = "#$user_info->ID <a target=\"_blank\" href=\"".admin_url('user-edit.php?user_id='.$user_info->ID)."\">$user_info->user_login</a> <br /> ".implode(', ', $user_info->roles) . " ";
    702 
    703     $user_agent = NULL;
    704     if(!empty($header_data["User-Agent"]))
    705     {
    706         $user_agent = $header_data["User-Agent"];
    707     }
    708    
    709 
    710     if(empty($text))
    711     {
    712         $text = '-';
    713     }
    714 
    715     if(isset($user_info->ID))
    716     {
    717 
    718     }
    719     elseif(wal_visitor_type($page, $request_uri, $user_agent ) === 'system')
    720     {
    721         $text = 'System';
    722     }
    723     elseif(wal_visitor_type($page, $request_uri, $user_agent ) === 'guest')
    724     {
    725         $text = 'Guest';
    726 
    727     }
    728     elseif(wal_visitor_type($page, $request_uri, $user_agent ) === 'unknown')
    729     {
    730         $text = 'Not logged in';
    731     }
    732 
    733     return $text;
    734 }
    735 
    736 function &wal_get_instance()
    737 {
    738     global $Winter_MVC;
    739 
    740     return $Winter_MVC;
    741 }
    742 
    743 if ( ! function_exists('wal_prepare_search_query_GET'))
    744 {
    745     function wal_prepare_search_query_GET($columns = array(), $model_name = NULL, $external_columns = array())
    746     {
    747         $CI = &wal_get_instance();
    748         $search_par = array_merge(wal_get_for_log(), wal_post_for_log());
    749         $search_par = wmvc_xss_clean($search_par);
    750        
     150if ( !function_exists( 'wal_resolve_level' ) ) {
     151    function wal_resolve_level(
     152        $request_uri = NULL,
     153        $post = NULL,
     154        $get = NULL,
     155        $request_method = NULL,
     156        $body = NULL,
     157        $fixed_level = NULL
     158    ) {
     159        if ( !empty( $fixed_level ) ) {
     160            return $fixed_level;
     161        }
     162        $level = 1;
     163        if ( $request_uri === NULL && $post === NULL && $get === NULL ) {
     164            $request_uri = wal_get_uri();
     165            $post = wal_post_for_log();
     166            $get = wal_get_for_log();
     167            $request_method = sanitize_text_field( $_SERVER['REQUEST_METHOD'] );
     168        }
     169        if ( $request_method == 'POST' && (count( $post ) > 0 || is_array( $body )) ) {
     170            $level = 2;
     171        }
     172        // standard wp ajax requests defined to level q
     173        if ( strpos( $request_uri, 'admin-ajax.php' ) === FALSE && strpos( $request_uri, 'wp-cron.php' ) === FALSE && strpos( $request_uri, 'wp_scrape_nonce' ) === FALSE && strpos( $request_uri, 'wp-json' ) === FALSE ) {
     174            if ( count( $post ) > 0 ) {
     175                $level = 3;
     176            }
     177        }
     178        // if ajax
     179        if ( strpos( $request_uri, 'admin-ajax.php' ) !== FALSE ) {
     180            // action post contain get-
     181            if ( substr( $post['action'], 0, 4 ) == 'get-' ) {
     182                $level = 1;
     183            }
     184        }
     185        if ( strpos( $request_uri, 'post-new.php' ) !== FALSE ) {
     186            $level = 4;
     187        }
     188        if ( strpos( $request_uri, 'edit.php' ) !== FALSE ) {
     189            $level = 4;
     190        }
     191        if ( isset( $body['edit_date'] ) || isset( $body['post_type'] ) || isset( $body['post_ID'] ) || isset( $body['post_status'] ) || isset( $body['content'] ) || isset( $post['post_type'] ) || isset( $post['post_ID'] ) || isset( $post['post_status'] ) || isset( $post['edit_date'] ) || isset( $post['content'] ) ) {
     192            $level = 4;
     193        }
     194        if ( isset( $post['action'] ) && $post['action'] == 'edit-theme-plugin-file' ) {
     195            $level = 4;
     196        }
     197        if ( isset( $get['action'] ) && $get['action'] == 'delete' ) {
     198            $level = 4;
     199        }
     200        if ( isset( $get['action'] ) && $get['action'] == 'trash' ) {
     201            $level = 4;
     202        }
     203        if ( isset( $get['action'] ) && $get['action'] == 'logout' ) {
     204            $level = 2;
     205        }
     206        if ( isset( $get['plugin'] ) || isset( $get['deleted'] ) || isset( $get['trashed'] ) ) {
     207            $level = 4;
     208        }
     209        return $level;
     210    }
     211
     212}
     213if ( !function_exists( 'wal_generate_label_by_level' ) ) {
     214    function wal_generate_label_by_level(  $level, $message = ''  ) {
     215        if ( empty( $message ) ) {
     216            $message = $level;
     217        }
     218        if ( $level == 1 ) {
     219            return '<span class="label label-default" title="' . __( 'Most basic activities log, like when someone open some page', 'winter-activity-log' ) . '">' . $message . '</span>';
     220        }
     221        if ( $level == 2 ) {
     222            return '<span class="label label-primary" title="' . __( 'Something is sent in POST via ajax, sometimes this mean change in database', 'winter-activity-log' ) . '">' . $message . '</span>';
     223        }
     224        if ( $level == 3 ) {
     225            return '<span class="label label-success" title="' . __( 'Something general is sent in POST to regular page, mostly this mean change in database', 'winter-activity-log' ) . '">' . $message . '</span>';
     226        }
     227        if ( $level == 4 ) {
     228            return '<span class="label label-info" title="' . __( 'Editing known contents like post, page or similar', 'winter-activity-log' ) . '">' . $message . '</span>';
     229        }
     230        if ( $level == 5 ) {
     231            return '<span class="label label-warning" title="' . __( 'Critical tasks like FAILED login', 'winter-activity-log' ) . '">' . $message . '</span>';
     232        }
     233        if ( $level == 6 ) {
     234            return '<span class="label label-danger" title="' . __( 'Very critical tasks like hacking', 'winter-activity-log' ) . '">' . $message . '</span>';
     235        }
     236        return $message;
     237    }
     238
     239}
     240if ( !function_exists( 'wal_resolve_wp_menu' ) ) {
     241    function wal_resolve_wp_menu(  $page = NULL, $request_uri = NULL  ) {
     242        global $submenu, $menu, $pagenow;
     243        $submenu_c = $submenu;
     244        $menu_c = $menu;
     245        $pagenow_c = $pagenow;
     246        if ( empty( $page ) && empty( $request_uri ) ) {
     247            return;
     248        }
     249        if ( !isset( $submenu_c ) ) {
     250            $menu_c = get_option( 'winter-activity-log-menuitems' );
     251            $submenu_c = get_option( 'winter-activity-log-submenuitems' );
     252        }
     253        $text = '';
     254        if ( is_array( $menu_c ) && !empty( $page ) ) {
     255            foreach ( $menu_c as $key => $row ) {
     256                if ( in_array( $page, $row ) ) {
     257                    $text .= $row[0];
     258                }
     259            }
     260        }
     261        if ( is_array( $submenu_c ) && !empty( $page ) ) {
     262            foreach ( $submenu_c as $key => $row ) {
     263                foreach ( $row as $key2 => $row2 ) {
     264                    if ( in_array( $page, $row2 ) ) {
     265                        if ( empty( $text ) ) {
     266                            $text .= $row2[0];
     267                        } else {
     268                            $text .= ' > ' . $row2[0];
     269                        }
     270                    }
     271                }
     272            }
     273        }
     274        if ( strpos( $request_uri, 'wp-admin' ) !== FALSE ) {
     275            $request_uri = basename( $request_uri );
     276        }
     277        if ( is_array( $menu_c ) && !empty( $request_uri ) ) {
     278            foreach ( $menu_c as $key => $row ) {
     279                if ( in_array( $request_uri, $row ) ) {
     280                    if ( empty( $text ) ) {
     281                        $text .= $row[0];
     282                    } else {
     283                        $text .= ' > ' . $row[0];
     284                    }
     285                }
     286            }
     287        }
     288        if ( is_array( $submenu_c ) && !empty( $request_uri ) ) {
     289            foreach ( $submenu_c as $key => $row ) {
     290                foreach ( $row as $key2 => $row2 ) {
     291                    if ( in_array( $request_uri, $row2 ) ) {
     292                        if ( empty( $text ) ) {
     293                            $text .= $row2[0];
     294                        } else {
     295                            $text .= ' > ' . $row2[0];
     296                        }
     297                    }
     298                }
     299            }
     300        }
     301        if ( strpos( $request_uri, 'post.php' ) !== FALSE ) {
     302            if ( empty( $text ) ) {
     303                $text .= 'Post';
     304            } else {
     305                $text .= ' > Post';
     306            }
     307        }
     308        if ( strpos( $request_uri, 'plugins.php' ) !== FALSE ) {
     309            if ( empty( $text ) ) {
     310                $text .= 'Plugins';
     311            } else {
     312                $text .= ' > Plugins';
     313            }
     314        }
     315        if ( strpos( $request_uri, 'post-new.php' ) !== FALSE ) {
     316            if ( empty( $text ) ) {
     317                $text .= 'Post Created';
     318            } else {
     319                $text .= ' > Post Created';
     320            }
     321        }
     322        if ( strpos( $request_uri, 'edit.php' ) !== FALSE && strpos( $request_uri, 'trashed' ) !== FALSE ) {
     323            if ( empty( $text ) ) {
     324                $text .= 'Post';
     325            } else {
     326                $text .= ' > Post';
     327            }
     328        }
     329        if ( strpos( $request_uri, 'edit.php' ) !== FALSE && strpos( $request_uri, 'deleted' ) !== FALSE ) {
     330            if ( empty( $text ) ) {
     331                $text .= 'Post';
     332            } else {
     333                $text .= ' > Post';
     334            }
     335        }
     336        if ( strpos( $request_uri, 'edit.php' ) !== FALSE && strpos( $request_uri, 'post_status' ) !== FALSE ) {
     337            if ( empty( $text ) ) {
     338                $text .= 'Edit Post';
     339            } else {
     340                $text .= ' > Edit Post';
     341            }
     342        }
     343        if ( !empty( $text ) ) {
     344            return $text;
     345        }
     346        if ( strpos( $request_uri, 'admin-ajax.php' ) !== FALSE ) {
     347            return 'Ajax request';
     348        }
     349        if ( strpos( $request_uri, 'wp-cron.php' ) !== FALSE ) {
     350            return 'WP Cron';
     351        }
     352        if ( strpos( $request_uri, 'wp_scrape_nonce' ) !== FALSE ) {
     353            return 'WP Scraping';
     354        }
     355        if ( strpos( $request_uri, 'wp-json' ) !== FALSE ) {
     356            return 'WP JSON';
     357        }
     358        if ( strpos( $request_uri, 'post.php?' ) !== FALSE ) {
     359            return 'Edit post/page';
     360        }
     361        if ( strpos( $request_uri, 'wp-login.php' ) !== FALSE ) {
     362            return 'wp-login.php';
     363        }
     364        if ( strpos( $request_uri, 'options.php' ) !== FALSE ) {
     365            return 'WP Options';
     366        }
     367        return $request_uri;
     368    }
     369
     370}
     371function wal_generate_description(  $row, $failed_login = false  ) {
     372    $desc = '';
     373    $desc .= wal_resolve_wp_menu( $row['page'], $row['request_uri'] );
     374    if ( !empty( $row['action'] ) ) {
     375        $desc .= ' > ' . $row['action'];
     376    }
     377    //check for "function" query string
     378    $request_data = unserialize( $row['request_data'] );
     379    if ( isset( $request_data['GET']['function'] ) ) {
     380        $desc .= ' > ' . $request_data['GET']['function'];
     381    }
     382    if ( isset( $request_data['GET']['trashed'] ) ) {
     383        $desc .= ' > Trashed';
     384    }
     385    if ( isset( $request_data['GET']['deleted'] ) ) {
     386        $desc .= ' > Deleted';
     387    }
     388    if ( isset( $request_data['POST']['post_ID'] ) ) {
     389        $post_link = get_edit_post_link( $request_data['POST']['post_ID'] );
     390        $post_title = '';
     391        if ( isset( $request_data['POST']['post_title'] ) ) {
     392            $post_title = ' (' . $request_data['POST']['post_title'] . ')';
     393        }
     394        $desc .= ' > ' . "Editing post with ID: <a target=\"_blank\" href=\"{$post_link}\">" . $request_data['POST']['post_ID'] . $post_title . '</a>';
     395    }
     396    $other_data = unserialize( $row['other_data'] );
     397    if ( isset( $other_data['post_revision_id'] ) ) {
     398        $revision_link = get_admin_url() . 'revision.php?revision=' . $other_data['post_revision_id'];
     399        $desc .= ' > ' . 'Post revision: <a target="_blank" href="' . $revision_link . '">' . $other_data['post_revision_id'] . '</a>';
     400    }
     401    if ( $row['action'] == 'edit-theme-plugin-file' ) {
     402        if ( isset( $request_data['POST']['file'] ) ) {
     403            $desc .= ' > ' . 'File: ' . $request_data['POST']['file'];
     404        }
     405    }
     406    if ( isset( $request_data['GET']['plugin'] ) ) {
     407        $desc .= ' > Plugin: ' . $request_data['GET']['plugin'];
     408    }
     409    if ( (strpos( $row['request_uri'], 'wp-login.php' ) !== FALSE || $row['action'] == 'wordfence_ls_authenticate') && isset( $request_data['POST']['pwd'] ) ) {
     410        if ( $failed_login ) {
     411            $desc = 'FAILED Login with data';
     412        } else {
     413            $desc = 'Login with data';
     414        }
     415        if ( isset( $request_data['POST']['log'] ) ) {
     416            $desc .= ' > Username: ' . $request_data['POST']['log'];
     417        }
     418    }
     419    if ( isset( $request_data['GET']['post_type'] ) ) {
     420        $desc .= ' > Post Type: ' . $request_data['GET']['post_type'];
     421    }
     422    if ( isset( $request_data['GET']['post_status'] ) ) {
     423        $desc .= ' > Post status: ' . $request_data['GET']['post_status'];
     424    }
     425    if ( isset( $request_data['GET']['ids'] ) ) {
     426        $desc .= ' > Ids: ' . $request_data['GET']['ids'];
     427    }
     428    if ( isset( $request_data['GET']['post'] ) && is_numeric( $request_data['GET']['post'] ) ) {
     429        $desc .= ' > Post ID: ' . $request_data['GET']['post'];
     430    }
     431    if ( isset( $request_data['GET']['loggedout'] ) ) {
     432        $desc .= ' > Logged Out: ' . $request_data['GET']['loggedout'];
     433    }
     434    //$desc .= $row->request_uri;
     435    return $desc;
     436}
     437
     438if ( !function_exists( 'wal_visitor_type' ) ) {
     439    function wal_visitor_type(  $page = NULL, $request_uri = NULL, $user_agent = NULL  ) {
     440        if ( empty( $page ) && empty( $request_uri ) ) {
     441            return NULL;
     442        }
     443        if ( strpos( $request_uri, 'wp-cron.php' ) !== FALSE ) {
     444            return 'system';
     445        }
     446        if ( strpos( $request_uri, 'wp_scrape_nonce' ) !== FALSE ) {
     447            return 'system';
     448        }
     449        if ( $user_agent !== NULL ) {
     450            $obj = new Winter_Activity_Log_BrowserDetector($user_agent);
     451            $info = $obj->detect()->getBrowser();
     452            if ( !empty( $info ) ) {
     453                return 'guest';
     454            }
     455        }
     456        return 'unknown';
     457    }
     458
     459}
     460function wal_basic_user_info(  $user_id  ) {
     461    $user_info = get_userdata( $user_id );
     462    $text = '';
     463    if ( isset( $user_info->user_login ) ) {
     464        $text = "#{$user_info->ID} <a target=\"_blank\" href=\"" . admin_url( 'user-edit.php?user_id=' . $user_info->ID ) . "\">{$user_info->user_login}</a> <br /> " . implode( ', ', $user_info->roles ) . " ";
     465    }
     466    if ( empty( $text ) ) {
     467        $text = 'IP: ' . wal_get_the_user_ip();
     468    }
     469    return $text;
     470}
     471
     472function wal_user_info(
     473    $user_id,
     474    $header_data = array(),
     475    $page = NULL,
     476    $request_uri = NULL
     477) {
     478    $user_info = get_userdata( $user_id );
     479    $text = '';
     480    if ( isset( $user_info->user_login ) ) {
     481        $text = "#{$user_info->ID} <a target=\"_blank\" href=\"" . admin_url( 'user-edit.php?user_id=' . $user_info->ID ) . "\">{$user_info->user_login}</a> <br /> " . implode( ', ', $user_info->roles ) . " ";
     482    }
     483    $user_agent = NULL;
     484    if ( !empty( $header_data["User-Agent"] ) ) {
     485        $user_agent = $header_data["User-Agent"];
     486    }
     487    if ( empty( $text ) ) {
     488        $text = '-';
     489    }
     490    if ( isset( $user_info->ID ) ) {
     491    } elseif ( wal_visitor_type( $page, $request_uri, $user_agent ) === 'system' ) {
     492        $text = 'System';
     493    } elseif ( wal_visitor_type( $page, $request_uri, $user_agent ) === 'guest' ) {
     494        $text = 'Guest';
     495    } elseif ( wal_visitor_type( $page, $request_uri, $user_agent ) === 'unknown' ) {
     496        $text = 'Not logged in';
     497    }
     498    return $text;
     499}
     500
     501function &wal_get_instance() {
     502    global $Winter_MVC;
     503    return $Winter_MVC;
     504}
     505
     506if ( !function_exists( 'wal_prepare_search_query_GET' ) ) {
     507    function wal_prepare_search_query_GET(  $columns = array(), $model_name = NULL, $external_columns = array()  ) {
     508        $CI =& wal_get_instance();
     509        $search_par = array_merge( wal_get_for_log(), wal_post_for_log() );
     510        $search_par = wmvc_xss_clean( $search_par );
    751511        $smart_search = '';
    752         if(isset($search_par['search']))
    753             $smart_search = sanitize_text_field($search_par['search']['value']);
    754            
    755         $available_fields = $CI->$model_name->get_available_fields();
    756        
    757         //$table_name = substr($model_name, 0, -2); 
    758        
     512        if ( isset( $search_par['search'] ) ) {
     513            $smart_search = sanitize_text_field( $search_par['search']['value'] );
     514        }
     515        $available_fields = $CI->{$model_name}->get_available_fields();
     516        //$table_name = substr($model_name, 0, -2);
    759517        $columns_original = array();
    760         foreach($columns as $key=>$val)
    761         {
     518        foreach ( $columns as $key => $val ) {
    762519            $columns_original[$val] = $val;
    763            
    764520            // if column contain also "table_name.*"
    765             $splited = explode('.', $val);
    766             if(wmvc_count($splited) == 2)
     521            $splited = explode( '.', $val );
     522            if ( wmvc_count( $splited ) == 2 ) {
    767523                $val = $splited[1];
    768            
    769             if(isset($available_fields[$val]))
    770             {
    771                
    772             }
    773             else
    774             {
    775                 if(!in_array($columns[$key], $external_columns))
    776                 {
     524            }
     525            if ( isset( $available_fields[$val] ) ) {
     526            } else {
     527                if ( !in_array( $columns[$key], $external_columns ) ) {
    777528                    unset($columns[$key]);
    778529                }
    779530            }
    780531        }
    781 
    782         if(wmvc_count($search_par) > 0)
    783         {
     532        if ( wmvc_count( $search_par ) > 0 ) {
    784533            unset($search_par['search']);
    785            
    786534            // For quick/smart search
    787             if(wmvc_count($columns) > 0 && !empty($smart_search))
    788             {
     535            if ( wmvc_count( $columns ) > 0 && !empty( $smart_search ) ) {
    789536                $gen_q = '';
    790                 foreach($columns as $key=>$value)
    791                 {
    792                     $value = sanitize_text_field($value);
    793 
    794                     if(substr_count($value, 'id') > 0 && is_numeric($smart_search))
    795                     {
    796                         $gen_q.="$value = $smart_search OR ";
     537                foreach ( $columns as $key => $value ) {
     538                    $value = sanitize_text_field( $value );
     539                    if ( substr_count( $value, 'id' ) > 0 && is_numeric( $smart_search ) ) {
     540                        $gen_q .= "{$value} = {$smart_search} OR ";
     541                    } else {
     542                        if ( substr_count( $value, 'date' ) > 0 ) {
     543                            //$gen_search = wmvc_generate_slug($smart_search, ' ');
     544                            $gen_q .= "{$value} LIKE '%{$smart_search}%' OR ";
     545                        } else {
     546                            $gen_q .= "{$value} LIKE '%{$smart_search}%' OR ";
     547                        }
    797548                    }
    798                     else if(substr_count($value, 'date') > 0)
    799                     {
    800                         //$gen_search = wmvc_generate_slug($smart_search, ' ');
    801 
    802                         $gen_q.="$value LIKE '%$smart_search%' OR ";
    803                     }
    804                     else
    805                     {
    806                         $gen_q.="$value LIKE '%$smart_search%' OR ";
    807                     }
    808                 }
    809                 $gen_q = substr($gen_q, 0, -4);
    810                
    811                 if(!empty($gen_q))
    812                     $CI->db->where("($gen_q)");
    813             }
    814            
     549                }
     550                $gen_q = substr( $gen_q, 0, -4 );
     551                if ( !empty( $gen_q ) ) {
     552                    $CI->db->where( "({$gen_q})" );
     553                }
     554            }
    815555            // For column search
    816             if(isset($search_par['columns']))
    817             {
     556            if ( isset( $search_par['columns'] ) ) {
    818557                $gen_q = '';
    819                
    820558                //var_dump($search_par['columns']);
    821                
    822                 foreach($search_par['columns'] as $key=>$row)
    823                 {
    824                    
    825                     if(!empty($row['search']['value']))
    826                     if(isset($row['data']) && !empty($row['data']) && in_array($row['data'], $columns))
    827                     {
    828                        
    829                         $col_name = sanitize_text_field($columns[$key]);
    830                         if(isset($row['data']))
    831                             $col_name = sanitize_text_field($row['data']);
    832                    
    833                         if(substr_count($row['data'], 'id') > 0 && is_numeric($row['search']['value']))
    834                         {
    835                             // ID is always numeric
    836                            
    837                             $gen_q.=$col_name." = ".sanitize_text_field($row['search']['value'])." AND ";
    838                         }
    839                         else if(substr_count($row['data'], 'date') > 0)
    840                         {
    841                             // DATE VALUES
    842                            
    843                             $gen_search = $row['search']['value'];
    844                            
    845                             $detect_date = strtotime($gen_search);
    846 
    847                             if(is_numeric($detect_date) && $detect_date > 1000)
    848                             {
    849                                 $gen_search = date('Y-m-d H:i:s', $detect_date);
    850                                 $gen_q.=$col_name." > '".$gen_search."' AND ";
    851                             }
    852                             else
    853                             {
    854                                 $gen_q.=$col_name." LIKE '%".$gen_search."%' AND ";
    855                             }
    856                         }
    857                         else if(substr_count($row['data'], 'is_') > 0)
    858                         {
    859                             // CHECKBOXES
    860                            
    861                             if($row['search']['value']=='on')
    862                             {
    863                                 $gen_search = 1;
    864                                 $gen_q.=$col_name." LIKE '%".$gen_search."%' AND ";
     559                foreach ( $search_par['columns'] as $key => $row ) {
     560                    if ( !empty( $row['search']['value'] ) ) {
     561                        if ( isset( $row['data'] ) && !empty( $row['data'] ) && in_array( $row['data'], $columns ) ) {
     562                            $col_name = sanitize_text_field( $columns[$key] );
     563                            if ( isset( $row['data'] ) ) {
     564                                $col_name = sanitize_text_field( $row['data'] );
    865565                            }
    866                             else if($row['search']['value']=='off')
    867                             {
    868                                 $gen_q.=$col_name." IS NULL AND ";
     566                            if ( substr_count( $row['data'], 'id' ) > 0 && is_numeric( $row['search']['value'] ) ) {
     567                                // ID is always numeric
     568                                $gen_q .= $col_name . " = " . sanitize_text_field( $row['search']['value'] ) . " AND ";
     569                            } else {
     570                                if ( substr_count( $row['data'], 'date' ) > 0 ) {
     571                                    // DATE VALUES
     572                                    $gen_search = $row['search']['value'];
     573                                    $detect_date = strtotime( $gen_search );
     574                                    if ( is_numeric( $detect_date ) && $detect_date > 1000 ) {
     575                                        $gen_search = date( 'Y-m-d H:i:s', $detect_date );
     576                                        $gen_q .= $col_name . " > '" . $gen_search . "' AND ";
     577                                    } else {
     578                                        $gen_q .= $col_name . " LIKE '%" . $gen_search . "%' AND ";
     579                                    }
     580                                } else {
     581                                    if ( substr_count( $row['data'], 'is_' ) > 0 ) {
     582                                        // CHECKBOXES
     583                                        if ( $row['search']['value'] == 'on' ) {
     584                                            $gen_search = 1;
     585                                            $gen_q .= $col_name . " LIKE '%" . $gen_search . "%' AND ";
     586                                        } else {
     587                                            if ( $row['search']['value'] == 'off' ) {
     588                                                $gen_q .= $col_name . " IS NULL AND ";
     589                                            }
     590                                        }
     591                                    } else {
     592                                        $gen_q .= $col_name . " LIKE '%" . sanitize_text_field( $row['search']['value'] ) . "%' AND ";
     593                                    }
     594                                }
    869595                            }
    870596                        }
    871                         else
    872                         {
    873                             $gen_q.=$col_name." LIKE '%".sanitize_text_field($row['search']['value'])."%' AND ";
    874                         }
    875597                    }
    876 
    877                 }
    878                
    879                 $gen_q = substr($gen_q, 0, -5);
    880                
    881                 if(!empty($gen_q))
    882                     $CI->db->where("($gen_q)");
    883             }
    884            
    885 
    886             // order
    887 
    888             /*
    889             ["order"]=>
    890             array(1) {
    891                 [0]=>
    892                 array(2) {
    893                 ["column"]=>
    894                 string(1) "0"
    895                 ["dir"]=>
    896                 string(4) "desc"
    897                 }
    898             }
    899             */
    900 
    901             if(isset($search_par['order']))
    902             {
    903                 foreach($search_par['order'] as $order_row)
    904                 {
    905                     $CI->db->order_by(sanitize_sql_orderby($columns[$order_row['column']].' '.$order_row['dir']));
    906                 }
    907             }
    908 
    909         }
    910     }
    911 }
    912 
    913 
     598                }
     599                $gen_q = substr( $gen_q, 0, -5 );
     600                if ( !empty( $gen_q ) ) {
     601                    $CI->db->where( "({$gen_q})" );
     602                }
     603            }
     604            // order
     605            /*
     606            ["order"]=>
     607            array(1) {
     608                [0]=>
     609                array(2) {
     610                ["column"]=>
     611                string(1) "0"
     612                ["dir"]=>
     613                string(4) "desc"
     614                }
     615            }
     616            */
     617            if ( isset( $search_par['order'] ) ) {
     618                foreach ( $search_par['order'] as $order_row ) {
     619                    $CI->db->order_by( sanitize_sql_orderby( $columns[$order_row['column']] . ' ' . $order_row['dir'] ) );
     620                }
     621            }
     622        }
     623    }
     624
     625}
    914626# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
    915627# see http://help.papertrailapp.com/ for additional PHP syslog options
    916 
    917 function wal_send_remote_syslog($PAPERTRAIL_HOSTNAME, $PAPERTRAIL_PORT, $message, $component = "web", $program = "next_big_thing")
    918 {
    919     if(!function_exists('socket_create'))return;
    920 
    921     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    922     foreach(explode("\n", $message) as $line) {
    923         $syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
    924         $ret = socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $PAPERTRAIL_HOSTNAME, $PAPERTRAIL_PORT);
    925 
    926         //if($ret === FALSE)
    927         //  echo "error: " . socket_strerror(socket_last_error($sock)) . "\n";
    928     }
    929     socket_close($sock);
    930 }
    931  
     628function wal_send_remote_syslog(
     629    $PAPERTRAIL_HOSTNAME,
     630    $PAPERTRAIL_PORT,
     631    $message,
     632    $component = "web",
     633    $program = "next_big_thing"
     634) {
     635    if ( !function_exists( 'socket_create' ) ) {
     636        return;
     637    }
     638    $sock = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
     639    foreach ( explode( "\n", $message ) as $line ) {
     640        $syslog_message = "<22>" . date( 'M d H:i:s ' ) . $program . ' ' . $component . ': ' . $line;
     641        $ret = socket_sendto(
     642            $sock,
     643            $syslog_message,
     644            strlen( $syslog_message ),
     645            0,
     646            $PAPERTRAIL_HOSTNAME,
     647            $PAPERTRAIL_PORT
     648        );
     649        //if($ret === FALSE)
     650        //  echo "error: " . socket_strerror(socket_last_error($sock)) . "\n";
     651    }
     652    socket_close( $sock );
     653}
     654
    932655# send_remote_syslog("Test");
    933656# send_remote_syslog("Any log message");
    934657# send_remote_syslog("Something just happened", "other-component");
    935658# send_remote_syslog("Something just happened", "a-background-job-name", "whatever-app-name");
    936 
    937 function wal_remotedb_log($row_cloud, $log_message, $insert_array)
    938 {
    939     global $wpdb;
    940 
    941 
    942     $servername = $row_cloud->host.':'.$row_cloud->port;
    943     $username = $row_cloud->database_username;
    944     $password = $row_cloud->database_password;
    945     $dbname = $row_cloud->database_name;
    946 
    947     // Create connection
    948     $conn = mysqli_connect($servername, $username, $password, $dbname);
    949 
    950     // Check connection
    951     if (!$conn) {
    952         //die("Connection failed: " . mysqli_connect_error());
    953 
    954         return;
    955     }
    956    
    957     // sql to create table
    958 
    959     $table_name = $row_cloud->database_tablename;
    960 
    961     $charset_collate = $wpdb->get_charset_collate();
    962 
    963     $sql = "CREATE TABLE IF NOT EXISTS $table_name (
    964         `idlog` int(11) NOT NULL AUTO_INCREMENT,
    965         `level` int(11) DEFAULT NULL,
    966         `date` datetime DEFAULT NULL,
    967         `user_id` int(11) DEFAULT NULL,
    968         `user_info`text COLLATE utf8_unicode_ci,
    969         `ip` varchar(160) COLLATE utf8_unicode_ci NULL,
    970         `page` varchar(160) COLLATE utf8_unicode_ci NULL,
    971         `request_uri` varchar(160) COLLATE utf8_unicode_ci NULL,
    972         `action` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
    973         `is_favourite` tinyint(1) DEFAULT NULL,
    974         `request_data` longtext COLLATE utf8_unicode_ci,
    975         `header_data` text COLLATE utf8_unicode_ci,
    976         `other_data`text COLLATE utf8_unicode_ci,
    977         `description`text COLLATE utf8_unicode_ci,
    978         PRIMARY KEY  (idlog)
    979     ) $charset_collate COMMENT='Winter Activity Log Plugin Data';";
    980        
    981     if ($conn->query($sql) === TRUE) {
    982         //echo "Table $table_name created successfully";
    983     } else {
    984         //echo "Error creating table: " . $conn->error;
    985     }
    986 
    987     $values = '';
    988 
    989     foreach($insert_array as $key=>$row)
    990     {
    991         $values.="'".str_replace("'", "\'", $row)."',";
    992     }
    993 
    994     $values = substr($values, 0, -1);
    995 
    996     $sql = "INSERT INTO $table_name (".join(', ', array_keys($insert_array)).")
    997             VALUES ($values)";
    998    
    999     if ($conn->query($sql) === TRUE) {
    1000       //echo "New record created successfully";
    1001     } else {
    1002       //echo "Error: " . $sql . "<br>" . $conn->error;
    1003     }
    1004 
    1005     //exit();
    1006 
    1007     $conn->close();
    1008 }
    1009 
    1010 function wal_access_allowed($cap)
    1011 {
    1012     $allowed_admins = get_option('wal_allowed_admins');
    1013 
    1014     if(wmvc_user_in_role('administrator') || wmvc_user_in_role('super-admin'))
    1015     {
    1016         if(is_array($allowed_admins) && count($allowed_admins) > 0)
    1017         {
    1018             if(!in_array(get_current_user_id(), $allowed_admins))
    1019                 return false;
    1020         }
    1021 
    1022         return true;
    1023     }
    1024 
    1025     $allowed_roles = get_option('wal_allowed_roles');
    1026 
    1027     if(is_array($allowed_roles) && count($allowed_roles) > 0)
    1028     {
    1029         foreach($allowed_roles as $key => $val)
    1030         {
    1031             if(wmvc_user_in_role($key))
    1032             {
    1033                 return true;
    1034             }
    1035         }
    1036     }
    1037 
    1038     return false;
    1039 }
    1040 
    1041 
    1042 function wal_send_sms($phone_number, $message)
    1043 {
    1044     if(!empty(get_option('wal_clickatell_one_api_key')))
    1045     {
    1046         wal_send_sms_one($phone_number, $message);
    1047     }
    1048     else if(!empty(get_option('wal_clickatell_http_api_key')))
    1049     {
    1050         wal_send_sms_http($phone_number, $message);
    1051     }
    1052     else if(!empty(get_option('wal_smsapicom_http_api_key')))
    1053     {
    1054         wal_sms_send_smsapicom($phone_number, $message);
    1055     }
    1056     else if(!empty(get_option('wal_smsto_api_key')))
    1057     {
    1058         wal_smsto($phone_number, $message);
    1059     }
    1060 }
    1061 
    1062 if ( winteractivitylog()->is__premium_only() ) {
    1063 
    1064 
    1065 /*
    1066 
    1067 curl -i \
    1068 -X POST \
    1069 -H "Content-Type: application/json" \
    1070 -H "Accept: application/json" \
    1071 -H "Authorization: XXX" \
    1072 -d '{"messages": [{ "channel": "whatsapp", "to": "1234567890", "content": "Test WhatsApp Message Text" }, { "channel": "sms", "to": "1234567890", "content": "Test SMS Message Text" }]}' \
    1073 -s https://platform.clickatell.com/v1/message
    1074 
    1075 */
    1076 
    1077 function wal_send_sms_one($phone_number, $message)
    1078 {
    1079     $message = substr($message, 0, 150);
    1080 
    1081     $channel = "sms";
    1082 
    1083     if(get_option('wal_checkbox_enable_whatsapp_clickatell', '0') == '1')
    1084     {
    1085         $channel = "whatsapp";
    1086     }
    1087 
    1088     $url = 'https://platform.clickatell.com/v1/message';
    1089     $data = array("messages" => array ( array("channel" => $channel, "to" => $phone_number, "content" => $message )));
    1090     $auth_code = get_option('wal_clickatell_one_api_key');
    1091 
    1092     $data_string = json_encode($data);
    1093    
    1094     $ch = curl_init($url);
    1095 
    1096     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    1097     curl_setopt($ch, CURLOPT_POST, TRUE);
    1098     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    1099     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    1100     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: '.$auth_code));
    1101     curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    1102    
    1103     $result = curl_exec($ch);
    1104     curl_close($ch);
    1105 }
    1106 
    1107 /*
    1108 
    1109 curl "https://platform.clickatell.com/messages/http/send?apiKey=XXX&to=XXX&content=XXX"
    1110 
    1111 
    1112 */
    1113 
    1114 function wal_send_sms_http($phone_number, $message)
    1115 {
    1116     $message = urlencode(substr($message, 0, 150));
    1117 
    1118     $auth_code = get_option('wal_clickatell_http_api_key');
    1119 
    1120     $url = 'https://platform.clickatell.com/messages/http/send?apiKey='.$auth_code.'&to='.$phone_number.'&content='.$message;
    1121 
    1122 
    1123     $ch = curl_init($url);
    1124     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    1125     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    1126     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    1127    
    1128     $result = curl_exec($ch);
    1129     curl_close($ch);
    1130 }
    1131 
    1132 function wal_sms_send_smsapicom($phone_number, $message, $from = 'Test')
    1133 {
    1134 
    1135     static $content;
    1136 
    1137     if(!empty(get_option('wal_smsapicom_sender_name')))
    1138     {
    1139         $from = get_option('wal_smsapicom_sender_name');
    1140     }
    1141 
    1142     $params = array(
    1143         'to'            => $phone_number,         //destination number 
    1144         'from'          => $from,                //sender name has to be active 
    1145         'message'       => $message,    //message content
    1146         'format'        => 'json',           
    1147     );
    1148    
    1149     $backup = false;
    1150 
    1151     $token = get_option('wal_smsapicom_http_api_key');
    1152 
    1153     if ($backup == true) {
    1154         $url = 'https://api2.smsapi.com/sms.do';
     659function wal_remotedb_log(  $row_cloud, $log_message, $insert_array  ) {
     660    global $wpdb;
     661    $servername = $row_cloud->host . ':' . $row_cloud->port;
     662    $username = $row_cloud->database_username;
     663    $password = $row_cloud->database_password;
     664    $dbname = $row_cloud->database_name;
     665    // Create connection
     666    $conn = mysqli_connect(
     667        $servername,
     668        $username,
     669        $password,
     670        $dbname
     671    );
     672    // Check connection
     673    if ( !$conn ) {
     674        //die("Connection failed: " . mysqli_connect_error());
     675        return;
     676    }
     677    // sql to create table
     678    $table_name = $row_cloud->database_tablename;
     679    $charset_collate = $wpdb->get_charset_collate();
     680    $sql = "CREATE TABLE IF NOT EXISTS {$table_name} (\r\n\t\t`idlog` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t`level` int(11) DEFAULT NULL,\r\n\t\t`date` datetime DEFAULT NULL,\r\n\t\t`user_id` int(11) DEFAULT NULL,\r\n\t\t`user_info`text COLLATE utf8_unicode_ci,\r\n\t\t`ip` varchar(160) COLLATE utf8_unicode_ci NULL,\r\n\t\t`page` varchar(160) COLLATE utf8_unicode_ci NULL,\r\n\t\t`request_uri` varchar(160) COLLATE utf8_unicode_ci NULL,\r\n\t\t`action` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,\r\n\t\t`is_favourite` tinyint(1) DEFAULT NULL,\r\n\t\t`request_data` longtext COLLATE utf8_unicode_ci,\r\n\t\t`header_data` text COLLATE utf8_unicode_ci,\r\n\t\t`other_data`text COLLATE utf8_unicode_ci,\r\n\t\t`description`text COLLATE utf8_unicode_ci,\r\n\t\tPRIMARY KEY  (idlog)\r\n\t) {$charset_collate} COMMENT='Winter Activity Log Plugin Data';";
     681    if ( $conn->query( $sql ) === TRUE ) {
     682        //echo "Table $table_name created successfully";
    1155683    } else {
    1156         $url = 'https://api.smsapi.com/sms.do';
    1157     }
    1158 
    1159     $c = curl_init();
    1160     curl_setopt($c, CURLOPT_URL, $url);
    1161     curl_setopt($c, CURLOPT_POST, true);
    1162     curl_setopt($c, CURLOPT_POSTFIELDS, $params);
    1163     curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    1164     curl_setopt($c, CURLOPT_HTTPHEADER, array(
    1165         "Authorization: Bearer $token"
    1166     ));
    1167 
    1168     $content = curl_exec($c);
    1169     $http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
    1170 
    1171     if ($http_status != 200 && $backup == false) {
    1172         $backup = true;
    1173         sms_send($params, $token, $backup);
    1174     }
    1175 
    1176     curl_close($c);
    1177    
    1178     //var_dump($content);
    1179     //exit();
    1180 
    1181     return $content;
    1182 }
    1183 
    1184 function wal_smsto($phone_number, $message, $senderID = 'WinterLock')
    1185 {
    1186     $curl = curl_init();
    1187 
    1188     $apikey = get_option('wal_smsto_api_key');
    1189 
    1190     if(!empty(get_option('wal_smsto_senderid')))
    1191     {
    1192         $senderID = get_option('wal_smsto_senderid');
    1193     }
    1194 
    1195     curl_setopt_array($curl, array(
    1196         CURLOPT_URL => "https://api.sms.to/sms/send",
    1197         CURLOPT_RETURNTRANSFER => true,
    1198         CURLOPT_ENCODING => "",
    1199         CURLOPT_MAXREDIRS => 10,
    1200         CURLOPT_TIMEOUT => 0,
    1201         CURLOPT_FOLLOWLOCATION => true,
    1202         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    1203         CURLOPT_CUSTOMREQUEST => "POST",
    1204         CURLOPT_POSTFIELDS =>"{\n    \"message\": \"$message\",\n    \"to\": \"$phone_number\",\n    \"sender_id\": \"$senderID\",\n    \"callback_url\": \"https://sms.to/callback/handler\"\n}",
    1205         CURLOPT_HTTPHEADER => array(
    1206                 "Content-Type: application/json",
    1207                 "Accept: application/json",
    1208                 "Authorization: Bearer $apikey"
    1209             ),
    1210     ));
    1211 
    1212     $response = curl_exec($curl);
    1213 
    1214     curl_close($curl);
    1215 }
    1216 
    1217 
    1218 }
    1219 
    1220 
    1221 
     684        //echo "Error creating table: " . $conn->error;
     685    }
     686    $values = '';
     687    foreach ( $insert_array as $key => $row ) {
     688        $values .= "'" . str_replace( "'", "\\'", $row ) . "',";
     689    }
     690    $values = substr( $values, 0, -1 );
     691    $sql = "INSERT INTO {$table_name} (" . join( ', ', array_keys( $insert_array ) ) . ")\r\n\t\t\tVALUES ({$values})";
     692    if ( $conn->query( $sql ) === TRUE ) {
     693        //echo "New record created successfully";
     694    } else {
     695        //echo "Error: " . $sql . "<br>" . $conn->error;
     696    }
     697    //exit();
     698    $conn->close();
     699}
     700
     701function wal_access_allowed(  $cap  ) {
     702    $allowed_admins = get_option( 'wal_allowed_admins' );
     703    if ( wmvc_user_in_role( 'administrator' ) || wmvc_user_in_role( 'super-admin' ) ) {
     704        if ( is_array( $allowed_admins ) && count( $allowed_admins ) > 0 ) {
     705            if ( !in_array( get_current_user_id(), $allowed_admins ) ) {
     706                return false;
     707            }
     708        }
     709        return true;
     710    }
     711    $allowed_roles = get_option( 'wal_allowed_roles' );
     712    if ( is_array( $allowed_roles ) && count( $allowed_roles ) > 0 ) {
     713        foreach ( $allowed_roles as $key => $val ) {
     714            if ( wmvc_user_in_role( $key ) ) {
     715                return true;
     716            }
     717        }
     718    }
     719    return false;
     720}
     721
     722function wal_send_sms(  $phone_number, $message  ) {
     723    if ( !empty( get_option( 'wal_clickatell_one_api_key' ) ) ) {
     724        wal_send_sms_one( $phone_number, $message );
     725    } else {
     726        if ( !empty( get_option( 'wal_clickatell_http_api_key' ) ) ) {
     727            wal_send_sms_http( $phone_number, $message );
     728        } else {
     729            if ( !empty( get_option( 'wal_smsapicom_http_api_key' ) ) ) {
     730                wal_sms_send_smsapicom( $phone_number, $message );
     731            } else {
     732                if ( !empty( get_option( 'wal_smsto_api_key' ) ) ) {
     733                    wal_smsto( $phone_number, $message );
     734                }
     735            }
     736        }
     737    }
     738}
    1222739
    1223740function wal_get_date() {
    1224     $date_format = get_option('date_format');
    1225     $time_format = get_option('time_format');
    1226     $date = date("{$date_format} {$time_format}", current_time('timestamp'));
    1227     return $date;
    1228 }
    1229 
    1230 function wal_wp_authenticate( $username, $password ) {
    1231     $username = sanitize_user( $username );
    1232     $password = trim( $password );
    1233 
    1234     // get user by login via the supplied username (form input)
    1235     $user = get_user_by('login', $username);
    1236    
    1237     if(!isset($user->user_pass))
    1238     {
    1239         $user = get_user_by('email', $username);
    1240 
    1241         if(!isset($user->user_pass))
    1242             return NULL;
    1243     }
    1244 
    1245     if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) )
    1246     {
    1247         return NULL;
    1248     }
    1249 
    1250     return $user;
    1251 }
    1252 
     741    $date_format = get_option( 'date_format' );
     742    $time_format = get_option( 'time_format' );
     743    $date = date( "{$date_format} {$time_format}", current_time( 'timestamp' ) );
     744    return $date;
     745}
     746
     747function wal_wp_authenticate(  $username, $password  ) {
     748    $username = sanitize_user( $username );
     749    $password = trim( $password );
     750    // get user by login via the supplied username (form input)
     751    $user = get_user_by( 'login', $username );
     752    if ( !isset( $user->user_pass ) ) {
     753        $user = get_user_by( 'email', $username );
     754        if ( !isset( $user->user_pass ) ) {
     755            return NULL;
     756        }
     757    }
     758    if ( !wp_check_password( $password, $user->user_pass, $user->ID ) ) {
     759        return NULL;
     760    }
     761    return $user;
     762}
  • winterlock/trunk/winterlock.php

    r3419393 r3441603  
    1010 *
    1111 * @link              https://activity-log.com/
    12  * @since             1.0.4
     12 * @since             1.0.
    1313 * @package           Winter_Activity_Log
    1414 *
     
    1717 * Plugin URI:        https://activity-log.com/
    1818 * Description:       Detailed WordPress Activity Log with user request tracking, instant logout, request restrictions, locking, blocking, alerts, and more.
    19  * Version:           1.2.7
     19 * Version:           1.2.8
    2020 * Author:            SWIT
    2121 * Author URI:        https://swit.hr/
     
    2525 * Domain Path:       /languages
    2626 *
    27  * @fs_premium_only /premium_functions.php
    2827 *
    2928 */
    3029// If this file is called directly, abort.
    31 if (!defined('WPINC')) {
     30if ( !defined( 'WPINC' ) ) {
    3231    die;
    3332}
    34 
    35 $time_before = microtime(true);
    36 
    37 if (!function_exists('activate_winter_activity_log')) {
     33$time_before = microtime( true );
     34if ( !function_exists( 'activate_winter_activity_log' ) ) {
    3835    /**
    3936     * Currently plugin version.
     
    4138     * Rename this for your plugin and update it as you release new versions.
    4239     */
    43     define('WINTER_ACTIVITY_LOG_VERSION', '1.2.6');
    44     define('WINTER_ACTIVITY_LOG_NAME', 'winter-activity-log');
    45     define('WINTER_ACTIVITY_LOG_PATH', plugin_dir_path(__FILE__));
    46     define('WINTER_ACTIVITY_LOG_URL', plugin_dir_url(__FILE__));
     40    define( 'WINTER_ACTIVITY_LOG_VERSION', '1.2.8' );
     41    define( 'WINTER_ACTIVITY_LOG_NAME', 'winter-activity-log' );
     42    define( 'WINTER_ACTIVITY_LOG_PATH', plugin_dir_path( __FILE__ ) );
     43    define( 'WINTER_ACTIVITY_LOG_URL', plugin_dir_url( __FILE__ ) );
    4744    /**
    4845     * The code that runs during plugin activation.
    4946     * This action is documented in includes/class-winter-activity-log-activator.php
    5047     */
    51     function activate_winter_activity_log()
    52     {
    53         require_once plugin_dir_path(__FILE__) . 'includes/class-winter-activity-log-activator.php';
     48    function activate_winter_activity_log() {
     49        require_once plugin_dir_path( __FILE__ ) . 'includes/class-winter-activity-log-activator.php';
    5450        Winter_Activity_Log_Activator::activate();
    5551    }
     
    5955     * This action is documented in includes/class-winter-activity-log-deactivator.php
    6056     */
    61     function deactivate_winter_activity_log()
    62     {
    63         require_once plugin_dir_path(__FILE__) . 'includes/class-winter-activity-log-deactivator.php';
     57    function deactivate_winter_activity_log() {
     58        require_once plugin_dir_path( __FILE__ ) . 'includes/class-winter-activity-log-deactivator.php';
    6459        Winter_Activity_Log_Deactivator::deactivate();
    6560    }
    6661
    67     register_activation_hook(__FILE__, 'activate_winter_activity_log');
    68     register_deactivation_hook(__FILE__, 'deactivate_winter_activity_log');
     62    register_activation_hook( __FILE__, 'activate_winter_activity_log' );
     63    register_deactivation_hook( __FILE__, 'deactivate_winter_activity_log' );
    6964    /**
    7065     * The core plugin class that is used to define internationalization,
    7166     * admin-specific hooks, and public-facing site hooks.
    7267     */
    73     require plugin_dir_path(__FILE__) . 'includes/class-winter-activity-log.php';
     68    require plugin_dir_path( __FILE__ ) . 'includes/class-winter-activity-log.php';
    7469    /**
    7570     * Begins execution of the plugin.
     
    8176     * @since    1.0.0
    8277     */
    83     function run_winter_activity_log()
    84     {
     78    function run_winter_activity_log() {
    8579        $plugin = new Winter_Activity_Log();
    8680        $plugin->run();
     
    8882
    8983    // [Freemius]
    90 
    91     if (function_exists('winteractivitylog')) {
    92         winteractivitylog()->set_basename(false, __FILE__);
     84    if ( function_exists( 'winteractivitylog' ) ) {
     85        winteractivitylog()->set_basename( false, __FILE__ );
    9386    } else {
    94 
    95         if (!function_exists('winteractivitylog')) {
     87        if ( !function_exists( 'winteractivitylog' ) ) {
    9688            // Create a helper function for easy SDK access.
    97             function winteractivitylog()
    98             {
    99                 global  $winteractivitylog;
    100 
    101                 if (!isset($winteractivitylog)) {
     89            function winteractivitylog() {
     90                global $winteractivitylog;
     91                if ( !isset( $winteractivitylog ) ) {
    10292                    // Include Freemius SDK.
    103                     require_once dirname(__FILE__) . '/freemius/start.php';
    104                     $winteractivitylog = fs_dynamic_init(array(
     93                    require_once dirname( __FILE__ ) . '/freemius/start.php';
     94                    $winteractivitylog = fs_dynamic_init( array(
    10595                        'id'             => '5253',
    10696                        'slug'           => 'winterlock',
    10797                        'type'           => 'plugin',
    10898                        'public_key'     => 'pk_453c5698d371cb2dcc7a41e27cfb8',
    109                         'is_premium'     => true,
     99                        'is_premium'     => false,
    110100                        'has_addons'     => false,
    111101                        'has_paid_plans' => true,
     
    115105                        ),
    116106                        'menu'           => array(
    117                             'slug'    => 'winteractivitylog',
    118                             //'support' => false,
     107                            'slug' => 'winteractivitylog',
    119108                        ),
    120                         'anonymous_mode' => !file_exists(WINTER_ACTIVITY_LOG_PATH . 'premium_functions.php'),
    121                         //'is_live'        => true,
    122                     ));
     109                        'anonymous_mode' => !file_exists( WINTER_ACTIVITY_LOG_PATH . 'premium_functions.php' ),
     110                        'is_live'        => true,
     111                    ) );
    123112                }
    124 
    125113                return $winteractivitylog;
    126114            }
     
    129117            winteractivitylog();
    130118            // Signal that SDK was initiated.
    131             do_action('winteractivitylog_loaded');
     119            do_action( 'winteractivitylog_loaded' );
    132120        }
    133 
    134121        // ... Your plugin's main file logic ...
    135122        run_winter_activity_log();
    136123    }
    137 
    138124    function winteractivitylog_custom_connect_message_on_update(
    139125        $message,
     
    145131    ) {
    146132        return sprintf(
    147             __('Hey %1$s') . ',<br>' . __('Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'winterlock'),
     133            __( 'Hey %1$s' ) . ',<br>' . __( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'winterlock' ),
    148134            $user_first_name,
    149135            '<b>' . $plugin_title . '</b>',
     
    162148    // [/Freemius]
    163149}
    164 
    165 $time_executing = microtime(true) - $time_before;
    166 
     150$time_executing = microtime( true ) - $time_before;
    167151//echo '<!-- TimeWinterLock: '.esc_html($time_executing).' -->';
Note: See TracChangeset for help on using the changeset viewer.