Plugin Directory

Changeset 3296861


Ignore:
Timestamp:
05/19/2025 10:13:35 PM (10 months ago)
Author:
ashanjay
Message:

2.4.5 (2025-5-19)

FIXED: event card settings not saving
FIXED: Broken access control validations for admin functions

Location:
eventon-lite
Files:
299 added
14 edited

Legend:

Unmodified
Added
Removed
  • eventon-lite/trunk/assets/css/admin/wp_admin.css

    r3288092 r3296861  
    260260        -o-transition: all .2s ease;
    261261        transition: all .2s ease;
    262     }
    263     .evo_loader{
    264         background: url(../../images/evo-loader.gif) center center no-repeat;
    265         min-height: 100px; min-width: 100px;
    266         opacity: 0.4
    267262    }
    268263
  • eventon-lite/trunk/assets/js/admin/wp_admin.js

    r3288092 r3296861  
    117117        var D = {
    118118            'action': 'eventon_get_latlng',
    119             'address': add
     119            'address': add,
     120            'nn': evo_admin_ajax_handle.postnonce,
    120121        };
    121122        $.ajax({
  • eventon-lite/trunk/assets/lib/settings/settings.css

    r3269686 r3296861  
    11/**
    22 * AJDE backender styles
    3  * @version 2.4
     3 * @version 2.4.5
    44 */
    55
     
    9494        font-size:11px;
    9595        font-family:georgia
     96    }
     97    .toplevel_page_eventon .notice.notice-warning{
     98        position: absolute;
     99    z-index: 9;
     100    margin-left: 300px;
     101    margin-top: 10px;
    96102    }
    97103
  • eventon-lite/trunk/eventon.php

    r3290104 r3296861  
    44 * Plugin URI: http://www.myeventon.com/lite
    55 * Description: A beautifully crafted minimal calendar experience - Lite Version
    6  * Version: 2.4.4
     6 * Version: 2.4.5
    77 * Author: Ashan Jay
    88 * Author URI: http://www.ashanjay.com
  • eventon-lite/trunk/includes/admin/class-admin-ajax.php

    r3290104 r3296861  
    22/**
    33 * Function ajax for backend
    4  * @version   2.4.3
     4 * @version   2.4.5
    55 */
    66class EVO_admin_ajax{
    7     public $helper;
    87    public $post_data;
    98   
     
    2322
    2423            'admin_get_environment'     =>'admin_get_environment',
    25             'admin_system_log'      =>'admin_system_log',
     24            'admin_system_log'          =>'admin_system_log',
    2625            'admin_system_log_flush'        =>'admin_system_log_flush',
    2726
     
    4241            $prepend = 'eventon_';
    4342            add_action( 'wp_ajax_'. $prepend . $ajax_event, array( $this, $class ) );
    44             add_action( 'wp_ajax_nopriv_'. $prepend . $ajax_event, array( $this, $class ) );
     43            add_action( 'wp_ajax_nopriv_' . $prepend . $ajax_event, array( $this, 'restrict_unauthenticated' ) );
    4544        }
    4645
    4746        add_action('wp_ajax_eventon-feature-event', array($this, 'eventon_feature_event'));
    48 
    49         $this->helper = EVO()->helper;
    50         $this->post_data = $this->helper->sanitize_array( $_POST );
     47        add_action('wp_ajax_nopriv_eventon-feature-event', array($this, 'restrict_unauthenticated'));
     48
     49        $this->post_data = EVO()->helper->sanitize_array( $_POST );
    5150    }   
    5251
     52    // Handle unauthenticated requests
     53    public function restrict_unauthenticated() {
     54        wp_send_json( array( 'status' => 'bad', 'msg' => __( 'Authentication required', 'eventon' )) );
     55        wp_die();
     56    }
     57
    5358    // shortcode generator
    54         function get_shortcode_generator(){
     59        public function get_shortcode_generator(){
     60            // Allow all roles, with nonce check, authorization check, read capability
     61            EVO()->helper->validate_request( 'nn', 'eventon_admin_nonce', 'read', false, true );
     62
    5563            $sc = isset($this->post_data['sc']) ? stripslashes( $this->post_data['sc'] ): 'add_eventon';
    5664
    5765            $content = EVO()->shortcode_gen->get_content();
    5866
    59             echo json_encode(array(
     67            wp_send_json(array(
    6068                'status'=>'good',
    6169                'content'=> $content,
    62                 'sc'=> $sc,
    63                 'type'=> isset($this->post_data['type']) ? $this->post_data['type']:'',
    64                 'other_id'=> isset($this->post_data['other_id']) ? $this->post_data['other_id']:'',
    65             ));exit;   
     70                'sc' => sanitize_text_field( $sc ),
     71                'type' => isset( $this->post_data['type'] ) ? sanitize_text_field( $this->post_data['type'] ) : '',
     72                'other_id' => isset( $this->post_data['other_id'] ) ? sanitize_text_field( $this->post_data['other_id'] ) : '',
     73            ));wp_die();   
    6674        }
    6775
    6876    // generate custom repeat instance unix
    6977        public function generate_custom_repeat_unix(){
     78            // Allow all roles, with nonce check, authorization check
     79            EVO()->helper->validate_request( 'nn', 'eventon_admin_nonce', false, false, true );
    7080
    7181            $msg = '';
    72 
    73             // verify nonce
    74             if(empty( $_REQUEST['nn'] ) || !wp_verify_nonce( wp_unslash( $_REQUEST['nn'] ), 'eventon_admin_nonce')) {
    75                 $output['msg'] = __('Security Check Failed!','eventon');
    76                 wp_send_json($output); wp_die();
    77             }
    78 
    7982            $PD = $this->post_data;
    80 
    81             EVO_Debug($PD);
    82 
     83            //EVO_Debug($PD);
    8384
    8485            // required data check
    8586            if( empty($PD['event_new_repeat_start_date_x']) || empty( $PD['event_new_repeat_end_date_x'])){
    86                 $output['msg'] = __('Missing required data!','eventon');
    87                 wp_send_json($output); wp_die();
     87                wp_send_json(['msg'=> __('Missing required data!','eventon')]); wp_die();
    8888            }
    8989
     
    137137        public function get_secondary_settings(){
    138138
    139             // validate if user has permission
    140             if( !current_user_can('edit_eventons') ){
    141                 wp_send_json(array(
    142                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    143                 )); wp_die();
    144             }
    145 
    146             // nonce validation
    147             if( empty($_POST['nn']) || !wp_verify_nonce( $_POST['nn'], 'eventon_admin_nonce' ) ){
    148                 wp_send_json(array(
    149                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    150                 )); wp_die();
    151             }
    152 
    153             $post_data = $this->helper->sanitize_array( $_POST);
     139            // Validate request
     140            EVO()->helper->validate_request();
     141           
     142            $post_data = EVO()->helper->sanitize_array( $_POST);
    154143            $settings_file_key = isset($post_data['setitngs_file_key']) ? $post_data['setitngs_file_key'] : '';
    155144            $allowed_files = array(
    156145                'cmf_settings' => plugin_dir_path(__FILE__) . 'views/cmf_settings.php',
    157             );
    158            
     146            );         
    159147
    160148            if (array_key_exists($settings_file_key, $allowed_files) && file_exists($allowed_files[$settings_file_key])) {
     
    176164        }
    177165        public function save_secondary_settings(){
    178             // validate if user has permission
    179             if( !current_user_can('edit_eventons') ){
    180                 wp_send_json(array(
    181                     'status'=>'bad','msg'=> __('You do not have proper permission to perform this action','eventon')
    182                 )); wp_die();
    183             }
    184 
    185             // nonce validation
    186             if( empty($_POST['evo_noncename']) || !wp_verify_nonce( $_POST['evo_noncename'], 'evo_save_secondary_settings' ) ){
    187                 wp_send_json(array(
    188                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    189                 )); wp_die();
    190             }
    191 
    192             $post_data = $this->helper->sanitize_array( $_POST);
     166
     167            // Validate request
     168            EVO()->helper->validate_request('evo_noncename','evo_save_secondary_settings');
     169           
     170
     171            $post_data = EVO()->helper->sanitize_array( $_POST);
    193172
    194173            // if html fields passed
     
    210189                // html content
    211190                if( $html_fields &&  in_array($key, $html_fields )){
    212                     $val = $this->helper->sanitize_html( $_POST[ $key ] );
     191                    $val = EVO()->helper->sanitize_html( $_POST[ $key ] );
    213192                }
    214193
     
    224203        public function config_virtual_event(){
    225204
    226             // validate if user has permission
    227             if( !current_user_can('edit_eventons') ){
    228                 wp_send_json(array(
    229                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    230                 ));
    231                 wp_die();
    232             }
    233 
    234             $post_data = $this->helper->sanitize_array( $_POST);
     205            // Validate request
     206            EVO()->helper->validate_request();
     207           
     208
     209            $post_data = EVO()->helper->sanitize_array( $_POST);
    235210
    236211            $EVENT = new EVO_Event( (int) $post_data['eid'] );
     
    246221        }
    247222        public function select_virtual_moderator(){
     223
     224            // Validate request
     225            EVO()->helper->validate_request();
    248226           
    249227            ob_start();
    250228
    251229            $eid = (int) $_POST['eid'];
    252 
    253             $EVENT = new EVO_Event( $eid);
    254            
     230            $EVENT = new EVO_Event( $eid);         
    255231            $set_user_role = $EVENT->get_prop('_evo_user_role');
    256232            $set_mod = $EVENT->get_prop('_mod');
     
    302278        public function get_virtual_users_select_options($role_slug, $set_user_id=''){
    303279           
     280            // Validate request
     281            EVO()->helper->validate_request();
     282
    304283            $users = get_users( array(
    305284                'role' => $role_slug,
     
    318297        public function get_virtual_users(){
    319298
    320             // validate if user has permission
    321             if( !current_user_can('edit_eventons') ){
    322                 wp_send_json(array(
    323                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    324                 )); wp_die();
    325             }
     299            // Validate request
     300            EVO()->helper->validate_request();
    326301
    327302            $user_role = sanitize_text_field( $_POST['_user_role']);
     
    337312        }
    338313        public function save_virtual_event_settings(){
    339             // validate if user has permission
    340             if( !current_user_can('edit_eventons') ){
    341                 wp_send_json(array(
    342                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    343                 )); wp_die();
    344             }
    345            
    346             // nonce validation
    347             if( empty( $_POST['evo_noncename'] ) || !wp_verify_nonce( wp_unslash( $_POST['evo_noncename'] ), 'evo_save_virtual_event_settings' ) ){
    348                 wp_send_json(array(
    349                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    350                 )); wp_die();
    351             }
    352 
    353             $post_data = $this->helper->sanitize_array( $_POST);
     314
     315            // Validate request
     316            EVO()->helper->validate_request('evo_noncename','evo_save_virtual_event_settings');
     317           
     318            $post_data = EVO()->helper->sanitize_array( $_POST);
    354319
    355320            $EVENT = new EVO_Event( $post_data['event_id']);
    356321
    357322            foreach($post_data as $key=>$val){
    358 
    359323                if( in_array($key, array( '_vir_url','_vir_after_content','_vir_pre_content','_vir_embed'))){
    360324                    $val = $post_data[$key];
     
    369333        }
    370334        public function save_virtual_mod_settings(){
    371             // validate if user has permission
    372             if( !current_user_can('edit_eventons') ){
    373                 wp_send_json(array(
    374                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    375                 )); wp_die();
    376             }           
    377 
    378             // nonce validation
    379             if( empty($_POST['evo_noncename']) || !wp_verify_nonce( wp_unslash ( $_POST['evo_noncename'] ), 'evo_save_virtual_mod_settings' ) ){
    380                 wp_send_json(array(
    381                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    382                 )); wp_die();
    383             }       
    384 
    385             $post_data = $this->helper->sanitize_array( $_POST);   
     335
     336            // Validate request
     337            EVO()->helper->validate_request('evo_noncename','evo_save_virtual_mod_settings');
     338           
     339
     340            $post_data = EVO()->helper->sanitize_array( $_POST);   
    386341
    387342            $EVENT = new EVO_Event( (int)$post_data['eid']);
     
    397352       
    398353    // Related Events @2.3
    399         function rel_event_list(){
    400 
    401             // Check User Caps.
    402             if ( ! current_user_can( 'edit_eventons' ) ) {
    403                 wp_send_json_error( 'missing_capabilities' ); wp_die();
    404             }
    405 
    406             // verify nonce
    407             if(empty( $_REQUEST['nn'] ) || !wp_verify_nonce( wp_unslash( $_REQUEST['nn'] ), 'eventon_admin_nonce')) {
    408                 wp_send_json_error('Security Check Failed!','eventon');
    409                  wp_die();
    410             }
    411 
    412             $post_data = $this->helper->sanitize_array( $_POST);
    413 
    414 
     354        public function rel_event_list(){
     355
     356            // Validate request
     357            EVO()->helper->validate_request();     
     358
     359            $post_data = EVO()->helper->sanitize_array( $_POST);
    415360            $event_id = (int)$post_data['eventid'];
    416361            $EVs = json_decode( stripslashes($post_data['EVs']), true );
     
    508453    // Get Location Cordinates
    509454        public function get_latlng(){
     455
     456            // Validate request
     457            EVO()->helper->validate_request('nn','eventon_admin_nonce', 'read', false ,true);       
     458
    510459            $gmap_api = EVO()->cal->get_prop('evo_gmap_api_key', 'evcal_1');
    511460
     
    545494
    546495    // export eventon settings
    547         function export_settings(){
    548             // validate if user has permission
    549             if( !current_user_can('edit_eventons') ){
    550                 wp_die( __('User not loggedin','eventon'));
    551             }
    552 
    553             // verify nonce
    554             if(empty( $_REQUEST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_REQUEST['nonce'] ), 'evo_export_settings')) {
    555                 wp_die( __('Security Check Failed','eventon'));
    556             }
     496        public function export_settings(){
     497
     498            // Validate request
     499            EVO()->helper->validate_request('nonce','evo_export_settings', 'edit_eventons', true ,true);       
     500       
    557501
    558502            header('Content-type: text/plain');
     
    572516    // import settings
    573517        public function get_import_settings(){
     518            // Validate request
     519            EVO()->helper->validate_request('nn','eventon_admin_nonce', 'edit_eventons', true ,true);       
     520
    574521            $output = array('status'=>'bad','msg'=>'');
    575 
    576             // verify nonce
    577             if(empty( $_REQUEST['nn'] ) || !wp_verify_nonce( wp_unslash( $_REQUEST['nn'] ), 'eventon_admin_nonce')) {
    578                 $output['msg'] = __('Security Check Failed!','eventon');
    579                 wp_send_json($output); wp_die();
    580             }
    581 
    582             // check if admin and loggedin
    583             if(!is_admin() && !is_user_logged_in()){
    584                 $output['msg'] = __('User not loggedin!','eventon');
    585                 wp_send_json($output); wp_die();
    586             }
    587 
    588             // validate if user has permission
    589             if( !current_user_can('edit_eventons') ){
    590                 $output['msg'] = __('Required permission missing!','eventon');
    591                 wp_send_json($output); wp_die();
    592             }
    593 
     522           
    594523            ob_start();
    595524
     
    609538
    610539        }
    611         function import_settings(){
    612             $output = array('status'=>'bad','msg'=>'');
    613            
    614             // verify nonce
    615                 if(empty( $_POST['nonce'] ) || !wp_verify_nonce($_POST['nonce'], 'eventon_admin_nonce')){
    616                     $output['msg'] = __('Security Check Failed!','eventon');
    617                     wp_send_json($output);
    618                     wp_die();
    619                 }
    620 
    621             // check if admin and loggedin
    622                 if(!is_admin() && !is_user_logged_in()){
    623                     $output['msg'] = __('User not loggedin!','eventon');
    624                     wp_send_json($output); wp_die();
    625                 }
    626 
    627             // admin permission
    628                 if( !current_user_can('edit_eventons')){
    629                     $output['msg'] = __('Required permission missing','eventon');
    630 
    631                     wp_send_json($output); wp_die();
    632                 }
    633 
    634             $post_data = $this->helper->sanitize_array( $_POST);
     540        public function import_settings(){
     541            // Validate request
     542            EVO()->helper->validate_request('nonce','eventon_admin_nonce', 'edit_eventons', true ,true);       
     543
     544            $output = array('status'=>'bad','msg'=>'');         
     545            $post_data = EVO()->helper->sanitize_array( $_POST);
    635546            $JSON_data = isset( $post_data['jsondata'] ) ? $post_data['jsondata'] : false;
    636547
     
    652563           
    653564            wp_send_json($output); wp_die();
    654 
    655565        }
    656566
    657567    // export events as CSV
    658     // @update 4.3
    659         function export_events(){
    660 
    661             // check if admin and loggedin
    662                 if( !current_user_can('edit_eventons') ){
    663                     wp_die( __('User not loggedin','eventon'));
    664                 }
    665 
    666             // verify nonce
    667                 if( empty( $_REQUEST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_REQUEST['nonce'] ), 'eventon_download_events')) {
    668                     wp_die('Security Check Failed!');
    669                 }
     568        public function export_events(){
     569
     570            // Validate request
     571            EVO()->helper->validate_request('nonce','eventon_download_events', 'edit_eventons', true ,true,'message');     
     572
    670573
    671574            $run_process_content = false;
     
    1024927       
    1025928        // loadin new language
    1026         public function settings_load_new_lang(){
    1027 
    1028         }
     929        public function settings_load_new_lang(){}
    1029930
    1030931        // save language settings
    1031932        public function settings_save(){
    1032933
    1033             // Check nonce and referer
    1034             if (!check_admin_referer('eventon_settings_save_nonce', 'evoajax')) {
    1035                 EVO_Debug('Invalid nonce or referer in settings_save: ' . print_r($_POST, true));
    1036                 wp_send_json_error(array('message' => 'Invalid nonce or referer'));
    1037                 wp_die();
    1038             }
    1039 
    1040             // check if admin and loggedin
    1041             if( !current_user_can('edit_eventons') ){
    1042                 wp_send_json_error(array('message' => 'You do not have proper permission')); wp_die();
    1043             }
     934            // Validate request
     935            EVO()->helper->validate_request('evoajax','eventon_settings_save_nonce', 'edit_eventons', true ,true);     
     936
    1044937
    1045938            // Decode JSON data and validate it
    1046939            $form_data = json_decode(stripslashes($_POST['formData']), true);           
    1047940            if (json_last_error() !== JSON_ERROR_NONE) {
    1048                 wp_send_json_error(array('message' => 'Invalid JSON data'));
    1049                 wp_die();
     941                wp_send_json_error(array('message' => 'Invalid JSON data'));wp_die();
    1050942            }
    1051943
     
    11511043
    11521044                    // check isolatedly saved setting values and include them
    1153                         foreach( array('evo_ecl','evowhs') as $_iso_field){
     1045                        foreach( array('evowhs') as $_iso_field){
    11541046                            if( array_key_exists( $_iso_field, $saved_settings)){
    11551047
     
    12051097           
    12061098           
    1207 
    12081099            $return_content = array(
    12091100                //'debug'=> $form_data,
     
    12171108
    12181109    // Feature an event from admin */
    1219         function eventon_feature_event() {
    1220 
    1221             if ( ! is_admin() ) wp_die( __( 'Only available in admin side.', 'eventon' ) );
    1222 
    1223             if ( ! current_user_can('edit_eventons') ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'eventon' ) );
    1224 
    1225             if ( ! check_admin_referer('eventon-feature-event')) wp_die( __( 'You have taken too long. Please go back and retry.', 'eventon' ) );
     1110        public function eventon_feature_event() {
     1111
     1112            // Validate request
     1113            EVO()->helper->validate_request('_wpnonce','eventon-feature-event', 'edit_eventons', true ,true,'message');     
     1114       
    12261115
    12271116            $post_id = isset( $_GET['eventID'] ) && (int) $_GET['eventID'] ? (int) $_GET['eventID'] : '';
    1228 
    12291117            if (!$post_id) wp_die( __( 'Event id is missing!', 'eventon' ) );
    12301118
     
    12471135        }
    12481136    // system log
    1249         function admin_system_log(){
     1137        public function admin_system_log(){
     1138            // Validate request
     1139            EVO()->helper->validate_request('nn','eventon_admin_nonce', 'edit_eventons', true ,true);   
     1140           
    12501141           
    12511142            $html = '';
     
    12771168            wp_die();
    12781169        }
    1279         function admin_system_log_flush(){
     1170        public function admin_system_log_flush(){
     1171            // Validate request
     1172            EVO()->helper->validate_request('nn','eventon_admin_nonce', 'edit_eventons', true ,true);   
     1173
    12801174            EVO_Error()->_flush_all_logs();
    12811175
     
    12911185
    12921186    // environment @u 4.5.5
    1293         function admin_get_environment(){
    1294 
    1295             // check if admin and loggedin
    1296                 if( !current_user_can('edit_eventons') ){
    1297                     wp_send_json_error(  __('User does not have permission','eventon') );
    1298                     wp_die();
    1299                 }
     1187        public function admin_get_environment(){
     1188
     1189            // Validate request
     1190            EVO()->helper->validate_request('nn','eventon_admin_nonce', 'edit_eventons', true ,true);   
     1191
    13001192           
    13011193            $data = array(); $html = ''; global $wpdb;
  • eventon-lite/trunk/includes/admin/class-admin-taxonomies_editor.php

    r3220597 r3296861  
    22/*
    33 * EventON Taxonomy Editor
    4  * @version 2.3
    5  * @fullversion 4.7.4
     4 * @version 2.4.5
    65 */
    76
    87class EVO_Taxonomies_editor{
    98
    10 public $helper;
    11 
    12 function editor_ajax_calls(){
     9public function editor_ajax_calls(){
    1310    $ajax_events = array(
    1411        'get_event_tax_term_section'=>'get_event_tax_term_section',
     
    2017        $prepend = 'eventon_';
    2118        add_action( 'wp_ajax_'. $prepend . $ajax_event, array( $this, $class ) );
    22         add_action( 'wp_ajax_nopriv_'. $prepend . $ajax_event, array( $this, $class ) );
    23     }
    24 
    25     $this->helper = EVO()->helper;
     19        add_action( 'wp_ajax_nopriv_'. $prepend . $ajax_event, array( $this, 'restrict_unauthenticated' ) );
     20    }
    2621}
    2722
     23// Handle unauthenticated requests
     24    public function restrict_unauthenticated() {
     25        wp_send_json( array( 'status' => 'bad', 'msg' => __( 'Authentication required', 'eventon' )) );
     26        wp_die();
     27    }
     28
    2829// AJAX
    29     function get_event_tax_term_section(){ 
    30 
    31         // validate if user has permission
    32             if( !current_user_can('edit_eventons') ){
    33                 wp_send_json(array(
    34                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    35                 ));
    36                 wp_die();
    37             }   
    38 
    39         $post_data = $this->helper->sanitize_array( $_POST);
     30    public function get_event_tax_term_section(){
     31
     32        // validate
     33        EVO()->helper->validate_request( 'nn', 'eventon_admin_nonce', true, true, true );   
     34
     35        $post_data = EVO()->helper->sanitize_array( $_POST);
    4036
    4137        wp_send_json(array(
     
    4642
    4743    // tax term list to select from
    48     function tax_select_term(){
    49 
    50         // validate if user has permission
    51             if( !current_user_can('edit_eventons') ){
    52                 wp_send_json(array(
    53                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    54                 )); wp_die();
    55             }
    56 
    57         // nonce validation
    58             if( empty($_POST['nn']) || !wp_verify_nonce( wp_unslash( $_POST['nn'] ), 'eventon_admin_nonce' )){
    59                 wp_send_json(array(
    60                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    61                 )); wp_die();
    62             }
    63 
    64         $post_data = $this->helper->sanitize_array( $_POST);
     44    public function tax_select_term(){
     45
     46        // validate
     47        EVO()->helper->validate_request( 'nn', 'eventon_admin_nonce', true, true, true );   
     48
     49        $post_data = EVO()->helper->sanitize_array( $_POST);
    6550        $terms = get_terms(
    6651            array(
     
    129114
    130115            <p style='text-align:center; padding-top:10px;'>
    131                 <span class='evo_btn evo_submit_form' <?php echo $this->helper->array_to_html_data( $btn_data );?>><?php esc_html_e('Save Changes','eventon');?></span>
     116                <span class='evo_btn evo_submit_form' <?php echo EVO()->helper->array_to_html_data( $btn_data );?>><?php esc_html_e('Save Changes','eventon');?></span>
    132117            </p>
    133118
     
    146131
    147132    // save changes
    148         function event_tax_save_changes(){
    149 
    150             // validate if user has permission
    151             if( !current_user_can('edit_eventons') ){
    152                 wp_send_json(array(
    153                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    154                 ));
    155                 wp_die();
    156             }
    157 
    158             // nonce validation
    159             if( empty($_POST['evo_noncename']) || !wp_verify_nonce( wp_unslash( $_POST['evo_noncename'] ), 'evo_save_term_form' ) ){
    160                 wp_send_json(array(
    161                     'status'=>'bad','msg'=> __('Nonce validation failed','eventon')
    162                 )); wp_die();
    163             }
    164 
    165 
    166             $post_data = $this->helper->sanitize_array( $_POST);
     133        public function event_tax_save_changes(){
     134
     135            // validate
     136            EVO()->helper->validate_request( 'evo_noncename', 'evo_save_term_form', true, true, true );
     137           
     138
     139            $post_data = EVO()->helper->sanitize_array( $_POST);
    167140            $status = 'bad';
    168141            $content = '';
     
    290263        }
    291264    // remove a taxonomy term
    292         function event_tax_remove(){
    293 
    294             // validate if user has permission
    295             if( !current_user_can('edit_eventons') ){
    296                 wp_send_json(array(
    297                     'status'=>'bad','msg'=> __('You do not have proper permission to access this','eventon')
    298                 )); wp_die();
    299             }
    300 
    301             $post_data = $this->helper->sanitize_array( $_POST);
    302             $status = 'bad';
    303             $content = '';
    304            
    305             if(!empty($post_data['term_id'])){
    306                 $event_id = (int)$post_data['event_id'];
    307                 wp_remove_object_terms( $event_id, (int)$post_data['term_id'], $post_data['tax'] , false);
    308                 $status = 'good';
    309                 $content = __('Changes successfully saved!','eventon');
    310             }else{
    311                 $content = __('Term ID was not passed!','eventon');
    312             }
    313 
    314             wp_send_json(array(
    315                 'tax'=> $post_data['tax'],
    316                 'status'=>$status,
    317                 'msg'=>$content,
    318                 'htmldata'=> $this->get_meta_box_content($post_data['tax'] , $post_data['event_id'] )
    319             )); wp_die();
     265    public function event_tax_remove(){
     266
     267        // validate
     268        EVO()->helper->validate_request( 'nn', 'eventon_admin_nonce', true, true, true );   
     269       
     270
     271        $post_data = EVO()->helper->sanitize_array( $_POST);
     272        $status = 'bad';
     273        $content = '';
     274       
     275        if(!empty($post_data['term_id'])){
     276            $event_id = (int)$post_data['event_id'];
     277            wp_remove_object_terms( $event_id, (int)$post_data['term_id'], $post_data['tax'] , false);
     278            $status = 'good';
     279            $content = __('Changes successfully saved!','eventon');
     280        }else{
     281            $content = __('Term ID was not passed!','eventon');
     282        }
     283
     284        wp_send_json(array(
     285            'tax'=> $post_data['tax'],
     286            'status'=>$status,
     287            'msg'=>$content,
     288            'htmldata'=> $this->get_meta_box_content($post_data['tax'] , $post_data['event_id'] )
     289        )); wp_die();
    320290        }
    321291
     
    379349                <p class='evo_selected_tax_term evo_edittable_sel_val'>
    380350                    <em><?php echo esc_attr( $term->name );?></em>
    381                     <i class='fa fa-pencil evolb_trigger' <?php echo $this->helper->array_to_html_data( $term_data );?> title='<?php echo esc_attr( $text_edit );?>' ></i>
    382                     <i class='fa fa-times evo_trigger_ajax_run' <?php echo $this->helper->array_to_html_data( $term_data_del );?> title='<?php esc_html_e('Delete','eventon');?>'></i>
     351                    <i class='fa fa-pencil evolb_trigger' <?php echo EVO()->helper->array_to_html_data( $term_data );?> title='<?php echo esc_attr( $text_edit );?>' ></i>
     352                    <i class='fa fa-times evo_trigger_ajax_run' <?php echo EVO()->helper->array_to_html_data( $term_data_del );?> title='<?php esc_html_e('Delete','eventon');?>'></i>
    383353                </p>
    384354                <?php
     
    448418        global $ajde;
    449419
    450         $post_data = $this->helper->sanitize_array( $_POST);
     420        $post_data = EVO()->helper->sanitize_array( $_POST);
    451421
    452422        $is_new = (isset($post_data['type']) && $post_data['type']=='new')? true: false;
  • eventon-lite/trunk/includes/admin/class-evo-admin.php

    r3288092 r3296861  
    9696            $this->metaboxes = new evo_event_metaboxes();
    9797
    98         // Includes for admin
    99             if(defined('DOING_AJAX')){  include_once( 'class-admin-ajax.php' );     }           
     98        // Includes for admin AJAX
     99            if ( ! $this->is_request('admin') || $this->is_request('ajax') ){
     100                include_once( 'class-admin-ajax.php' );     
     101            }   
    100102
    101103        // evneton settings only
     
    131133            add_action('evo_addon_version_change', array($this, 'update_addon_styles'), 10);
    132134
     135    }
     136   
     137    private function is_request( $type ) {
     138        switch ( $type ) {
     139            case 'admin':
     140                return is_admin();
     141            case 'ajax':
     142                return defined( 'DOING_AJAX' );
     143            case 'cron':
     144                return defined( 'DOING_CRON' );
     145            case 'frontend':
     146                return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! $this->is_rest_api_request();
     147        }
    133148    }
    134149   
  • eventon-lite/trunk/includes/admin/settings/settings_support_tab.php

    r3220597 r3296861  
    22/**
    33 * EventON Settings tab - Troubleshoot/support
    4  * @version 2.3
     4 * @version 2.4.5
    55 *
    66 */
     
    6363                </div>",
    6464                'footer'=>"<div class='evopad15 evotac evomarb20'><p style=''><i>" . __('NOTE: Please feel free to type in your question and search our documentation library for related answers','eventon') . "</i></p>
    65                     <a href='https://www.youtube.com/playlist?list=PLj0uAR9EylGrROSEOpT6WuL_ZkRgEIhLq' class='evomart10 evo_admin_btn btn_prime' target='_blank'><i class='fa fa-youtube evomarr10'></i> " . __('EventON Video Tutorials','eventon') . "</a></div>",
     65                    <a href='https://www.youtube.com/playlist?list=PLj0uAR9EylGrROSEOpT6WuL_ZkRgEIhLq' class='evomart10 evo_admin_btn btn_prime' target='_blank'><i class='fa fa-play evomarr10'></i> " . __('EventON Video Tutorials','eventon') . "</a></div>",
    6666                'styles'=>'background-color:var(--evo_color_second);',
    6767            ),
  • eventon-lite/trunk/includes/admin/views/virtual_event_settings.php

    r3121634 r3296861  
    22/**
    33 * Virtual Event Settings
    4  * @version 2.2.16
     4 * @version 2.4.5
    55 */
    66
     
    134134    ?>
    135135    <label><?php esc_html_e('Select moderator for the virtual event','eventon')?></label>
    136     <span class='evo_btn evolb_trigger' <?php echo $this->helper->array_to_html_data($btn_data);?> data-popc='print_lightbox' data-lb_cl_nm='sel_moderator' data-lb_sz='small' data-t='<?php esc_html_e('Select Moderator for Virtual Event','eventon');?>' data-eid='<?php echo esc_attr( $EVENT->ID );?>' style='margin-right: 10px'><?php $EVENT->get_prop('_mod') ? esc_html_e('Update Moderator','eventon') : esc_html_e('Select Moderator','eventon');?></span>
     136    <span class='evo_btn evolb_trigger' <?php echo EVO()->helper->array_to_html_data($btn_data);?> data-popc='print_lightbox' data-lb_cl_nm='sel_moderator' data-lb_sz='small' data-t='<?php esc_html_e('Select Moderator for Virtual Event','eventon');?>' data-eid='<?php echo esc_attr( $EVENT->ID );?>' style='margin-right: 10px'><?php $EVENT->get_prop('_mod') ? esc_html_e('Update Moderator','eventon') : esc_html_e('Select Moderator','eventon');?></span>
    137137</p>
    138138
  • eventon-lite/trunk/includes/class-eventon.php

    r3290104 r3296861  
    22/**
    33 * EventON Lite Setup
    4  * @version 2.4.4
     4 * @version 2.4.5
    55 *
    66 */
     
    1212
    1313    // defines
    14         public $version = '2.4.4';
     14        public $version = '2.4.5';
    1515               
    1616        public $template_url;
     
    185185        $this->evosv            = new Evo_Cal_Schedule();
    186186       
    187         new EVO_AJAX();
    188 
    189 
    190187        $GLOBALS['evo_shortcode_box'] = $this->shortcode_gen;
    191         //$this->helper         = new evo_helper();
    192 
    193         // Classes/actions loaded for the frontend and for ajax requests
    194         if ( ! is_admin() || defined('DOING_AJAX') ) {
    195            
    196         }
    197         if(is_admin()){
     188
     189       
     190        if( $this->is_request('admin') ){
    198191            if( class_exists('evo_admin')) $this->evo_admin     = new evo_admin();
    199192            if( class_exists('EVO_Taxonomies') ) $this->taxonomies  = new EVO_Taxonomies();
  • eventon-lite/trunk/includes/class-evo-ajax.php

    r3269686 r3296861  
    77 * @category    Core
    88 * @package     EventON/Functions/AJAX
    9  * @version     2.4
     9 * @version     2.4.5
    1010 */
    1111
     
    1515     */
    1616
    17     public function __construct(){
     17    public static function init(){
    1818
    1919        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
    2020        add_action( 'template_redirect', array( __CLASS__, 'do_evo_ajax' ), 0 );
    2121
    22         $this->ajax_events();
     22        self::ajax_events();
    2323    }   
    2424
     
    7979
    8080    // AJAX events
    81         public function ajax_events(){
     81        public static function ajax_events(){
    8282            $ajax_events = array(
    8383                'init_load'=>'init_load',                       
     
    9393            foreach ( $ajax_events as $ajax_event => $class ) {
    9494                $prepend = ( in_array($ajax_event, array('evo_dynamic_css','the_post_ajax_hook_3','the_post_ajax_hook_2')) )? '': 'eventon_';
    95                 add_action( 'wp_ajax_'. $prepend . $ajax_event, array( $this, $class ) );
    96                 add_action( 'wp_ajax_nopriv_'. $prepend . $ajax_event, array( $this, $class ) );
     95                add_action( 'wp_ajax_'. $prepend . $ajax_event, array( __CLASS__, $class ) );
     96                add_action( 'wp_ajax_nopriv_'. $prepend . $ajax_event, array( __CLASS__, 'restrict_unauthenticated' ) );
    9797
    9898                // EVO AJAX can be used for frontend ajax requests.
    99                 add_action( 'evo_ajax_' . $prepend . $ajax_event, array( $this , $class ) );
    100             }
    101 
    102         }
     99                add_action( 'evo_ajax_' . $prepend . $ajax_event, array( __CLASS__ , $class ) );
     100            }
     101
     102        }
     103
     104    // Handle unauthenticated requests
     105    public function restrict_unauthenticated() {
     106        wp_send_json( array( 'status' => 'bad', 'msg' => __( 'Authentication required', 'eventon' )) );
     107        wp_die();
     108    }
    103109
    104110    // Initial load
    105         function init_load($return = false){           
    106 
     111        public static function init_load($return = false){         
     112           
     113            // nonce verification
     114            EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false , false, false );
     115           
    107116            $post_data = EVO()->helper->recursive_sanitize_array_fields( $_POST);
    108 
    109             // nonce verification
    110             if(empty( $_POST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    111                 wp_send_json_error( 'bad_nonce' );
    112                 wp_die();
    113             }
    114 
    115117            // init load calendar events
    116118            $CALS = array();
     
    166168
    167169    // General ajax call - added 3.1
    168         public function gen_trig_ajax(){
    169 
    170             // verify nonce
    171             if(empty( $_POST['nn'] ) || !wp_verify_nonce( wp_unslash( $_POST['nn'] ), 'eventon_nonce')) {
    172                 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.','eventon') );
    173             }
     170        public static function gen_trig_ajax(){
     171
     172            // nonce verification
     173            EVO()->helper->validate_request( 'nn', 'eventon_nonce', false, false, false );
    174174           
    175175            $PP = EVO()->helper->recursive_sanitize_array_fields( $_POST );
     
    181181
    182182    // Primary function to load event data u2.2.12
    183         function main_ajax_call(){
     183        public static function main_ajax_call(){
     184
     185            // nonce verification
     186            EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false, false, false );
    184187
    185188            $postdata = EVO()->helper->sanitize_array( $_POST );
    186 
    187             // nonce verification
    188             if(empty( $_POST['nonce'] ) || !wp_verify_nonce(wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    189                 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.','eventon') );
    190             }
    191 
    192189            $shortcode_args = $focused_month_num = $focused_year = '';
    193190            $status = 'GOOD';
     
    287284
    288285    // Now Calendar
    289         public function refresh_now_cal(){
    290 
    291             // nonce verification
    292             if(empty( $_POST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    293                 wp_send_json_error( 'bad_nonce' );
    294                 wp_die();
    295             }
     286        public static function refresh_now_cal(){
     287
     288            // nonce verification
     289            EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false, false, false );
     290
    296291
    297292            $post_data = EVO()->helper->sanitize_array( $_POST );
     
    321316        public function refresh_elm(){
    322317            // nonce verification
    323             if(empty( $_POST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    324                 wp_send_json_error( 'bad_nonce' );
    325                 wp_die();
    326             }
     318            EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false, false, false );
    327319
    328320            $post_data = EVO()->helper->recursive_sanitize_array_fields( $_POST );
    329321
    330             wp_send_json($this->get_refresh_elm_data( $post_data ));           
     322            wp_send_json( self::get_refresh_elm_data( $post_data ));           
    331323        }
    332324
    333325        //get ajax refresh element's data array
    334         private function get_refresh_elm_data($PP, $type ='ajax'){
     326        private static function get_refresh_elm_data($PP, $type ='ajax'){
    335327            $response = array();
    336328
     
    367359    // Load single event content
    368360    // @2.2.8
    369         function load_event_content(){
    370 
    371             // nonce verification
    372             if(empty( $_POST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    373                 wp_send_json_error( 'bad_nonce' );
    374                 wp_die();
    375             }
     361        public static function load_event_content(){
     362
     363            // nonce verification
     364            EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false, false, false );
     365
    376366
    377367            $post_data = EVO()->helper->recursive_sanitize_array_fields( $_POST );
     
    389379    // load single eventcard content
    390380    // @2.2.8
    391         public function load_single_eventcard_content(){
    392 
    393             // nonce verification
    394             if(empty( $_POST['nn'] ) || !wp_verify_nonce( wp_unslash( $_POST['nn'] ), 'eventon_nonce')) {
    395                 wp_send_json_error( 'bad_nonce' );
    396                 wp_die();
    397             }
     381        public static function load_single_eventcard_content(){
     382
     383            // nonce verification
     384            EVO()->helper->validate_request( 'nn', 'eventon_nonce', false, false, false );
    398385           
    399386
     
    434421   
    435422    // Search results for ajax search of events from search box u2.2.12
    436     function search_evo_events(){
     423    public static function search_evo_events(){
    437424
    438425        // nonce verification
    439         if(empty( $_POST['nonce'] ) || !wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'eventon_nonce')) {
    440             wp_send_json_error( 'bad_nonce' );
    441             wp_die();
    442         }
     426        EVO()->helper->validate_request( 'nonce', 'eventon_nonce', false, false, false );
    443427           
    444428        $post_data = EVO()->helper->recursive_sanitize_array_fields( $_POST );
    445 
    446429        $searchfor = isset($post_data['search']) ? $post_data['search'] :'';
    447430        $shortcode = isset($post_data['shortcode']) ? $post_data['shortcode']: array();
     
    518501    }
    519502}
     503
     504
     505
     506EVO_AJAX::init();
  • eventon-lite/trunk/includes/class-evo-helper.php

    r3269686 r3296861  
    33 * Helper functions to be used by eventon or its addons
    44 * front-end only
    5  * @version 2.4
     5 * @version 2.4.5
    66 */
    77
     
    5353
    5454    // sanitization
     55        // @since 2.4.5
     56        public function validate_request(
     57            $nonce_field = 'nn',
     58            $nonce_action = 'eventon_admin_nonce',
     59            $capability = 'edit_eventons',
     60            $require_admin = false,
     61            $require_auth = true,
     62            $output_type = 'json' ,
     63            $use_admin_referer = false
     64        ) {
     65            $error_msg = '';
     66
     67            // Check if in admin context if required
     68            if ( $require_admin && ! is_admin() ) {
     69                $error_msg = __( 'Only available in admin side.', 'eventon' );
     70            }
     71            // Check authentication if required
     72            elseif ( $require_auth && ! is_user_logged_in() ) {
     73                $error_msg = __( 'Authentication required', 'eventon' );
     74            }
     75            // Verify user permissions if capability is specified
     76            elseif ( $capability && ! current_user_can( $capability ) ) {
     77                EVO_Debug( 'Unauthorized access attempt to ' . $nonce_action );
     78                $error_msg = __( 'You do not have proper permission', 'eventon' );
     79            }
     80            // admin referer check
     81            elseif ( $use_admin_referer ) {
     82                if ( ! check_admin_referer( $nonce_action, $nonce_field ) ) {
     83                    $error_msg = __( 'Nonce or referrer validation failed', 'eventon' );
     84                }
     85            }
     86            // Verify nonce
     87            elseif ( empty( $_REQUEST[$nonce_field] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST[$nonce_field] ), $nonce_action ) ) {
     88                $error_msg = __( 'Nonce validation failed', 'eventon' );
     89            }
     90
     91            // Handle output based on $output_type
     92            if ( $error_msg ) {
     93                if ( $output_type === 'json' ) {
     94                    wp_send_json( array( 'status' => 'bad', 'msg' => $error_msg ) );
     95                } else {
     96                    wp_die( $error_msg );
     97                }
     98            }
     99        }
    55100        // @+ 4.0.3
    56101        public function sanitize_array($array){
  • eventon-lite/trunk/includes/integration/openai/class-ai.php

    r3288092 r3296861  
    22/**
    33 * Open AI Integration
    4  * @version 2.4.3
     4 * @version 2.4.5
    55 */
    66
     
    2222        foreach ( $ajax_events as $ajax_event => $class ) {             
    2323            add_action( 'wp_ajax_'.  $ajax_event, array( $this, $class ) );
    24             add_action( 'wp_ajax_nopriv_'.  $ajax_event, array( $this, $class ) );
     24            add_action( 'wp_ajax_nopriv_'.  $ajax_event, array( $this, 'restrict_unauthenticated' ) );
    2525        }
    2626    }
    2727
    28     public function nopriv(){
    29         wp_send_json(['status'=>'nopriv','content'=> __('Login Needed')]);wp_die();
    30     }
     28    // Handle unauthenticated requests
     29    public function restrict_unauthenticated() {
     30        wp_send_json( array( 'status' => 'bad', 'msg' => __( 'Authentication required', 'eventon' )) );
     31        wp_die();
     32    }
    3133
    3234// ajax
    3335    public function enhance_content(){
    3436
    35         // verification
    36             if (empty($_REQUEST['nn']) || !wp_verify_nonce($_REQUEST['nn'], 'eventon_admin_nonce')) {
    37                 wp_send_json_error(array( 'msg' => __('Nonce validation failed', 'eventon') ));
    38                 return;
    39             }
    40 
    41             if( !$this->is_ai_ready()){
    42                 wp_send_json_error(array( 'msg' => __('AI configuration is not ready for use.', 'eventon') ));
    43                 return;
    44             }
     37        // validate
     38        EVO()->helper->validate_request();
     39
     40        if( !$this->is_ai_ready()){
     41            wp_send_json_error(array( 'msg' => __('AI configuration is not ready for use.', 'eventon') ));
     42            return;
     43        }
    4544
    4645        $help = new evo_helper();
     
    8382       
    8483
    85         EVO_Debug( $prompt);
     84        //EVO_Debug( $prompt);
    8685
    8786        $response = $this->call_openai_api($prompt, 300, 3); // Max tokens and 3 completions
     
    206205    public function reset_usage(){
    207206
    208         // verification
    209             if (empty($_REQUEST['nn']) || !wp_verify_nonce($_REQUEST['nn'], 'eventon_admin_nonce')) {
    210                 wp_send_json_error(array( 'msg' => __('Nonce validation failed', 'eventon') ));
    211                 return;
    212             }
    213             if (current_user_can('manage_options')) {
    214                 wp_send_json_error( array('msg'=> __('You do not have permission to reset this data','eventon')) ); return;
    215             }
    216 
    217             if (get_transient('evoai_reset_cooldown')) {
    218                 wp_send_json_error(array('msg' => __('Please wait before resetting again', 'eventon')));
    219                 return;
    220             }
    221             set_transient('evoai_reset_cooldown', true, 60); // 60-second cooldown
     207        // validate
     208        EVO()->helper->validate_request();
     209        if (get_transient('evoai_reset_cooldown')) {
     210            wp_send_json_error(array('msg' => __('Please wait before resetting again', 'eventon')));
     211            return;
     212        }
     213        set_transient('evoai_reset_cooldown', true, 60); // 60-second cooldown
    222214
    223215        $new_data = array(
     
    238230
    239231    public function get_privacy_notice(){
    240         //EVO_Debug( $_POST);
    241         // verification
    242             if (empty($_REQUEST['nn']) || !wp_verify_nonce($_REQUEST['nn'], 'eventon_admin_nonce')) {
    243                 wp_send_json_error(array( 'msg' => __('Nonce validation failed', 'eventon') ));
    244                 return;
    245             }
    246 
     232        // validate
     233        EVO()->helper->validate_request();
    247234
    248235        ob_start();
  • eventon-lite/trunk/readme.txt

    r3290104 r3296861  
    66Requires at least: 6.0
    77Tested up to: 6.8.1
    8 Stable tag: 2.4.4
     8Stable tag: 2.4.5
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    238238
    239239== Changelog ==
     240= 2.4.5 (2025-5-19) =
     241FIXED: event card settings not saving
     242FIXED: Broken access control validations for admin functions
     243
    240244= 2.4.4 (2025-5-8) =
    241245FIXED: language translations not saving or erasing values
Note: See TracChangeset for help on using the changeset viewer.