Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/truebooker-appointment-booking/main/function_ajax.php
+++ b/truebooker-appointment-booking/main/function_ajax.php
@@ -951,7 +951,7 @@
//update_appointment_booked
add_action('wp_ajax_update_appointment_booked', 'truebooker_update_appointment_booked');
-add_action('wp_ajax_nopriv_update_appointment_booked', 'truebooker_update_appointment_booked');
+
function truebooker_update_appointment_booked()
{
global $wpdb, $settingdatamain, $result, $truebooker_helperobj,$truebooker_emailobj;
@@ -963,8 +963,25 @@
$bookedid = sanitize_text_field(wp_unslash($_POST['bookedid']));
}
- $truebooker_payments_table = $wpdb->prefix . 'truebooker_payments';
$truebooker_appointment_booked_table = $wpdb->prefix.'truebooker_appointment_booked';
+
+ $truebooker_booking_owner_id = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT truebooker_app_user_id FROM {$truebooker_appointment_booked_table} WHERE truebooker_app_booked_id = %d",
+ $bookedid
+ )
+ );
+
+ if ( (int) $truebooker_booking_owner_id !== get_current_user_id() && ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => esc_html__( 'Permission denied.', 'truebooker-appointment-booking' ),
+ ),
+ 403
+ );
+ }
+
+ $truebooker_payments_table = $wpdb->prefix . 'truebooker_payments';
$truebooker_appointment_booked_item_table = $wpdb->prefix.'truebooker_appointment_booked_item';
$truebooker_appointment_cart_table = $wpdb->prefix.'truebooker_appointment_cart';
$truebooker_helperobj->deletefromtable($truebooker_appointment_booked_table,'truebooker_app_booked_id',$bookedid);
@@ -7052,1058 +7069,6 @@
}
-
-
-
-
-
-add_action( 'wp_ajax_add_front_user_booking', 'add_front_user_booking' );
-
-add_action( 'wp_ajax_nopriv_add_front_user_booking', 'add_front_user_booking' );
-
-
-
-function add_front_user_booking(){
-
-
-
- global $wpdb, $settingdatamain, $truebooker_helperobj,$truebooker_emailobj;
-
-
-
- check_ajax_referer( 'truebooker_nonce_action', 'security' );
-
- $message = $error_msg = array();
-
-
-
- $searcharray = array();
-
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
- parse_str($_POST['alldata'], $searcharray);
-
- $truebooker_max_person =1;
-
- if(!empty($settingdatamain)){
-
- if($settingdatamain['truebooker_max_person']){
-
- $truebooker_max_person = $settingdatamain['truebooker_max_person'];
-
- }
-
- }
-
-
-
- $truebooker_user_firstname = sanitize_text_field($searcharray['truebooker_f_user_firstname']);
-
- $truebooker_user_lastname = sanitize_text_field($searcharray['truebooker_f_user_lastname']);
-
- $truebooker_user_email = sanitize_text_field($searcharray['truebooker_f_user_email']);
-
- $truebooker_user_country = sanitize_text_field($searcharray['truebooker_f_user_conutry']);
-
- $truebooker_user_state = sanitize_text_field($searcharray['truebooker_f_user_state']);
-
- $truebooker_user_phone = sanitize_text_field($searcharray['truebooker_f_user_phone']);
-
- $truebooker_user_city = sanitize_text_field($searcharray['truebooker_f_user_city']);
-
- $truebooker_user_address1 = sanitize_text_field($searcharray['truebooker_f_user_address1']);
-
- $truebooker_user_pincode = sanitize_text_field($searcharray['truebooker_f_user_pincode']);
-
- $truebooker_user_phonecode = sanitize_text_field($searcharray['truebooker_f_user_phonecode']);
-
- $truebooker_user_id = sanitize_text_field($searcharray['truebooker_user_id']);
-
- $truebooker_wp_user_id = sanitize_text_field($searcharray['truebooker_wp_user_id']);
-
-
-
- $truebooker_no_user = sanitize_text_field($searcharray['truebooker_f_user_person']);
-
- $truebooker_user_note = sanitize_text_field($searcharray['truebooker_f_user_note']);
-
- $truebooker_user_service = sanitize_text_field($searcharray['truebooker_user_service']);
-
-
-
- $truebooker_user_dt = sanitize_text_field($searcharray['truebooker_f_user_dt']);
-
- $truebooker_user_time = sanitize_text_field($searcharray['tba_front_user_timeslot']);
-
-
-
-
-
- $noncename = sanitize_text_field($searcharray['truebooker_meta_box_noncename']);
-
- $truebooker_user_payment_method = '';
-
- if(isset($searcharray['truebooker_user_payment_method'])){
-
- $truebooker_user_payment_method = sanitize_text_field( $searcharray['truebooker_user_payment_method']);
-
- }
-
- $truebooker_appointment_status = 'pending';
-
-
-
- $truebooker_currency =sanitize_text_field($searcharray['truebooker_currency']);
-
-
-
- if (isset($searcharray['sf-name'])) {
-
- $truebooker_user_subservice = $searcharray['sf-name'];
-
- }
-
-
-
- if (isset($searcharray['subservice-id'])) {
-
- $truebooker_user_subservice_id = $searcharray['subservice-id'];
-
- }
-
- if (isset($searcharray['sf-price'])) {
-
- $truebooker_user_subservice_p = $searcharray['sf-price'];
-
- }
-
-
-
-
-
- $truebooker_tax = $truebooker_sub_total = $truebooker_grand_total = 0.00;
-
- if(!empty($truebooker_user_subservice_p))
-
- {
-
- $summary = pricewithtax($truebooker_user_subservice_p);
-
- $truebooker_tax = $summary['tax'];
-
- $truebooker_sub_total = $summary['subtotal'];
-
- $truebooker_grand_total = $summary['grandtotal'];
-
- }
-
-
-
-
-
-
-
- $noncename = sanitize_text_field($searcharray['truebooker_meta_box_noncename']);
-
-
-
- $table_truebooker_customers = $wpdb->prefix . 'truebooker_user';
-
- $table_truebooker_appointment = $wpdb->prefix . 'truebooker_appointment';
-
-
-
- if ( ! isset( $noncename ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash($noncename) ), 'truebooker_meta_box_nonce' ) ) {
-
- $error_msg['php-error'] = esc_html__('Sorry, Your request can not be processed due to security reason.','truebooker-appointment-booking');
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_error']) ){
-
- $er_msg = $settingdatamain['truebooker_s_error'];
-
- } else {
-
- $er_msg =esc_html__('There is some error!!','truebooker-appointment-booking'); ;
-
- }
-
-
-
- if(empty($truebooker_user_firstname)) {
-
- $error_msg['fname-error-front'] = $er_msg;
-
- }
-
- if(empty($truebooker_user_lastname)) {
-
- $error_msg['lname-error-front'] = $er_msg;
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_mail']) ) {
-
- $er_msg = $settingdatamain['truebooker_s_mail'];
-
- } else {
-
- $er_msg =esc_html__('Please enter your email','truebooker-appointment-booking'); ;
-
- }
-
-
-
- if(empty($truebooker_user_email)) {
-
- $error_msg['email-error-front'] = $er_msg;
-
- }
-
- else {
-
- if (!filter_var($truebooker_user_email, FILTER_VALIDATE_EMAIL)) {
-
- $error_msg['email-error-front'] = esc_html__("Please enter valid email address",'truebooker-appointment-booking'); ;
-
- }
-
-
-
- $user_wp_id = email_exists($truebooker_user_email);
-
- if($truebooker_wp_user_id != $user_wp_id){
-
- if(!empty($user_wp_id))
-
- {
-
- $error_msg['email-error-front'] = esc_html__("User already exist with same email",'truebooker-appointment-booking');
-
- }
-
- }
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_phone']) ){
-
- $er_msg = $settingdatamain['truebooker_s_phone'];
-
- } else {
-
- $er_msg =esc_html__('Please enter your phone','truebooker-appointment-booking');
-
- }
-
-
-
- if(empty($truebooker_user_phone)) {
-
- $error_msg['phone-error-front'] = $er_msg;
-
- }
-
- else {
-
- if (!preg_match("/^[0-9]*$/", $truebooker_user_phone)) {
-
- $error_msg['phone-error-front'] = esc_html__("Only numeric value is allowed",'truebooker-appointment-booking');
-
- }
-
- }
-
-
-
- if(empty($truebooker_user_country)) {
-
- $error_msg['country-error-front'] = esc_html__('Please select country','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_state)) {
-
- $error_msg['state-error-front'] = esc_html__('Please select state','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_city)) {
-
- $error_msg['city-error-front'] = esc_html__('Please enter your city','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_pincode)) {
-
- $error_msg['pincode-error-front'] = esc_html__('Please enter pincode','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_address1)) {
-
- $error_msg['address1-error-front'] = esc_html__('Please enter address','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_no_user)) {
-
- $error_msg['person-error-front'] = esc_html__('Please enter No. of Person','truebooker-appointment-booking');
-
- }
-
- else
-
- {
-
-
-
- if (is_string($truebooker_no_user) && !is_numeric($truebooker_no_user)) {
-
- $error_msg['person-error-front'] = esc_html__( 'Please enter proper maximum person', 'truebooker-appointment-booking' );
-
- }
-
-
-
- if($truebooker_no_user > $truebooker_max_person || $truebooker_no_user < 1)
-
- {
-
- $error_msg['person-error-front'] = esc_html__( 'Please enter proper maximum person in between 1 to 20', 'truebooker-appointment-booking' );
-
- }
-
-
-
- }
-
-
-
-
-
-
-
- $message['error_message']=$error_msg;
-
-
-
- if(!empty($error_msg))
-
- {
-
- $message['php_error']= '<div class="truebooker_error tba-popconfirm"><span>'.$er_msg.'</span></div>';
-
- }
-
- else{
-
-
-
- $data = array(
-
- 'truebooker_user_firstname'=> $truebooker_user_firstname,
-
- 'truebooker_user_lastname'=> $truebooker_user_lastname,
-
- 'truebooker_user_email'=> $truebooker_user_email,
-
- 'truebooker_user_country'=> $truebooker_user_country,
-
- 'truebooker_user_state'=> $truebooker_user_state,
-
- 'truebooker_user_city'=> $truebooker_user_city,
-
- 'truebooker_user_pincode'=> $truebooker_user_pincode,
-
- 'truebooker_user_address1'=> $truebooker_user_address1,
-
- 'truebooker_user_phone'=> $truebooker_user_phone,
-
- 'truebooker_user_phonecode'=> $truebooker_user_phonecode,
-
- );
-
-
-
-
-
- if(!empty( $truebooker_user_id ))
-
- {
-
-
-
-
-
- $user_data = wp_update_user( array( 'ID' => $truebooker_wp_user_id, 'user_email' => $truebooker_user_email ) );
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
- $wpdb->update(
-
- $table_truebooker_customers,
-
- $data,
-
- array(
-
- 'truebooker_user_id' => $truebooker_user_id,
-
- )
-
- );
-
- $customerid = $truebooker_user_id;
-
- $message['truebooker_user_id'] = $truebooker_user_id;
-
- $message['truebooker_wp_user_id'] = $truebooker_wp_user_id;
-
- $message['success'] = esc_html__('User update successfull','truebooker-appointment-booking');
-
- }
-
- else
-
- {
-
- $createnew='';
-
- if(empty($truebooker_wp_user_id)){
-
-
-
-
-
- $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
-
-
-
- $emaildata = explode("@",$truebooker_user_email);
-
- $truebooker_user_name = $emaildata[0];
-
-
-
-
-
- $truebooker_wp_user_id = createuser($truebooker_user_name,$truebooker_user_email,$random_password);
-
-
-
- $createnew= 1;
-
-
-
- }
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($table_truebooker_customers, $data);
-
-
-
- $customerid = $wpdb->insert_id;
-
-
-
- if(!empty($customerid))
-
- {
-
- $data = array(
-
- 'truebooker_wpuser_id'=> $truebooker_wp_user_id,
-
- );
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
- $wpdb->update(
-
- $table_truebooker_customers,
-
- $data,
-
- array(
-
- 'truebooker_user_id' => $customerid,
-
- )
-
- );
-
-
-
- if(!empty($createnew)){
-
- $info['user_login'] = $truebooker_user_name;
-
-
-
- $info['user_password'] = $truebooker_password;
-
-
-
- $info['remember'] = true;
-
-
-
- $user_signon = wp_signon( $info, false );
-
-
-
- $truebooker_emailobj->newAccountCreateMail($truebooker_user_name,$truebooker_user_email,$truebooker_password);
-
- }
-
- }
-
- $message['truebooker_user_id'] = $customerid;
-
- $message['truebooker_wp_user_id'] = $truebooker_wp_user_id;
-
- $message['success'] =esc_html__('User create successfull','truebooker-appointment-booking');
-
- }
-
-
-
-
-
-
-
- if($customerid)
-
- {
-
-
-
-
-
- $data = array(
-
- 'truebooker_wp_user_id' => $truebooker_wp_user_id,
-
- 'truebooker_user_id' => $customerid,
-
- 'truebooker_user_note'=> $truebooker_user_note,
-
- 'truebooker_user_service'=> $truebooker_user_service,
-
- 'truebooker_user_currency'=>$truebooker_currency,
-
- 'truebooker_user_dt'=> $truebooker_user_dt,
-
- 'truebooker_user_time'=> $truebooker_user_time,
-
- 'truebooker_user_person'=> $truebooker_no_user,
-
- 'truebooker_user_payment_method'=> $truebooker_user_payment_method,
-
- 'truebooker_appointment_status'=> $truebooker_appointment_status,
-
- 'truebooker_sub_total'=> $truebooker_sub_total,
-
- 'truebooker_tax'=> $truebooker_tax,
-
- 'truebooker_grand_total'=> $truebooker_grand_total,
-
- );
-
-
-
- $appointmentid = $truebooker_helperobj->tbabCommonInsert($table_truebooker_appointment,$data);
-
-
- $appointmentid = base64_encode($appointmentid);
-
- $message['appintid'] = $appointmentid;
-
-
-
-
-
- }
-
-
-
- }
-
-
-
-
-
- echo wp_json_encode($message);
-
- die;
-
-}
-
-
-
-add_action( 'wp_ajax_admin_user_create', 'admin_user_create_cus' );
-
-add_action( 'wp_ajax_nopriv_admin_user_create', 'admin_user_create_cus' );
-
-
-
-function admin_user_create_cus()
-
-{
-
- global $wpdb, $settingdatamain, $result, $paysandbox,$truebooker_emailobj;
-
-
-
- check_ajax_referer( 'truebooker_nonce_action', 'security' );
-
-
-
- $message = $error_msg = array();
-
-
-
- $searcharray = array();
-
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
- // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
- parse_str($_POST['alldata'], $searcharray);
-
-
-
- $truebooker_user_firstname = sanitize_text_field($searcharray['truebooker_f_user_firstname']);
-
- $truebooker_user_lastname = sanitize_text_field($searcharray['truebooker_f_user_lastname']);
-
- $truebooker_user_email = sanitize_text_field($searcharray['truebooker_f_user_email']);
-
- $truebooker_user_country = sanitize_text_field($searcharray['truebooker_f_user_conutry']);
-
- $truebooker_user_state = sanitize_text_field($searcharray['truebooker_f_user_state']);
-
- $truebooker_user_phone = sanitize_text_field($searcharray['truebooker_f_user_phone']);
-
- $truebooker_user_city = sanitize_text_field($searcharray['truebooker_f_user_city']);
-
- $truebooker_user_address1 = sanitize_text_field($searcharray['truebooker_f_user_address1']);
-
- $truebooker_user_pincode = sanitize_text_field($searcharray['truebooker_f_user_pincode']);
-
- $truebooker_user_name = sanitize_text_field($searcharray['truebooker_f_user_name']);
-
- $truebooker_password = sanitize_text_field($searcharray['truebooker_f_password']);
-
- $truebooker_user_phonecode ='';
-
-
-
-
-
-
-
-
-
- $truebooker_user_id = sanitize_text_field($searcharray['truebooker_user_id']);
-
- $truebooker_wp_user_id = sanitize_text_field($searcharray['truebooker_wp_user_id']);
-
-
-
- $noncename = sanitize_text_field($searcharray['truebooker_meta_box_noncename']);
-
-
-
- $table_truebooker_customers = $wpdb->prefix . 'truebooker_user';
-
-
-
- if ( ! isset( $noncename ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash($noncename) ), 'truebooker_meta_box_nonce' ) ) {
-
- $error_msg['php-error'] = esc_html__('Sorry, Your request can not be processed due to security reason.','truebooker-appointment-booking');
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_error']) ){
-
- $er_msg = $settingdatamain['truebooker_s_error'];
-
- } else {
-
- $er_msg =esc_html__('There is some error!!','truebooker-appointment-booking'); ;
-
- }
-
-
-
- if(empty($truebooker_user_firstname)) {
-
- $error_msg['fname-error-front'] = $er_msg;
-
- }
-
- if(empty($truebooker_user_lastname)) {
-
- $error_msg['lname-error-front'] = $er_msg;
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_mail']) ) {
-
- $er_msg = $settingdatamain['truebooker_s_mail'];
-
- } else {
-
- $er_msg =esc_html__('Please enter your email','truebooker-appointment-booking'); ;
-
- }
-
-
-
- if(empty($truebooker_user_email)) {
-
- $error_msg['email-error-front'] = $er_msg;
-
- }
-
- else {
-
- if (!filter_var($truebooker_user_email, FILTER_VALIDATE_EMAIL)) {
-
- $error_msg['email-error-front'] = esc_html__("Please enter valid email address",'truebooker-appointment-booking'); ;
-
- }
-
-
-
- $user_wp_id = email_exists($truebooker_user_email);
-
- if($truebooker_wp_user_id != $user_wp_id){
-
- if(!empty($user_wp_id))
-
- {
-
- $error_msg['email-error-front'] = esc_html__("User already exist with same email",'truebooker-appointment-booking');
-
- }
-
- }
-
- }
-
-
-
- if(!empty($settingdatamain['truebooker_s_phone']) ){
-
- $er_msg = $settingdatamain['truebooker_s_phone'];
-
- } else {
-
- $er_msg =esc_html__('Please enter your phone','truebooker-appointment-booking');
-
- }
-
-
-
- if(empty($truebooker_user_phone)) {
-
- $error_msg['phone-error-front'] = $er_msg;
-
- }
-
- else {
-
- if (!preg_match("/^[0-9]*$/", $truebooker_user_phone)) {
-
- $error_msg['phone-error-front'] = esc_html__("Only numeric value is allowed",'truebooker-appointment-booking');
-
- }
-
- }
-
-
-
- if(empty($truebooker_user_country)) {
-
- $error_msg['country-error-front'] = esc_html__('Please select country','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_state)) {
-
- $error_msg['state-error-front'] = esc_html__('Please select state','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_city)) {
-
- $error_msg['city-error-front'] = esc_html__('Please enter your city','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_pincode)) {
-
- $error_msg['pincode-error-front'] = esc_html__('Please enter pincode','truebooker-appointment-booking');
-
- }
-
- if(empty($truebooker_user_address1)) {
-
- $error_msg['address1-error-front'] = esc_html__('Please enter address','truebooker-appointment-booking');
-
- }
-
-
-
-
-
-
-
- if(empty($truebooker_password))
-
- {
-
- if(empty($truebooker_wp_user_id)){
-
- $error_msg['password-error-front'] = esc_html__('Please enter password','truebooker-appointment-booking');
-
- }
-
-
-
- }
-
-
-
- if(!empty($truebooker_password))
-
- {
-
- if(!empty($truebooker_wp_user_id)){
-
- $length = strlen ($truebooker_password);
-
- if($length < 5) {
-
- $error_msg['password-error-front'] = esc_html__('Please enter password atleast five character','truebooker-appointment-booking');
-
- }
-
- }
-
- }
-
-
-
- if(empty($truebooker_user_name))
-
- {
-
- if(!empty($truebooker_wp_user_id)){
-
- $error_msg['user-name-error-front'] = esc_html__('Please enter username','truebooker-appointment-booking');
-
- }
-
- }
-
-
-
- if(!empty($truebooker_user_name))
-
- {
-
- $user_wp_id = username_exists( $truebooker_user_name );
-
- if(!empty($user_wp_id)){
-
- if($truebooker_wp_user_id != $user_wp_id){
-
- $error_msg['user-name-error-front'] = esc_html__('User is already exist with same username','truebooker-appointment-booking');
-
- }
-
- }
-
- }
-
-
-
-
-
- $message['error_message']=$error_msg;
-
-
-
- if(!empty($error_msg))
-
- {
-
- $message['php_error']= '<div class="truebooker_error tba-popconfirm"><span>'.esc_html__('There is some error!!','truebooker-appointment-booking').'</span></div>';
-
- }
-
- else{
-
-
-
- $data = array(
-
- 'truebooker_user_firstname'=> $truebooker_user_firstname,
-
- 'truebooker_user_lastname'=> $truebooker_user_lastname,
-
- 'truebooker_user_email'=> $truebooker_user_email,
-
- 'truebooker_user_country'=> $truebooker_user_country,
-
- 'truebooker_user_state'=> $truebooker_user_state,
-
- 'truebooker_user_city'=> $truebooker_user_city,
-
- 'truebooker_user_pincode'=> $truebooker_user_pincode,
-
- 'truebooker_user_address1'=> $truebooker_user_address1,
-
- 'truebooker_user_phone'=> $truebooker_user_phone,
-
- 'truebooker_user_phonecode'=> $truebooker_user_phonecode,
-
- );
-
-
-
-
-
- if(!empty( $truebooker_user_id ))
-
- {
-
-
-
-
-
- $user_data = wp_update_user( array( 'ID' => $truebooker_wp_user_id, 'user_email' => $truebooker_user_email ) );
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
- $wpdb->update(
-
- $table_truebooker_customers,
-
- $data,
-
- array(
-
- 'truebooker_user_id' => $truebooker_user_id,
-
- )
-
- );
-
-
-
- $message['success'] = esc_html__('User update successfull','truebooker-appointment-booking');
-
- }
-
- else
-
- {
-
-
-
- $wp_user_id = createuser($truebooker_user_name,$truebooker_user_email,$truebooker_password);
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($table_truebooker_customers, $data);
-
-
-
- $customerid = $wpdb->insert_id;
-
-
-
- if(!empty($customerid))
-
- {
-
- $data = array(
-
- 'truebooker_wpuser_id'=> $wp_user_id,
-
- );
-
-
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
- // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
- $wpdb->update(
-
- $table_truebooker_customers,
-
- $data,
-
- array(
-
- 'truebooker_user_id' => $customerid,
-
- )
-
- );
-
-
-
-
-
- $truebooker_emailobj->newAccountCreateMail($truebooker_user_name,$truebooker_user_email,$truebooker_password);
-
- }
-
-
-
-
-
- $message['success'] =esc_html__('User create successfull','truebooker-appointment-booking');
-
- }
-
-
-
- }
-
-
-
-
-
-
-
- echo wp_json_encode($message);
-
- die;
-
-}
-
-
-
function createuser($username=null, $email=null,$password=null)
{
@@ -13674,37 +12639,39 @@
/*** appointments *********/
add_action('wp_ajax_update_appointment_status', 'truebooker_update_appointment_status');
-add_action('wp_ajax_nopriv_update_appointment_status', 'truebooker_update_appointment_status');
function truebooker_update_appointment_status()
{
global $wpdb,$truebooker_emailobj;
+
+
+ if ( ! is_user_logged_in() ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Unauthorized', 'truebooker-appointment-booking' ),
+ ),
+ 403
+ );
+ }
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Permission denied.', 'truebooker-appointment-booking' ),
+ ),
+ 403
+ );
+ }
+
if(isset($_POST['appointmentid']))
{
$appointmentid = sanitize_text_field(wp_unslash($_POST['appointmentid']));
}
- if(isset($_POST['appuserwpid']))
- {
- $appuserwpid = sanitize_text_field(wp_unslash($_POST['appuserwpid']));
- }
if(isset($_POST['appnewstatus']))
{
$appnewstatus = sanitize_text_field(wp_unslash($_POST['appnewstatus']));
}
- if(isset($_POST['servicename']))
- {
- $service_name = sanitize_text_field(wp_unslash($_POST['servicename']));
- }
- if(isset($_POST['appbookeddate']))
- {
- $appbookeddate = sanitize_text_field(wp_unslash($_POST['appbookeddate']));
- }
-
- if(isset($_POST['appbookedtime']))
- {
- $appbookedtime = sanitize_text_field(wp_unslash($_POST['appbookedtime']));
- }
@@ -13717,32 +12684,36 @@
if ( empty($appnewstatus) || ! $appointmentid ) {
wp_send_json_error(['message' => 'Invalid input.']);
}
+
+ $truebooker_allowed_statuses = array( 'pending', 'approved', 'cancelled' );
+ if ( ! in_array( $appnewstatus, $truebooker_allowed_statuses, true ) ) {
+ wp_send_json_error(['message' => 'Invalid status.']);
+ }
- /********** Start Get user info **************/
+ /********** Start Get user info (derived from the appointment record, not the request) **************/
- $username = $email = $phonecode = $phone = '';
-
+ $username = $useremail = $service_name = $appbookeddate = $appbookedtime = '';
+
$resultsusersql = $wpdb->prepare(
- "SELECT * FROM {$wpdb->prefix}truebooker_user
- WHERE truebooker_wpuser_id = %d",
- $appuserwpid
+ "SELECT i.truebooker_app_booked_item_service_name, i.truebooker_app_booked_item_date, i.truebooker_app_booked_item_time,
+ u.truebooker_user_firstname, u.truebooker_user_lastname, u.truebooker_user_email
+ FROM {$truebooker_app_table} i
+ INNER JOIN {$wpdb->prefix}truebooker_appointment_booked b ON b.truebooker_app_booked_id = i.truebooker_app_booked_id
+ INNER JOIN {$wpdb->prefix}truebooker_user u ON u.truebooker_wpuser_id = b.truebooker_app_user_id
+ WHERE i.truebooker_app_booked_item_id = %d",
+ $appointmentid
);
- $resultsuser = $wpdb->get_results($resultsusersql);
+ $resultsuser = $wpdb->get_row($resultsusersql);
if(!empty($resultsuser))
{
-
-
- foreach ($resultsuser as $resuser) {
-
- $username = $resuser->truebooker_user_firstname.' '.$resuser->truebooker_user_lastname;
- $useremail = $resuser->truebooker_user_email;
- $userphone = $resuser->truebooker_user_phone;
-
- }
-
+ $username = $resultsuser->truebooker_user_firstname.' '.$resultsuser->truebooker_user_lastname;
+ $useremail = $resultsuser->truebooker_user_email;
+ $service_name = $resultsuser->truebooker_app_booked_item_service_name;
+ $appbookeddate = $resultsuser->truebooker_app_booked_item_date;
+ $appbookedtime = $resultsuser->truebooker_app_booked_item_time;
}
@@ -13787,27 +12758,11 @@
wp_send_json_error(['message' => 'Failed to update status.']);
}
- /*if($wpdb->query(
- $wpdb->prepare(
- "UPDATE $truebooker_app_table SET truebooker_app_booked_item_status = %s WHERE truebooker_app_booked_item_id = %d",
- $appnewstatus,
- $appointmentid
- )
- )){
-
- wp_send_json_success(['message' => 'Appointment status updated.']);
-
-
- }else
- {
- wp_send_json_error(['message' => 'Failed to update status.']);
- }
- */
}
+
add_action('wp_ajax_get_bookeappointment_list', 'truebooker_get_bookeappointment_list');
-add_action('wp_ajax_nopriv_bookeappointment_list', 'truebooker_get_bookeappointment_list');
function truebooker_get_bookeappointment_list()
{
@@ -13828,6 +12783,24 @@
{
$appointmentid = sanitize_text_field(wp_unslash($_POST['appointmentid']));
}
+
+ $truebooker_booking_owner_id = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT b.truebooker_app_user_id FROM {$wpdb->prefix}truebooker_appointment_booked_item i
+ INNER JOIN {$wpdb->prefix}truebooker_appointment_booked b ON b.truebooker_app_booked_id = i.truebooker_app_booked_id
+ WHERE i.truebooker_app_booked_item_id = %d",
+ $appointmentid
+ )
+ );
+
+ if ( (int) $truebooker_booking_owner_id !== get_current_user_id() && ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => esc_html__( 'Permission denied.', 'truebooker-appointment-booking' ),
+ ),
+ 403
+ );
+ }
$appointment_table = ['truebooker_appointment_booked_item', 'truebooker_appointment_booked','truebooker_user','users'];
@@ -13963,12 +12936,21 @@
add_action('wp_ajax_truebooker_get_appointments_calendar', 'truebooker_get_appointments_calendar');
-add_action( 'wp_ajax_nopriv_truebooker_get_appointments_calendar', 'truebooker_get_appointments_calendar');
function truebooker_get_appointments_calendar() {
check_ajax_referer( 'truebooker_nonce_action', 'nonce' );
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => esc_html__( 'Permission denied.', 'truebooker-appointment-booking' ),
+ ),
+ 403
+ );
+ }
+
$truebooker_branchid = $truebooker_staffmemberid = '';
if(isset($_GET['staffid']))
--- a/truebooker-appointment-booking/truebooker-appointment-booking.php
+++ b/truebooker-appointment-booking/truebooker-appointment-booking.php
@@ -3,7 +3,7 @@
* Plugin Name: TrueBooker - Appointment Booking and Scheduler System
* Plugin URI: https://wordpress.org/plugins/truebooker-appointment-booking
* Description: Truebooker - Appointment Booking plugin for online book anything, anytime, anywhere. A perfect choice for medical centers, beauty salons, hair shops, car services.
- * Version: 1.2.6
+ * Version: 1.2.7
* Requires at least: 6.5
* Author: ThemetechMount
* Author URI: https://themetechmount.com/
@@ -16,7 +16,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) { exit; }
- define( 'TRUEBOOKER_VERSION', '1.2.6' );
+ define( 'TRUEBOOKER_VERSION', '1.2.7' );
define( 'TRUEBOOKER_DIR', trailingslashit( dirname( __FILE__ ) ) );
define( 'TRUEBOOKER_URL', plugins_url( '', __FILE__ ) );
define( 'TRUEBOOKER_PATH', plugin_dir_path( __FILE__ ) );