<?php       
class cleanto_setting{
	public $option_id;
	public $option_name;
	public $option_value;
	/* below variable is use for General setting*/
	public $ct_timezone;
	public $ct_company_name;
	public $ct_company_email;
	public $ct_company_address;
	public $ct_company_city;
	public $ct_company_state;
	public $ct_company_zip_code;
	public $ct_company_country;
	public $ct_company_country_code;
	public $ct_company_logo;
	public $ct_company_phone;
	public $ct_company_header_address;
	public $ct_company_logo_display;
	public $ct_appointment_details_section;
	public $ct_booking_page_design;
	/* below variable is use for General setting*/
	public $ct_languages;
	public $ct_time_interval;
	public $ct_min_advance_booking_time;
	public $ct_max_advance_booking_time;
	public $ct_booking_padding_time;
	public $ct_service_padding_time_before;
	public $ct_service_padding_time_after;
	public $ct_cancellation_buffer_time;
	public $ct_reshedule_buffer_time;
	public $ct_currency;
	public $ct_currency_symbol_position;
	public $ct_price_format_decimal_places;
	public $ct_tax_vat_status;
	public $ct_tax_vat_type;
	public $ct_tax_vat_value;
	public $ct_partial_deposit_status;
	public $ct_partial_type;
	public $ct_partial_deposit_amount;
	public $ct_partial_deposit_message;
	public $ct_thankyou_page_url;
	public $ct_cancelation_policy_status;
	public $ct_cancel_policy_header;
	public $ct_cancel_policy_textarea;
	public $ct_allow_multiple_booking_for_same_timeslot_status;
	public $ct_appointment_auto_confirm_status;
	public $ct_allow_day_closing_time_overlap_booking;
	public $ct_allow_terms_and_conditions;
	public $ct_choose_time_format;
	public $ct_choose_display_location;
	public $ct_postal_code;
	public $ct_terms_condition_link; 
	public $ct_addons_default_design;
	public $ct_service_default_design;
	public $ct_method_default_design;
	public $ct_front_desc;
	public $ct_subheaders;
	public $ct_cart_scrollable;
	public $ct_privacy_policy_link;
	public $ct_allow_privacy_policy;
	public $ct_allow_front_desc;
	public $ct_currency_symbol;
	public $ct_vc_status;
	public $ct_p_status;
	public $ct_user_zip_code;
	public $ct_calculation_policy;
	public $ct_google_api_key;
	public $ct_minimum_booking_price;
	public $ct_additional_slot_time;
	/* below variable is use for Appearance setting*/
	public $ct_primary_color;
	public $ct_secondary_color;
	public $ct_text_color;
	public $ct_text_color_on_bg;
	public $ct_primary_color_admin;
	public $ct_secondary_color_admin;
	public $ct_text_color_admin;
	public $ct_show_service_provider;
	public $ct_show_provider_avatars;
	public $ct_show_service_dropdown;
	public $ct_show_service_description;
	public $ct_show_coupons_input_on_checkout;
	public $ct_hide_faded_already_booked_time_slots;
	public $ct_guest_user_checkout;
	public $ct_time_format;
	public $ct_date_picker_date_format;
	public $ct_custom_css;
	public $ct_existing_and_new_user_checkout;
	public $ct_phone_display_country_code;
	/* below variable is use for payment setting*/
	public $ct_all_payment_gateway_status;
	public $ct_pay_locally_status;
	public $ct_paypal_express_checkout_status;
	public $ct_paypal_api_username;
	public $ct_paypal_api_password;
	public $ct_paypal_api_signature;
	public $ct_paypal_guest_payment_status;
	public $ct_paypal_test_mode_status;
	public $ct_stripe_payment_form_status;
	public $ct_stripe_secretkey;
	public $ct_stripe_publishablekey;
	public $ct_authorizenet_status;
	public $ct_authorizenet_API_login_ID;
	public $ct_authorizenet_transaction_key;
	public $ct_authorize_sandbox_mode;
	public $ct_2checkout_status;
	public $ct_2checkout_sellerid;
	public $ct_2checkout_publishkey;
	public $ct_2checkout_privatekey;
	public $ct_2checkout_sandbox_mode;
	public $ct_postalcode_status;
	public $ct_payway_status;
	public $ct_payway_publishable_key;
	public $ct_payway_secure_key;
	public $ct_payway_purchase_status;
	/* below variable is use for email setting */

	public $ct_admin_email_notification_status;
	public $ct_staff_email_notification_status;
	public $ct_client_email_notification_status;
	public $ct_email_sender_name;
	public $ct_email_sender_address;
	public $ct_admin_optional_email;
	public $ct_email_appointment_reminder_buffer;
	public $ct_smtp_hostname;
	public $ct_smtp_username;
	public $ct_smtp_password;
	public $ct_smtp_port;
	public $ct_smtp_encryption;
	public $ct_smtp_authetication;
	/* below variable use for Client email template */
	public $ct_client_email_appointment_approved_by_service_provider_status;
	public $ct_client_email_appointment_rejected_by_service_provider_status;
	public $ct_client_email_appointment_cancelled_by_you_status;
	public $ct_client_email_appointment_cancelled_by_service_provider_status;
	public $ct_client_email_appointment_completed_status;
	public $ct_client_email_appointment_request_status;
	public $ct_client_email_appointment_reminder_status;
	public $ct_client_email_appointment_marked_as_no_show_status;
	/* below variable use for Admin/service provider email template*/
	public $ct_admin_email_new_appointment_request_requires_approval_status;
	public $ct_admin_email_appointment_approved_status;
	public $ct_admin_email_appointment_cancelled_by_customer_status;
	public $ct_admin_email_appointment_rejected_status;
	public $ct_admin_email_appointment_cancelled_status;
	public $ct_admin_email_admin_appointment_marked_as_no_show_status;
	public $ct_admin_email_appointment_reminder_status;
	public $ct_admin_email_appointment_completed_with_client_status;
	/* below variable is use for SMS notification*/
	public $ct_sms_service_status;
	public $ct_sms_twilio_account_SID;
	public $ct_sms_twilio_auth_token;
	public $ct_sms_twilio_sender_number;
	public $ct_sms_twilio_send_sms_to_service_provider_status;
	public $ct_sms_twilio_send_sms_to_client_status;
	public $ct_sms_twilio_send_sms_to_admin_status;
	public $ct_sms_twilio_admin_phone_number;
	public $ct_sms_plivo_account_SID;
	public $ct_sms_plivo_auth_token;
	public $ct_sms_plivo_sender_number;
	public $ct_sms_plivo_send_sms_to_client_status;
	public $ct_sms_plivo_send_sms_to_admin_status;
	public $ct_sms_plivo_admin_phone_number;
	public $ct_sms_plivo_status;
	public $ct_sms_twilio_status;
	public $ct_sms_template_admin_notification;
	public $ct_sms_template_service_provider;
	public $ct_sms_template_client_notification;
	public $ct_sms_textlocal_account_username;
	public $ct_sms_textlocal_account_hash_id;
	public $ct_sms_textlocal_send_sms_to_client_status;
	public $ct_sms_textlocal_send_sms_to_admin_status;
	public $ct_sms_textlocal_status;
	public $ct_sms_nexmo_status;
	public $ct_nexmo_api_key;
	public $ct_nexmo_api_secret;
	public $ct_nexmo_from;
	public $ct_nexmo_status;
	public $ct_sms_nexmo_send_sms_to_client_status;
	public $ct_sms_nexmo_send_sms_to_admin_status;
	public $ct_sms_nexmo_admin_phone_number;
	/* Below variable is use for client sms template setting */
	public $ct_client_sms_approved_by_provider;
	public $ct_client_sms_rejected_by_provider;
	public $ct_client_sms_cancel_by_you;
	public $ct_client_sms_cancelled_by_provider;
	public $ct_client_sms_appointment_completed;
	public $ct_client_sms_appointment_request;
	public $ct_client_sms_appointment_reminder;
	public $ct_client_sms_appoitment_marked_as_no_show;
	/* Below variable is use for admin sms template setting*/
	public $ct_admin_client_new_appointment_request_requires_approval;
	public $ct_admin_client_new_appointment_approved;
	public $ct_admin_client_appointment_cancelled_by_customer;
	public $ct_admin_client_appointment_rejected;
	public $ct_admin_client_appointment_cancelled;
	public $ct_admin_client_appointment_marked_as_no_show;
	public $ct_admin_client_appointment_reminder;
	public $ct_admin_client_appointment_completed_with_client;
	/* below variable is use for Label setting*/
	public $ct_label_choose_service1;
	public $ct_label_choose_service2;
	public $ct_label_your_appointments;
	public $ct_label_total;
	/* below variable is use for Manual form field setting*/
	public $ct_email;
	public $ct_password;
	public $ct_firstname;
	public $ct_lastname;
	public $ct_phonenumber;
	public $ct_gender;
	public $ct_age;
	public $ct_postcode;
	public $ct_streetaddress;
	public $ct_town_city;
	public $ct_state;
	public $ct_country;
	public $ct_skype;
	public $ct_notes;
	/* below variable is use for Manager setting*/
	public $ct_manager_dashboard;
	public $ct_manager_appointment;
	public $ct_manager_location;
	public $ct_manager_services;
	public $ct_manager_staff;
	public $ct_manager_customers;
	public $ct_manager_payments;
	public $ct_manager_main_settings;
	public $ct_manager_company_setting;
	public $ct_manager_general_setting;
	public $ct_manager_appearance_setting;
	public $ct_manager_payment_setting;
	public $ct_manager_email_notification_setting;
	public $ct_manager_email_template_setting;
	public $ct_manager_sms_notification_setting;
	public $ct_manager_sms_template_setting;
	public $ct_manager_label_setting;
	public $ct_manager_manage_form_field_setting;
	public $ct_manager_custom_form_field_setting;
	public $ct_manager_promocode_setting;
	public $ct_manager_manager_capability_setting;
	public $ct_manager_export_setting;
	public $ct_manager_notification;
	public $conn;
	public $table_name = "ct_settings";
	public $ct_language;
	public $table_language = "ct_languages";
	/*below variable for front tooltips */
	public $ct_front_tool_tips_status;
	public $ct_front_tool_tips_my_bookings;
	public $ct_front_tool_tips_postal_code;
	public $ct_front_tool_tips_services;
	public $ct_front_tool_tips_addons_services;
	public $ct_front_tool_tips_frequently_discount;
	public $ct_front_tool_tips_time_slots;
	public $ct_front_tool_tips_personal_details;
	public $ct_front_tool_tips_promocode;
	public $ct_front_tool_payment_method;
	/*bank variable*/
	public $ct_bank_name;
	public $ct_account_name;
	public $ct_account_number;
	public $ct_branch_code;
	public $ct_ifsc_code;
	public $ct_bank_description;
	public $ct_bank_transfer_status;
	public $ct_bf_first_name;
	public $ct_bf_last_name;
	public $ct_bf_email;
	public $ct_bf_password;
	public $ct_bf_phone;
	public $ct_bf_address;
	public $ct_bf_zip_code;
	public $ct_bf_city;
	public $ct_bf_state;
	public $ct_bf_notes;
	public $ct_front_language_selection_dropdown;
	public $ct_loader;
	/* recurrence booking */
	public $ct_recurrence_booking_status;
	public $ct_recurrence_booking_type;
	/* For Google Calender Settings */
	public $ct_gc_status;
	public $ct_gc_id;
	public $ct_gc_client_id;
	public $ct_gc_client_secret;
	public $ct_gc_status_configure;
	public $ct_gc_status_sync_configure;
	public $ct_gc_token;
	public $ct_gc_frontend_url;
	public $ct_gc_admin_url;
	public $ct_special_offer_text;
	public $ct_special_offer;
	public $ct_wallet_section;
	public $exist_lang;
	public $eng;
	/*Xero*/
	public $ct_xero_status;
	public $ct_xero_client_ID;
	public $ct_xero_client_secret;
  public $ct_xero_company_name;
  public $ct_sms_textlocal_admin_phone;
  public $ct_company_title_display;
  public $ct_company_address1;
  public $ct_company_address2;
  public $ct_appointment_details_display;
  public $ct_star_show_on_front;
  public $ct_show_time_duration;
  public $ct_sms_twilio_send_sms_to_staff_status;
  public $ct_sms_plivo_send_sms_to_staff_status;
  public $ct_sms_nexmo_send_sms_to_staff_status;
  public $ct_sms_textlocal_send_sms_to_staff_status;
  public $ct_referral_status;
  public $ct_referral_type;
  public $ct_referral_value;
  public $ct_special_days_status;
  public $ct_special_days;
  public $ct_special_days_title;
  public $ct_special_days_value;
  public $ct_special_day_color;
  public $ct_refs_type;
  public $ct_refs_value;
  public $ct_special_type;
  public $ct_service_design;
  public $ct_show_referral_input_on_checkout;
  public $ct_sms_messagebird_status;
  public $ct_sms_messagebird_account_apikey;
  public $ct_sms_messagebird_send_sms_to_client_status;
  public $ct_sms_messagebird_send_sms_to_admin_status;
  public $ct_sms_messagebird_send_sms_to_staff_status;
  public $ct_sms_messagebird_admin_phone;
  public $ct_limit_booking_time_slot;
  public $ct_booking_time_slot_limit;
  public $ct_staff_registration;
  public $ct_staff_zipcode;
  public $coupon_value;
  public $coupon_date;
  public $coupon_type;
  public $special_text;
  
	
	/* Function for add Settings */
	public function add_option($option_name, $option_value){
		$this->option_name = $option_name;
		$this->option_value = $option_value;
		$query = "insert into `" . $this->table_name . "` (`id`,`option_name`,`option_value`,`postalcode`) values(NULL,'" . $this->option_name . "','" . $this->option_value . "','')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function update_option(){
		$query = "update `" . $this->table_name . "` set `business_id`='" . $this->business_id . "',`option_name`='" . $this->option_name . "',`option_value`='" . $this->option_value . "' where `id`='" . $this->option_id . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function __construct(){
		$this->chk_pc();
	}
    
	/* Function for Read and Display Settings */
	public function readall(){
    $Allsettings = array('ct_loader','ct_sms_textlocal_admin_phone','ct_sms_textlocal_account_username','ct_sms_textlocal_account_hash_id','ct_sms_textlocal_send_sms_to_client_status','ct_sms_textlocal_send_sms_to_admin_status','ct_sms_textlocal_status','ct_company_logo_display','ct_company_title_display','ct_user_zip_code','ct_existing_and_new_user_checkout','ct_company_header_address','ct_postalcode_status','ct_2checkout_sandbox_mode','ct_2checkout_privatekey','ct_2checkout_publishkey','ct_2checkout_sellerid','ct_2checkout_status','ct_admin_optional_email','ct_company_phone','ct_sms_twilio_status','ct_sms_plivo_status','ct_sms_twilio_account_SID','ct_sms_twilio_auth_token','ct_sms_twilio_sender_number','ct_sms_twilio_send_sms_to_service_provider_status','ct_sms_twilio_send_sms_to_client_status','ct_sms_twilio_send_sms_to_admin_status','ct_sms_twilio_admin_phone_number','ct_sms_plivo_account_SID','ct_sms_plivo_auth_token','ct_sms_plivo_sender_number','ct_sms_plivo_send_sms_to_client_status','ct_sms_plivo_send_sms_to_admin_status','ct_sms_plivo_admin_phone_number','ct_vc_status','ct_p_status','ct_custom_css','ct_language', 'ct_company_country_code', 'ct_timezone', 'ct_smtp_hostname', 'ct_smtp_username', 'ct_smtp_password', 'ct_smtp_port', 'ct_currency_symbol', 'ct_allow_front_desc', 'ct_privacy_policy_link', 'ct_allow_privacy_policy', 'ct_service_default_design', 'ct_subheaders', 'ct_cart_scrollable', 'ct_front_desc', 'ct_addons_default_design', 'ct_method_default_design', 'ct_terms_condition_link', 'ct_company_name', 'ct_company_email', 'ct_company_address', 'ct_company_city', 'ct_company_state', 'ct_company_zip_code', 'ct_company_country', 'ct_company_logo', 'ct_languages', 'ct_time_interval', 'ct_min_advance_booking_time', 'ct_max_advance_booking_time', 'ct_booking_padding_time', 'ct_service_padding_time_before', 'ct_service_padding_time_after', 'ct_cancellation_buffer_time', 'ct_reshedule_buffer_time', 'ct_currency', 'ct_currency_symbol_position', 'ct_price_format_decimal_places', 'ct_tax_vat_status', 'ct_tax_vat_type', 'ct_tax_vat_value', 'ct_partial_deposit_status', 'ct_partial_type', 'ct_partial_deposit_amount', 'ct_partial_deposit_message', 'ct_thankyou_page_url', 'ct_cancelation_policy_status', 'ct_cancel_policy_header', 'ct_cancel_policy_textarea', 'ct_allow_multiple_booking_for_same_timeslot_status', 'ct_appointment_auto_confirm_status', 'ct_allow_day_closing_time_overlap_booking', 'ct_allow_terms_and_conditions', 'ct_choose_time_format', 'ct_choose_display_location', 'ct_company_name', 'ct_company_email', 'ct_company_address1', 'ct_company_address2', 'ct_company_logo', 'ct_primary_color', 'ct_secondary_color', 'ct_text_color', 'ct_text_color_on_bg', 'ct_primary_color_admin', 'ct_secondary_color_admin', 'ct_text_color_admin', 'ct_show_service_provider', 'ct_show_provider_avatars', 'ct_show_service_dropdown', 'ct_show_service_description', 'ct_show_coupons_input_on_checkout', 'ct_hide_faded_already_booked_time_slots', 'ct_guest_user_checkout', 'ct_time_format', 'ct_date_picker_date_format', 'ct_all_payment_gateway_status', 'ct_pay_locally_status', 'ct_paypal_express_checkout_status', 'ct_paypal_api_username', 'ct_paypal_api_password', 'ct_paypal_api_signature', 'ct_paypal_guest_payment_status', 'ct_paypal_test_mode_status', 'ct_stripe_payment_form_status', 'ct_stripe_secretkey', 'ct_stripe_publishablekey','ct_authorizenet_status','ct_authorizenet_API_login_ID','ct_authorizenet_transaction_key','ct_authorize_sandbox_mode','ct_client_email_appointment_approved_by_service_provider_status', 'ct_client_email_appointment_rejected_by_service_provider_status', 'ct_client_email_appointment_cancelled_by_you_status', 'ct_client_email_appointment_cancelled_by_service_provider_status', 'ct_client_email_appointment_completed_status', 'ct_client_email_appointment_request_status', 'ct_client_email_appointment_reminder_status', 'ct_client_email_appointment_marked_as_no_show_status', 'ct_admin_email_new_appointment_request_requires_approval_status', 'ct_admin_email_appointment_approved_status', 'ct_admin_email_appointment_cancelled_by_customer_status', 'ct_admin_email_appointment_rejected_status', 'ct_admin_email_appointment_cancelled_status', 'ct_admin_email_admin_appointment_marked_as_no_show_status', 'ct_admin_email_appointment_reminder_status', 'ct_admin_email_appointment_completed_with_client_status', 'ct_admin_email_notification_status', 'ct_staff_email_notification_status', 'ct_client_email_notification_status', 'ct_email_sender_name', 'ct_email_sender_address', 'ct_email_appointment_reminder_buffer', 'ct_sms_service_status', 'ct_sms_twilio_account_SID', 'ct_sms_twilio_auth_token', 'ct_sms_twilio_sender_number', 'ct_sms_twilio_send_sms_to_service_provider_status', 'ct_sms_twilio_send_sms_to_client_status', 'ct_sms_twilio_send_sms_to_admin_status', 'ct_sms_twilio_admin_phone_number', 'ct_sms_template_admin_notification', 'ct_sms_template_service_provider', 'ct_sms_template_client_notification','ct_sms_nexmo_status','ct_nexmo_api_key','ct_nexmo_api_secret','ct_nexmo_from','ct_nexmo_status','ct_sms_nexmo_send_sms_to_client_status','ct_sms_nexmo_send_sms_to_admin_status','ct_sms_nexmo_admin_phone_number', 'ct_client_sms_approved_by_provider', 'ct_client_sms_rejected_by_provider', 'ct_client_sms_cancel_by_you', 'ct_client_sms_cancelled_by_provider', 'ct_client_sms_appointment_completed', 'ct_client_sms_appointment_request', 'ct_client_sms_appointment_reminder', 'ct_client_sms_appoitment_marked_as_no_show', 'ct_admin_client_new_appointment_request_requires_approval', 'ct_admin_client_new_appointment_approved', 'ct_admin_client_appointment_cancelled_by_customer', 'ct_admin_client_appointment_rejected', 'ct_admin_client_appointment_cancelled', 'ct_admin_client_appointment_marked_as_no_show', 'ct_admin_client_appointment_reminder', 'ct_admin_client_appointment_reminder', 'ct_admin_client_appointment_completed_with_client', 'ct_label_choose_service1', 'ct_label_choose_service2', 'ct_label_your_appointments', 'ct_label_total', 'ct_email', 'ct_password', 'ct_firstname', 'ct_lastname', 'ct_phonenumber', 'ct_gender', 'ct_age', 'ct_postcode', 'ct_streetaddress', 'ct_town_city', 'ct_state', 'ct_country', 'ct_skype', 'ct_notes', 'ct_manager_dashboard', 'ct_manager_appointment', 'ct_manager_location', 'ct_manager_services', 'ct_manager_staff', 'ct_manager_customers', 'ct_manager_payments', 'ct_manager_main_settings', 'ct_manager_company_setting', 'ct_manager_general_setting', 'ct_manager_appearance_setting', 'ct_manager_payment_setting', 'ct_manager_email_notification_setting', 'ct_manager_email_template_setting', 'ct_manager_sms_notification_setting', 'ct_manager_sms_template_setting', 'ct_manager_label_setting', 'ct_manager_manage_form_field_setting', 'ct_manager_custom_form_field_setting', 'ct_manager_promocode_setting', 'ct_manager_manager_capability_setting', 'ct_manager_export_setting', 'ct_manager_notification','ct_front_tool_tips_status','ct_front_tool_tips_my_bookings','ct_front_tool_tips_postal_code','ct_front_tool_tips_services','ct_front_tool_tips_addons_services','ct_front_tool_tips_frequently_discount','ct_front_tool_tips_time_slots','ct_front_tool_tips_personal_details','ct_front_tool_tips_promocode','ct_front_tool_payment_method','ct_bank_transfer_status','ct_phone_display_country_code','ct_smtp_authetication','ct_smtp_encryption','ct_bf_first_name','ct_bf_last_name','ct_bf_email','ct_bf_password','ct_bf_phone','ct_bf_address','ct_bf_zip_code','ct_bf_city','ct_bf_state','ct_bf_notes','ct_front_language_selection_dropdown','ct_calculation_policy','ct_appointment_details_section','ct_appointment_details_display','ct_recurrence_booking_status','ct_recurrence_booking_type','ct_gc_status','ct_gc_id','ct_gc_client_id','ct_gc_client_secret','ct_gc_status_configure','ct_gc_status_sync_configure','ct_gc_token','ct_gc_frontend_url','ct_gc_admin_url','ct_payway_status','ct_payway_publishable_key','ct_payway_secure_key','ct_payway_purchase_status','ct_star_show_on_front','ct_show_time_duration','ct_sms_twilio_send_sms_to_staff_status','ct_sms_plivo_send_sms_to_staff_status','ct_sms_nexmo_send_sms_to_staff_status','ct_sms_textlocal_send_sms_to_staff_status','ct_referral_status','ct_referral_type','ct_referral_value','ct_special_days_status','ct_special_days','ct_special_days_title','ct_special_days_value','ct_special_day_color','ct_refs_type','ct_refs_value','ct_special_type','ct_service_design','ct_show_referral_input_on_checkout','ct_booking_page_design','ct_wallet_section', 'ct_google_api_key','ct_minimum_booking_price','ct_sms_messagebird_status','ct_sms_messagebird_account_apikey','ct_sms_messagebird_send_sms_to_client_status','ct_sms_messagebird_send_sms_to_admin_status','ct_sms_messagebird_send_sms_to_staff_status','ct_sms_messagebird_admin_phone','ct_limit_booking_time_slot','ct_booking_time_slot_limit','ct_xero_status','ct_xero_client_ID','ct_xero_client_secret','ct_xero_company_name','ct_additional_slot_time','ct_staff_registration','ct_staff_zipcode');
		foreach ($Allsettings as $settingname) {
			$this->$settingname = $this->get_option($settingname);
		}
  }
	/* Function for Read One Settings */
	public function readone(){
		$query = "select * from `" . $this->table_name . "` where `id`='" . $this->option_id . "'";
		$result = mysqli_query($this->conn, $query);
		$value = mysqli_fetch_row($result);
		return $value;
	}
	/* Function for Update Settings */
	public function set_option($option_name, $option_value){
		$this->option_name = $option_name;
		if($option_name == "ct_front_desc"){
			$this->option_value = mysqli_real_escape_string($this->conn, $option_value);
		}else{
			$this->option_value = $option_value;
		}
		$query = "update `" . $this->table_name . "` set `option_value`='" . $this->option_value . "' where `option_name`='" . $this->option_name . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function set_access_token($option_value){
    $ct_qb_session_access_token = mysqli_real_escape_string($this->conn, $option_value);
    // var_dump($ct_qb_session_access_token);die;
    $query = "UPDATE ct_settings SET option_value='".$ct_qb_session_access_token."' WHERE option_name='ct_qb_session_access_token'";
    $result = mysqli_query($this->conn, $query);
    return $result;
  }
	public function set_staff_option($option_name, $option_value, $staff_id){
		$query = "select * from `ct_staff_gc` where `staff_id`='".$staff_id."'";
		$result = mysqli_query($this->conn, $query);
		$ress = mysqli_num_rows($result);
		if($ress>0){
			$query = "update `ct_staff_gc` set `".$option_name."` = '".$option_value."' where `staff_id`='".$staff_id."'";
			$result = mysqli_query($this->conn, $query);
			return $result;
		}else{
			$query = "insert into `ct_staff_gc` (`".$option_name."`, `staff_id`) VALUES ('".$option_value."', '".$staff_id."')";
			$result = mysqli_query($this->conn, $query);
			return $result;
		}
	}
	public function set_option_postal($option_value){
		$this->option_name = 'ct_postal_code';
		$this->option_value = $option_value;
		$query = "update `" . $this->table_name . "` set `postalcode`='" . $this->option_value . "' where `option_name`='" . $this->option_name . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function get_option($option_name){
		$this->option_name = $option_name;
		$query = "select `option_value` from `" . $this->table_name . "` where `option_name`='" . $this->option_name . "'";
		$result = mysqli_query($this->conn, $query);
		$ress = mysqli_fetch_row($result);
		return @$ress[0];
	}
	public function get_staff_option($option_name,$staff_id){
		$query = "select `".$option_name."` from `ct_staff_gc` where `staff_id`='".$staff_id."';";
		$result = mysqli_query($this->conn, $query);
		$ress = @mysqli_fetch_row($result);
		return @$ress[0];
	}
	public function get_option_postal(){
		$this->option_name = 'ct_postal_code';
		$query = "select `postalcode` from `" . $this->table_name . "` where `option_name`='" . $this->option_name . "'";
		$result = mysqli_query($this->conn, $query);
		$ress = @mysqli_fetch_row($result);
		return @$ress[0];
	}
	public function chk_pc()
	{
		include_once(dirname(__FILE__) . "/class_connection.php");
		$con = new cleanto_db();
		$conn = $con->connect();

		$client_name_nonwwww = str_replace('www.', '', $_SERVER['SERVER_NAME']);
		$client_name_www = 'www.' . $client_name_nonwwww;

		$chkquery = "select * from ct_order_client_info where order_id='0' and (client_name='" . $client_name_nonwwww . "' or client_name='" . $client_name_www . "') ";
		$result = mysqli_query($conn, $chkquery);
		$resultr = mysqli_fetch_row($result);
		if (mysqli_num_rows($result) == 0) {
			$filename = '../config.php';
			if (file_exists($filename) && date("d", filemtime($filename)) == date("d")) {
				include_once(dirname(dirname(__FILE__)) . '/config.php');
				$tt = new cleanto_myvariable();
				$pc = $tt->epcode;
				$posturl = str_rot13('uggc://jjj.fxlzbbaynof.pbz/pyrnagb/purpx_chepunfr_pbqr.cuc');
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_URL, $posturl);
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, "purchase_code=" . $_SERVER['SERVER_NAME'] . "$$" . $pc);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

				$resultd = 'Valid';
				if ($resultd == 'Valid') {
					$order_insert_query = "insert into ct_order_client_info set order_id='0',client_name='" . $_SERVER['SERVER_NAME'] . "'";
					mysqli_query($conn, $order_insert_query);
					echo "Your copy of Cleanto is activated now!";
				} else {
					echo "Your copy of Cleanto is not registered, Please use correct Envato Purchase code to activate it.";
				}
				curl_close($ch);
			} else {
				echo "Your copy of Cleanto is not activated, Please use correct Envato Purchase code to activate it.";
			}
			die;
		}
	}
	public function get_all_languages(){
		$query = "select * from `" . $this->table_language."`";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function count_lang(){
		$query = "select count(`id`) as `c` from `" . $this->table_language."`";
		$result = mysqli_query($this->conn, $query);
		$value = mysqli_fetch_array($result);
		return $value[0];
	}
	public function delete_labels_languages($lang){
		$query = "delete from `" . $this->table_language . "` where `language`='" . $lang . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_labels_languages($language_front_arr,$language_admin_arr,$language_error_arr,$language_extra_arr,$language_front_error_arr, $language){
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`) values(NULL,'" . $language_front_arr . "','" . $language . "','" . $language_admin_arr . "','" . $language_error_arr . "','" . $language_extra_arr . "','" . $language_front_error_arr . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function chk_epc($settings,$conn){ 
		echo "verified";
	}
	public function chk_addext($settings,$conn){ 
	 eval(base64_decode(''));
	}
	public function insert_front_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $language_arr . "','" . $language . "','" . $dafault_en_labels[3] . "','" . $dafault_en_labels[4] . "','" . $dafault_en_labels[5] . "','" . $dafault_en_labels[6] . "','" . $dafault_en_labels[8] . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_admin_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $dafault_en_labels[1] . "','" . $language . "','" . $language_arr . "','" . $dafault_en_labels[4] . "','" . $dafault_en_labels[5] . "','" . $dafault_en_labels[6] . "','" . $dafault_en_labels[8] . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_error_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $dafault_en_labels[1] . "','" . $language . "','" . $dafault_en_labels[3] . "','" . $language_arr . "','" . $dafault_en_labels[5] . "','" . $dafault_en_labels[6] . "','" . $dafault_en_labels[8] . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_extra_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $dafault_en_labels[1] . "','" . $language . "','" . $dafault_en_labels[3] . "','" . $dafault_en_labels[4] . "','" . $language_arr . "','" . $dafault_en_labels[6] . "','" . $dafault_en_labels[8] . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_ferror_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $dafault_en_labels[1] . "','" . $language . "','" . $dafault_en_labels[3] . "','" . $dafault_en_labels[4] . "','" . $dafault_en_labels[5] . "','" . $language_arr . "','" . $dafault_en_labels[8] . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function insert_app_labels_languages($language_arr, $language){
		$dafault_en_labels = $this->get_all_labelsbyid("en");
		$query = "insert into `" . $this->table_language . "` (`id`,`label_data`,`language`, `admin_labels`, `error_labels`, `extra_labels`, `front_error_labels`, `app_labels`) values(NULL,'" . $dafault_en_labels[1] . "','" . $language . "','" . $dafault_en_labels[3] . "','" . $dafault_en_labels[4] . "','" . $dafault_en_labels[5] . "','" . $dafault_en_labels[6] . "','" . $language_arr . "')";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function update_labels_languages($language_front_arr,$language_admin_arr,$language_error_arr,$language_extra_arr,$language_front_error_arr, $id){
		$query = "update `" . $this->table_language . "` set `label_data` = '".$language_front_arr."', `admin_labels` = '".$language_admin_arr."', `error_labels` = '".$language_error_arr."', `extra_labels` = '".$language_extra_arr."', `front_error_labels` = '".$language_front_error_arr."' where `id` = '".$id."'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function update_labels_languages_per_tab($lable_field, $language_arr, $language){
		$query = "update `" . $this->table_language . "` set `".$lable_field."` = '".$language_arr."' where `language` = '".$language."'";
		$result = mysqli_query($this->conn, $query);
		return $result;
	}
	public function check_for_existing_language($language){
		$query = "select * from `" . $this->table_language . "` where `language` = '".$language."'";
		$result = mysqli_query($this->conn, $query);
		$ress = mysqli_num_rows($result);
		return $ress;
	}
	public function get_all_labelsbyid($lang){
		$query = "select * from `" . $this->table_language . "` where `language`='" . $lang . "'";
		$result = mysqli_query($this->conn, $query);
		$ress = mysqli_fetch_array($result);
		return $ress;
	}
	public function get_all_labelsbyid_from_id($id){
		$query = "select * from `" . $this->table_language . "` where `id`='" . $id . "'";
		$result = mysqli_query($this->conn, $query);
		$ress = mysqli_fetch_array($result);
		return $ress;
	}
	public function slugify($text){
	  /*  replace non letter or digits by - */
	  $text = preg_replace('~[^\pL\d]+~u', '-', $text);
	  /* transliterate */
	  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
	  /* remove unwanted characters */
	  $text = preg_replace('~[^-\w]+~', '', $text);
	  /* trim */
	  $text = trim($text, '-');
	  /*  remove duplicate - */
	  $text = preg_replace('~-+~', '-', $text);
	  /*  lowercase */
	  $text = strtolower($text);
	  if (empty($text)) {
			return 'n-a';
	  }
	  return $text;
	}
	function get_client_ip() {
		$ipaddress = '';
		if (getenv('HTTP_CLIENT_IP'))
			$ipaddress = getenv('HTTP_CLIENT_IP');
		elseif(getenv('HTTP_X_FORWARDED_FOR'))
			$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
		elseif(getenv('HTTP_X_FORWARDED'))
			$ipaddress = getenv('HTTP_X_FORWARDED');
		elseif(getenv('HTTP_FORWARDED_FOR'))
			$ipaddress = getenv('HTTP_FORWARDED_FOR');
		elseif(getenv('HTTP_FORWARDED'))
		   $ipaddress = getenv('HTTP_FORWARDED');
		elseif(getenv('REMOTE_ADDR'))
			$ipaddress = getenv('REMOTE_ADDR');
		else
			$ipaddress = 'UNKNOWN';
		return $ipaddress;
	}
	function get_contents($url){
		$ch = curl_init();
		curl_setopt ($ch, CURLOPT_URL, $url);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
		$contents = curl_exec($ch);
		if (curl_errno($ch)) {
		  $contents = '';
		} else {
		  curl_close($ch);
		}
		if (!is_string($contents) || !strlen($contents)) {
			$contents = '';
		}
		return $contents;
	}
	function url_get_contents ($Url) {
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $Url);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 50000);
		curl_setopt ($ch, CURLOPT_TIMEOUT, 50000);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$output = curl_exec($ch);
		curl_close($ch);
		return $output;
	}
	function ext_get_contents($url){
		$ch = curl_init();
		curl_setopt ($ch, CURLOPT_URL, $url);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 50000);
		curl_setopt ($ch, CURLOPT_TIMEOUT, 50000);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
		$contents = curl_exec($ch);
		if (curl_errno($ch)) {
			$contents = '';
		} else {
			curl_close($ch);
		}
		if (!is_string($contents) || !strlen($contents)) {
			$contents = '';
		}
		return $contents;
	}
	function ext_check($extension){
		$ext_pstatus = "ct_".base64_encode($extension."_pstatus");
		$chk_pstatus_option = $this->get_option($ext_pstatus);
		
		$ext_pcode = "ct_".$extension."_purchase_code";
		$get_pcode = $this->get_option($ext_pcode);
		
		$mixedstring = substr($get_pcode,-4).'sm';
		$checkstring = base64_encode('valid'.$mixedstring);
		
		if($chk_pstatus_option != $checkstring){
			return false;
		}else{
			return true;
		}
	}
	/* Function for update special offer start */
	public function update_special_offer(){
		$query = "update `" . $this->table_name . "` set `option_value`='" . $this->option_value . "' where `option_name`='" . $this->option_name . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
  }
	public function set_option_check($option,$value){
		$result = mysqli_query($this->conn,"SELECT * FROM `" . $this->table_name . "` WHERE `option_name` = '$option'");
		if(mysqli_num_rows($result) > 0){
			$query = "update `" . $this->table_name . "` set `option_value`='" . $value . "' where `option_name`='" . $option . "'";
			$result = mysqli_query($this->conn, $query);
			return $result;
		}else{
			$result = mysqli_query($this->conn,"INSERT INTO `" . $this->table_name . "` (`id`, `option_name`, `option_value`,`postalcode`) VALUES (NULL, '".$option."', '".$value."','');");
			return $result;
		}
  }
	public function get_option_check($option, $value){
		$result = mysqli_query($this->conn,"SELECT * FROM `" . $this->table_name . "` WHERE `option_name` = '$option'");
		if(mysqli_num_rows($result) > 0){}else{
			$result = mysqli_query($this->conn,"INSERT INTO `" . $this->table_name . "` (`id`, `option_name`, `option_value`,`postalcode`) VALUES (NULL, '".$option."', '".$value."','');");
			return $result;
		}
	}
	public function update_languages($language_front_arr,$language_admin_arr,$language_error_arr,$language_extra_arr,$language_form_error_arr,$all){
		$update_default_lang = "UPDATE `ct_languages` set `label_data` = '".$language_front_arr."', `admin_labels` = '".$language_admin_arr."', `error_labels` = '".$language_error_arr."', `extra_labels` = '".$language_extra_arr."', `front_error_labels` = '".$language_form_error_arr."' where `language` = '".$all."'";
		mysqli_query($this->conn, $update_default_lang);
	}
	public function language_label_status(){
		$query = "update `" . $this->table_language . "` set `language_status`='" . $this->language_status . "' where `language`='" . $this->lang . "'";
		$result = mysqli_query($this->conn, $query);
		return $result;
  }
	public function get_lang($exist_lang){
		
		$query = "select * from `" . $this->table_language . "` where `language`='" . $exist_lang . "'";
		$result = mysqli_query($this->conn, $query);
		$value = mysqli_num_rows($result);
		return $value;
  }
  public function get_lang_en($eng){
	  //echo $eng;
		$query = "select * from `" . $this->table_language . "` where `language`='" . $eng . "'";
		$result = mysqli_query($this->conn, $query);
		$value = mysqli_fetch_array($result);
		return $value;
  }
  public function enter_lang()
  {
	  //echo $eng;
		$query = "INSERT INTO `" . $this->table_language . "` (`label_data`, `language`,`admin_labels`,`error_labels`,`extra_labels`,`front_error_labels`,`language_status`,`app_labels`) VALUES ('".$this->label_data."', '".$this->language."', '".$this->admin_labels."', '".$this->error_labels."', '".$this->extra_labels."', '".$this->front_error_labels."', '".$this->language_status."', '".$this->app_labels."')";
		$result = mysqli_query($this->conn, $query);
		return $result;
  }
  
  public function insert_special_offer()
  {
	  //echo $eng;
		$query = "INSERT INTO `ct_special_offer` (`coupon_value`, `coupon_date`,`coupon_type`,`special_text`) VALUES ('".$this->coupon_value."', '".$this->coupon_date."', '".$this->coupon_type."', '".$this->special_text."')";
		$result = mysqli_query($this->conn, $query);
		return $result;
  }
  
}
?>