diff --git a/post.php b/post.php index 988c9c7f..a3ea90ea 100644 --- a/post.php +++ b/post.php @@ -72,10 +72,10 @@ if(isset($_POST['edit_user'])){ $user_id = intval($_POST['user_id']); $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); - $new_password = $_POST['new_password']; + $new_password = trim($_POST['new_password']); $company = intval($_POST['company']); $level = intval($_POST['level']); - $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path'])); + $path = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path']))); if($_FILES['file']['tmp_name']!='') { //delete old avatar file @@ -111,8 +111,8 @@ if(isset($_POST['edit_profile'])){ $user_id = intval($_POST['user_id']); $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); - $new_password = $_POST['new_password']; - $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path'])); + $new_password = trim($_POST['new_password']); + $path = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path']))); if($_FILES['file']['tmp_name']!='') { //delete old avatar file @@ -259,16 +259,16 @@ if(isset($_POST['add_company'])){ if(isset($_POST['edit_company'])){ $company_id = intval($_POST['company_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_file_path'])); @@ -380,10 +380,10 @@ if(isset($_POST['verify'])){ if(isset($_POST['edit_general_settings'])){ - $config_api_key = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_api_key'])); + $config_api_key = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_api_key']))); $old_aes_key = $config_aes_key; - $config_aes_key = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_aes_key'])); - $config_base_url = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_base_url'])); + $config_aes_key = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_aes_key']))); + $config_base_url = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_base_url']))); mysqli_query($mysqli,"UPDATE settings SET config_api_key = '$config_api_key', config_aes_key = '$config_aes_key', config_base_url = '$config_base_url' WHERE company_id = $session_company_id"); @@ -411,12 +411,12 @@ if(isset($_POST['edit_general_settings'])){ if(isset($_POST['edit_mail_settings'])){ - $config_smtp_host = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_host'])); + $config_smtp_host = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_host']))); $config_smtp_port = intval($_POST['config_smtp_port']); - $config_smtp_username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_username'])); - $config_smtp_password = mysqli_real_escape_string($mysqli,$_POST['config_smtp_password']); - $config_mail_from_email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_email'])); - $config_mail_from_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_name'])); + $config_smtp_username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_username']))); + $config_smtp_password = trim(mysqli_real_escape_string($mysqli,$_POST['config_smtp_password'])); + $config_mail_from_email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_email']))); + $config_mail_from_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_name']))); mysqli_query($mysqli,"UPDATE settings SET config_smtp_host = '$config_smtp_host', config_smtp_port = $config_smtp_port, config_smtp_username = '$config_smtp_username', config_smtp_password = '$config_smtp_password', config_mail_from_email = '$config_mail_from_email', config_mail_from_name = '$config_mail_from_name' WHERE company_id = $session_company_id"); @@ -472,14 +472,14 @@ if(isset($_POST['test_email'])){ if(isset($_POST['edit_invoice_quote_settings'])){ - $config_invoice_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_prefix'])); + $config_invoice_prefix = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_prefix']))); $config_invoice_next_number = intval($_POST['config_invoice_next_number']); - $config_invoice_footer = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_footer'])); - $config_recurring_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_recurring_prefix'])); + $config_invoice_footer = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_footer']))); + $config_recurring_prefix = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_recurring_prefix']))); $config_recurring_next_number = intval($_POST['config_recurring_next_number']); - $config_quote_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_quote_prefix'])); + $config_quote_prefix = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_quote_prefix']))); $config_quote_next_number = intval($_POST['config_quote_next_number']); - $config_quote_footer = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_quote_footer'])); + $config_quote_footer = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_quote_footer']))); mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_invoice_footer = '$config_invoice_footer', config_recurring_prefix = '$config_recurring_prefix', config_recurring_next_number = $config_recurring_next_number, config_quote_prefix = '$config_quote_prefix', config_quote_next_number = $config_quote_next_number, config_quote_footer = '$config_quote_footer' WHERE company_id = $session_company_id"); @@ -494,7 +494,7 @@ if(isset($_POST['edit_invoice_quote_settings'])){ if(isset($_POST['edit_ticket_settings'])){ - $config_ticket_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_ticket_prefix'])); + $config_ticket_prefix = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_ticket_prefix']))); $config_ticket_next_number = intval($_POST['config_ticket_next_number']); mysqli_query($mysqli,"UPDATE settings SET config_ticket_prefix = '$config_ticket_prefix', config_ticket_next_number = $config_ticket_next_number WHERE company_id = $session_company_id"); @@ -510,12 +510,12 @@ if(isset($_POST['edit_ticket_settings'])){ if(isset($_POST['edit_default_settings'])){ - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $expense_account = intval($_POST['expense_account']); $payment_account = intval($_POST['payment_account']); - $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); - $expense_payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_payment_method'])); + $payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']))); + $expense_payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_payment_method']))); $transfer_from_account = intval($_POST['transfer_from_account']); $transfer_to_account = intval($_POST['transfer_to_account']); $calendar = intval($_POST['calendar']); @@ -554,8 +554,8 @@ if(isset($_POST['edit_alert_settings'])){ if(isset($_POST['edit_online_payment_settings'])){ $config_stripe_enable = intval($_POST['config_stripe_enable']); - $config_stripe_publishable = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_stripe_publishable'])); - $config_stripe_secret = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_stripe_secret'])); + $config_stripe_publishable = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_stripe_publishable']))); + $config_stripe_secret = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_stripe_secret']))); mysqli_query($mysqli,"UPDATE settings SET config_stripe_enable = $config_stripe_enable, config_stripe_publishable = '$config_stripe_publishable', config_stripe_secret = '$config_stripe_secret' WHERE company_id = $session_company_id"); @@ -674,23 +674,23 @@ if(isset($_GET['download_database'])){ if(isset($_POST['add_client'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); - $contact = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); + $contact = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); $mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral'])); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $referral = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral']))); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $net_terms = intval($_POST['net_terms']); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id"); @@ -712,23 +712,23 @@ if(isset($_POST['add_client'])){ if(isset($_POST['edit_client'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); - $contact = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); + $contact = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); $mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral'])); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $referral = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral']))); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $net_terms = intval($_POST['net_terms']); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id"); @@ -820,8 +820,8 @@ if(isset($_GET['delete_client'])){ if(isset($_POST['add_calendar'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $color = strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color']))); mysqli_query($mysqli,"INSERT INTO calendars SET calendar_name = '$name', calendar_color = '$color', calendar_created_at = NOW(), company_id = $session_company_id"); @@ -837,10 +837,10 @@ if(isset($_POST['add_calendar'])){ if(isset($_POST['add_event'])){ $calendar_id = intval($_POST['calendar']); - $title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])); - $start = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start'])); - $end = strip_tags(mysqli_real_escape_string($mysqli,$_POST['end'])); - $repeat = strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat'])); + $title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']))); + $start = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['start']))); + $end = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['end']))); + $repeat = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat']))); $client = intval($_POST['client']); $email_event = intval($_POST['email_event']); @@ -915,10 +915,10 @@ if(isset($_POST['edit_event'])){ $event_id = intval($_POST['event_id']); $calendar_id = intval($_POST['calendar']); - $title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])); - $start = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start'])); - $end = strip_tags(mysqli_real_escape_string($mysqli,$_POST['end'])); - $repeat = strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat'])); + $title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']))); + $start = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['start']))); + $end = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['end']))); + $repeat = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat']))); $client = intval($_POST['client']); $email_event = intval($_POST['email_event']); @@ -1006,9 +1006,9 @@ if(isset($_GET['delete_event'])){ if(isset($_POST['add_ticket'])){ $client_id = intval($_POST['client']); - $subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject'])); - $priority = strip_tags(mysqli_real_escape_string($mysqli,$_POST['priority'])); - $details = mysqli_real_escape_string($mysqli,$_POST['details']); + $subject = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']))); + $priority = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['priority']))); + $details = trim(mysqli_real_escape_string($mysqli,$_POST['details'])); //Get the next Ticket Number and add 1 for the new ticket number $ticket_number = $config_ticket_next_number; @@ -1029,9 +1029,9 @@ if(isset($_POST['add_ticket'])){ if(isset($_POST['edit_ticket'])){ $ticket_id = intval($_POST['ticket_id']); - $subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject'])); - $priority = strip_tags(mysqli_real_escape_string($mysqli,$_POST['priority'])); - $details = mysqli_real_escape_string($mysqli,$_POST['details']); + $subject = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']))); + $priority = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['priority']))); + $details = trim(mysqli_real_escape_string($mysqli,$_POST['details'])); mysqli_query($mysqli,"UPDATE tickets SET ticket_subject = '$subject', ticket_priority = '$priority', ticket_details = '$details', ticket_updated_at = NOW() WHERE ticket_id = $ticket_id AND company_id = $session_company_id"); @@ -1061,7 +1061,7 @@ if(isset($_GET['delete_ticket'])){ if(isset($_POST['add_ticket_update'])){ $ticket_id = intval($_POST['ticket_id']); - $ticket_update = mysqli_real_escape_string($mysqli,$_POST['ticket_update']); + $ticket_update = trim(mysqli_real_escape_string($mysqli,$_POST['ticket_update'])); mysqli_query($mysqli,"INSERT INTO ticket_updates SET ticket_update = '$ticket_update', ticket_update_created_at = NOW(), user_id = $session_user_id, ticket_id = $ticket_id, company_id = $session_company_id") or die(mysqli_error($mysqli)); @@ -1092,20 +1092,20 @@ if(isset($_GET['close_ticket'])){ if(isset($_POST['add_vendor'])){ $client_id = intval($_POST['client_id']); //Used if this vendor is under a contact otherwise its 0 for under company - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $account_number = strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); - $contact_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $account_number = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); + $contact_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO vendors SET vendor_name = '$name', vendor_description = '$description', vendor_country = '$country', vendor_address = '$address', vendor_city = '$city', vendor_state = '$state', vendor_zip = '$zip', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); @@ -1123,20 +1123,20 @@ if(isset($_POST['add_vendor'])){ if(isset($_POST['edit_vendor'])){ $vendor_id = intval($_POST['vendor_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $account_number = strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); - $contact_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $account_number = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['account_number']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); + $contact_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact_name']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"UPDATE vendors SET vendor_name = '$name', vendor_description = '$description', vendor_country = '$country', vendor_address = '$address', vendor_city = '$city', vendor_state = '$state', vendor_zip = '$zip', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_updated_at = NOW() WHERE vendor_id = $vendor_id AND company_id = $session_company_id"); @@ -1179,8 +1179,8 @@ if(isset($_GET['delete_vendor'])){ if(isset($_POST['add_product'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $cost = floatval($_POST['cost']); $category = intval($_POST['category']); $tax = intval($_POST['tax']); @@ -1199,8 +1199,8 @@ if(isset($_POST['add_product'])){ if(isset($_POST['edit_product'])){ $product_id = intval($_POST['product_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $cost = floatval($_POST['cost']); $category = intval($_POST['category']); $tax = intval($_POST['tax']); @@ -1232,12 +1232,12 @@ if(isset($_GET['delete_product'])){ if(isset($_POST['add_trip'])){ - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); - $source = strip_tags(mysqli_real_escape_string($mysqli,$_POST['source'])); - $destination = strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); + $source = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['source']))); + $destination = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination']))); $miles = floatval($_POST['miles']); $roundtrip = intval($_POST['roundtrip']); - $purpose = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose'])); + $purpose = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose']))); $client_id = intval($_POST['client']); mysqli_query($mysqli,"INSERT INTO trips SET trip_date = '$date', trip_source = '$source', trip_destination = '$destination', trip_miles = $miles, round_trip = $roundtrip, trip_purpose = '$purpose', trip_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); @@ -1254,12 +1254,12 @@ if(isset($_POST['add_trip'])){ if(isset($_POST['edit_trip'])){ $trip_id = intval($_POST['trip_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); - $source = strip_tags(mysqli_real_escape_string($mysqli,$_POST['source'])); - $destination = strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); + $source = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['source']))); + $destination = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination']))); $miles = floatval($_POST['miles']); $roundtrip = intval($_POST['roundtrip']); - $purpose = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose'])); + $purpose = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose']))); $client_id = intval($_POST['client']); mysqli_query($mysqli,"UPDATE trips SET trip_date = '$date', trip_source = '$source', trip_destination = '$destination', trip_miles = $miles, trip_purpose = '$purpose', round_trip = $roundtrip, trip_updated_at = NOW(), client_id = $client_id WHERE trip_id = $trip_id AND company_id = $session_company_id"); @@ -1289,10 +1289,10 @@ if(isset($_GET['delete_trip'])){ if(isset($_POST['add_account'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $opening_balance = floatval($_POST['opening_balance']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = '$opening_balance', account_currency_code = '$currency_code', account_notes = '$notes', account_created_at = NOW(), company_id = $session_company_id"); @@ -1308,8 +1308,8 @@ if(isset($_POST['add_account'])){ if(isset($_POST['edit_account'])){ $account_id = intval($_POST['account_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"UPDATE accounts SET account_name = '$name', account_notes = '$notes', account_updated_at = NOW() WHERE account_id = $account_id AND company_id = $session_company_id"); @@ -1352,9 +1352,9 @@ if(isset($_GET['delete_account'])){ if(isset($_POST['add_category'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $color = strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color']))); mysqli_query($mysqli,"INSERT INTO categories SET category_name = '$name', category_type = '$type', category_color = '$color', category_created_at = NOW(), company_id = $session_company_id"); @@ -1370,9 +1370,9 @@ if(isset($_POST['add_category'])){ if(isset($_POST['edit_category'])){ $category_id = intval($_POST['category_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $color = strip_tags(mysqli_real_escape_string($mysqli,$_POST['color'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $color = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['color']))); mysqli_query($mysqli,"UPDATE categories SET category_name = '$name', category_type = '$type', category_color = '$color', category_updated_at = NOW() WHERE category_id = $category_id AND company_id = $session_company_id"); @@ -1418,7 +1418,7 @@ if(isset($_GET['delete_category'])){ if(isset($_POST['add_tax'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $percent = floatval($_POST['percent']); mysqli_query($mysqli,"INSERT INTO taxes SET tax_name = '$name', tax_percent = $percent, tax_created_at = NOW(), company_id = $session_company_id"); @@ -1435,7 +1435,7 @@ if(isset($_POST['add_tax'])){ if(isset($_POST['edit_tax'])){ $tax_id = intval($_POST['tax_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $percent = floatval($_POST['percent']); mysqli_query($mysqli,"UPDATE taxes SET tax_name = '$name', tax_percent = $percent, tax_updated_at = NOW() WHERE tax_id = $tax_id AND company_id = $session_company_id"); @@ -1520,13 +1520,13 @@ if(isset($_GET['ack_all_alerts'])){ if(isset($_POST['add_expense'])){ - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); $account = intval($_POST['account']); $vendor = intval($_POST['vendor']); $category = intval($_POST['category']); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $reference = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']))); if($_FILES['file']['tmp_name']!='') { $path = "uploads/expenses/$session_company_id/"; @@ -1549,14 +1549,14 @@ if(isset($_POST['add_expense'])){ if(isset($_POST['edit_expense'])){ $expense_id = intval($_POST['expense_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); $account = intval($_POST['account']); $vendor = intval($_POST['vendor']); $category = intval($_POST['category']); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); - $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_receipt'])); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $reference = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']))); + $path = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_receipt']))); if($_FILES['file']['tmp_name']!='') { //remove old receipt @@ -1600,11 +1600,11 @@ if(isset($_GET['delete_expense'])){ if(isset($_POST['add_transfer'])){ - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); $account_from = intval($_POST['account_from']); $account_to = intval($_POST['account_to']); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$date', expense_amount = '$amount', expense_currency_code = '$config_default_currency', vendor_id = 0, category_id = 0, account_id = $account_from, expense_created_at = NOW(), company_id = $session_company_id"); $expense_id = mysqli_insert_id($mysqli); @@ -1628,11 +1628,11 @@ if(isset($_POST['edit_transfer'])){ $transfer_id = intval($_POST['transfer_id']); $expense_id = intval($_POST['expense_id']); $revenue_id = intval($_POST['revenue_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); $account_from = intval($_POST['account_from']); $account_to = intval($_POST['account_to']); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"UPDATE expenses SET expense_date = '$date', expense_amount = '$amount', account_id = $account_from, expense_updated_at = NOW() WHERE expense_id = $expense_id AND company_id = $session_company_id"); @@ -1675,10 +1675,10 @@ if(isset($_GET['delete_transfer'])){ if(isset($_POST['add_invoice'])){ $client = intval($_POST['client']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); //Get Net Terms $sql = mysqli_query($mysqli,"SELECT client_net_terms FROM clients WHERE client_id = $client AND company_id = $session_company_id"); @@ -1709,11 +1709,11 @@ if(isset($_POST['add_invoice'])){ if(isset($_POST['edit_invoice'])){ $invoice_id = intval($_POST['invoice_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); - $due = strip_tags(mysqli_real_escape_string($mysqli,$_POST['due'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); + $due = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['due']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); mysqli_query($mysqli,"UPDATE invoices SET invoice_scope = '$scope', invoice_date = '$date', invoice_due = '$due', invoice_currency_code = '$currency_code', invoice_updated_at = NOW(), category_id = $category WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); @@ -1729,7 +1729,7 @@ if(isset($_POST['edit_invoice'])){ if(isset($_POST['add_invoice_copy'])){ $invoice_id = intval($_POST['invoice_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); //Get Net Terms $sql = mysqli_query($mysqli,"SELECT client_net_terms FROM clients, invoices WHERE clients.client_id = invoices.client_id AND invoices.invoice_id = $invoice_id AND invoices.company_id = $session_company_id"); @@ -1785,7 +1785,7 @@ if(isset($_POST['add_invoice_copy'])){ if(isset($_POST['add_invoice_recurring'])){ $invoice_id = intval($_POST['invoice_id']); - $recurring_frequency = strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency'])); + $recurring_frequency = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency']))); $sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql); @@ -1835,10 +1835,10 @@ if(isset($_POST['add_invoice_recurring'])){ if(isset($_POST['add_quote'])){ $client = intval($_POST['client']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); //Get the last Quote Number and add 1 for the new Quote number $quote_number = $config_quote_next_number; @@ -1866,7 +1866,7 @@ if(isset($_POST['add_quote'])){ if(isset($_POST['add_quote_copy'])){ $quote_id = intval($_POST['quote_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); //Get the last Invoice Number and add 1 for the new invoice number $quote_number = $config_quote_next_number; @@ -1918,7 +1918,7 @@ if(isset($_POST['add_quote_copy'])){ if(isset($_POST['add_quote_to_invoice'])){ $quote_id = intval($_POST['quote_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $client_net_terms = intval($_POST['client_net_terms']); $invoice_number = $config_invoice_next_number; @@ -1974,8 +1974,8 @@ if(isset($_POST['add_quote_item'])){ $quote_id = intval($_POST['quote_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $qty = floatval($_POST['qty']); $price = floatval($_POST['price']); $tax_id = intval($_POST['tax_id']); @@ -2013,7 +2013,7 @@ if(isset($_POST['add_quote_item'])){ if(isset($_POST['quote_note'])){ $quote_id = intval($_POST['quote_id']); - $note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['note'])); + $note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['note']))); mysqli_query($mysqli,"UPDATE quotes SET quote_note = '$note', quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id"); @@ -2026,10 +2026,10 @@ if(isset($_POST['quote_note'])){ if(isset($_POST['edit_quote'])){ $quote_id = intval($_POST['quote_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_currency_code = '$currency_code', category_id = $category, quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id"); @@ -2253,11 +2253,11 @@ if(isset($_GET['email_quote'])){ if(isset($_POST['add_recurring'])){ $client = intval($_POST['client']); - $frequency = strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency'])); - $start_date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start_date'])); + $frequency = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency']))); + $start_date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['start_date']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); //Get the last Recurring Number and add 1 for the new Recurring number $recurring_number = $config_recurring_next_number; @@ -2282,10 +2282,10 @@ if(isset($_POST['add_recurring'])){ if(isset($_POST['edit_recurring'])){ $recurring_id = intval($_POST['recurring_id']); - $frequency = strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency'])); + $frequency = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency']))); $category = intval($_POST['category']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $scope = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope']))); $status = intval($_POST['status']); mysqli_query($mysqli,"UPDATE recurring SET recurring_scope = '$scope', recurring_frequency = '$frequency', category_id = $category, recurring_status = $status, recurring_currency_code = '$currency_code', recurring_updated_at = NOW() WHERE recurring_id = $recurring_id AND company_id = $session_company_id"); @@ -2362,8 +2362,8 @@ if(isset($_GET['recurring_deactivate'])){ if(isset($_POST['add_recurring_item'])){ $recurring_id = intval($_POST['recurring_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $qty = floatval($_POST['qty']); $price = floatval($_POST['price']); $tax_id = intval($_POST['tax_id']); @@ -2401,7 +2401,7 @@ if(isset($_POST['add_recurring_item'])){ if(isset($_POST['recurring_note'])){ $recurring_id = intval($_POST['recurring_id']); - $note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['note'])); + $note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['note']))); mysqli_query($mysqli,"UPDATE recurring SET recurring_note = '$note', recurring_updated_at = NOW() WHERE recurring_id = $recurring_id AND company_id = $session_company_id"); @@ -2511,8 +2511,8 @@ if(isset($_GET['delete_invoice'])){ if(isset($_POST['add_invoice_item'])){ $invoice_id = intval($_POST['invoice_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $qty = floatval($_POST['qty']); $price = floatval($_POST['price']); $tax_id = intval($_POST['tax_id']); @@ -2551,7 +2551,7 @@ if(isset($_POST['add_invoice_item'])){ if(isset($_POST['invoice_note'])){ $invoice_id = intval($_POST['invoice_id']); - $note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['note'])); + $note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['note']))); mysqli_query($mysqli,"UPDATE invoices SET invoice_note = '$note', invoice_updated_at = NOW() WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); @@ -2567,8 +2567,8 @@ if(isset($_POST['edit_item'])){ $quote_id = intval($_POST['quote_id']); $recurring_id = intval($_POST['recurring_id']); $item_id = intval($_POST['item_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); $qty = floatval($_POST['qty']); $price = floatval($_POST['price']); $tax_id = intval($_POST['tax_id']); @@ -2653,12 +2653,12 @@ if(isset($_POST['add_payment'])){ $invoice_id = intval($_POST['invoice_id']); $balance = floatval($_POST['balance']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); $account = intval($_POST['account']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); - $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); - $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); + $payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']))); + $reference = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']))); $email_receipt = intval($_POST['email_receipt']); $base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']); @@ -2961,14 +2961,14 @@ if(isset($_GET['email_invoice'])){ if(isset($_POST['add_revenue'])){ - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $account = intval($_POST['account']); $category = intval($_POST['category']); - $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); + $payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $reference = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']))); mysqli_query($mysqli,"INSERT INTO revenues SET revenue_date = '$date', revenue_amount = '$amount', revenue_currency_code = '$currency_code', revenue_payment_method = '$payment_method', revenue_reference = '$reference', revenue_description = '$description', revenue_created_at = NOW(), category_id = $category, account_id = $account, company_id = $session_company_id"); @@ -2984,14 +2984,14 @@ if(isset($_POST['add_revenue'])){ if(isset($_POST['edit_revenue'])){ $revenue_id = intval($_POST['revenue_id']); - $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); + $date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']))); $amount = floatval($_POST['amount']); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $account = intval($_POST['account']); $category = intval($_POST['category']); - $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); - $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); - $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); + $payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']))); + $description = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']))); + $reference = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']))); mysqli_query($mysqli,"UPDATE revenues SET revenue_date = '$date', revenue_amount = '$amount', revenue_currency_code = '$currency_code', revenue_payment_method = '$payment_method', revenue_reference = '$reference', revenue_description = '$description', revenue_updated_at = NOW(), category_id = $category, account_id = $account WHERE revenue_id = $revenue_id AND company_id = $session_company_id"); @@ -3021,13 +3021,13 @@ if(isset($_GET['delete_revenue'])){ if(isset($_POST['add_contact'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); $mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); if(!file_exists("uploads/clients/$session_company_id/$client_id")) { mkdir("uploads/clients/$session_company_id/$client_id"); @@ -3055,13 +3055,13 @@ if(isset($_POST['edit_contact'])){ $contact_id = intval($_POST['contact_id']); $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $extension = preg_replace("/[^0-9]/", '',$_POST['extension']); $mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path'])); @@ -3118,15 +3118,15 @@ if(isset($_GET['delete_contact'])){ if(isset($_POST['add_location'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $hours = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); $contact = intval($_POST['contact']); if(!file_exists("uploads/clients/$session_company_id/$client_id")) { @@ -3154,15 +3154,15 @@ if(isset($_POST['add_location'])){ if(isset($_POST['edit_location'])){ $location_id = intval($_POST['location_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $hours = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); $contact = intval($_POST['contact']); $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_file_path'])); @@ -3206,34 +3206,34 @@ if(isset($_GET['delete_location'])){ if(isset($_POST['add_asset'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $make = strip_tags(mysqli_real_escape_string($mysqli,$_POST['make'])); - $model = strip_tags(mysqli_real_escape_string($mysqli,$_POST['model'])); - $serial = strip_tags(mysqli_real_escape_string($mysqli,$_POST['serial'])); - $os = strip_tags(mysqli_real_escape_string($mysqli,$_POST['os'])); - $ip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['ip'])); - $mac = strip_tags(mysqli_real_escape_string($mysqli,$_POST['mac'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $make = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['make']))); + $model = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['model']))); + $serial = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['serial']))); + $os = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['os']))); + $ip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['ip']))); + $mac = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['mac']))); $location = intval($_POST['location']); $vendor = intval($_POST['vendor']); $contact = intval($_POST['contact']); $network = intval($_POST['network']); - $purchase_date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase_date'])); + $purchase_date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase_date']))); if(empty($purchase_date)){ $purchase_date = "0000-00-00"; } - $warranty_expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['warranty_expire'])); + $warranty_expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['warranty_expire']))); if(empty($warranty_expire)){ $warranty_expire = "0000-00-00"; } - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO assets SET asset_name = '$name', asset_type = '$type', asset_make = '$make', asset_model = '$model', asset_serial = '$serial', asset_os = '$os', asset_ip = '$ip', asset_mac = '$mac', location_id = $location, vendor_id = $vendor, contact_id = $contact, asset_purchase_date = '$purchase_date', asset_warranty_expire = '$warranty_expire', asset_notes = '$notes', asset_created_at = NOW(), network_id = $network, client_id = $client_id, company_id = $session_company_id"); if(!empty($_POST['username'])) { $asset_id = mysqli_insert_id($mysqli); - $username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username'])); - $password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password'])); + $username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']))); + $password = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']))); mysqli_query($mysqli,"INSERT INTO logins SET login_name = '$name', login_username = '$username', login_password = AES_ENCRYPT('$password','$config_aes_key'), login_created_at = NOW(), asset_id = $asset_id, client_id = $client_id, company_id = $session_company_id"); @@ -3253,29 +3253,29 @@ if(isset($_POST['edit_asset'])){ $asset_id = intval($_POST['asset_id']); $login_id = intval($_POST['login_id']); $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $make = strip_tags(mysqli_real_escape_string($mysqli,$_POST['make'])); - $model = strip_tags(mysqli_real_escape_string($mysqli,$_POST['model'])); - $serial = strip_tags(mysqli_real_escape_string($mysqli,$_POST['serial'])); - $os = strip_tags(mysqli_real_escape_string($mysqli,$_POST['os'])); - $ip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['ip'])); - $mac = strip_tags(mysqli_real_escape_string($mysqli,$_POST['mac'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $make = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['make']))); + $model = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['model']))); + $serial = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['serial']))); + $os = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['os']))); + $ip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['ip']))); + $mac = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['mac']))); $location = intval($_POST['location']); $vendor = intval($_POST['vendor']); $contact = intval($_POST['contact']); $network = intval($_POST['network']); - $purchase_date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase_date'])); + $purchase_date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['purchase_date']))); if(empty($purchase_date)){ $purchase_date = "0000-00-00"; } - $warranty_expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['warranty_expire'])); + $warranty_expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['warranty_expire']))); if(empty($warranty_expire)){ $warranty_expire = "0000-00-00"; } - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); - $username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username'])); - $password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password'])); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); + $username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']))); + $password = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']))); mysqli_query($mysqli,"UPDATE assets SET asset_name = '$name', asset_type = '$type', asset_make = '$make', asset_model = '$model', asset_serial = '$serial', asset_os = '$os', asset_ip = '$ip', asset_mac = '$mac', location_id = $location, vendor_id = $vendor, contact_id = $contact, asset_purchase_date = '$purchase_date', asset_warranty_expire = '$warranty_expire', asset_notes = '$notes', asset_updated_at = NOW(), network_id = $network WHERE asset_id = $asset_id AND company_id = $session_company_id"); @@ -3320,7 +3320,7 @@ if(isset($_POST['add_login'])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $uri = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['uri']))); $username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']))); - $password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password'])); + $password = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']))); $note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['note']))); $vendor_id = intval($_POST['vendor']); $asset_id = intval($_POST['asset']); @@ -3340,11 +3340,11 @@ if(isset($_POST['add_login'])){ if(isset($_POST['edit_login'])){ $login_id = intval($_POST['login_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $uri = strip_tags(mysqli_real_escape_string($mysqli,$_POST['uri'])); - $username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username'])); - $password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password'])); - $note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['note'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $uri = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['uri']))); + $username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']))); + $password = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']))); + $note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['note']))); $vendor_id = intval($_POST['vendor']); $asset_id = intval($_POST['asset']); $software_id = intval($_POST['software']); @@ -3376,7 +3376,7 @@ if(isset($_GET['delete_login'])){ if(isset($_POST['add_file'])){ $client_id = intval($_POST['client_id']); - $new_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['new_name'])); + $new_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['new_name']))); if(!file_exists("uploads/clients/$session_company_id/$client_id")) { mkdir("uploads/clients/$session_company_id/$client_id"); @@ -3426,8 +3426,8 @@ if(isset($_GET['delete_file'])){ if(isset($_POST['add_document'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $details = mysqli_real_escape_string($mysqli,$_POST['details']); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $details = trim(mysqli_real_escape_string($mysqli,$_POST['details'])); mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_details = '$details', document_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); @@ -3443,8 +3443,8 @@ if(isset($_POST['add_document'])){ if(isset($_POST['edit_document'])){ $document_id = intval($_POST['document_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $details = mysqli_real_escape_string($mysqli,$_POST['details']); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $details = trim(mysqli_real_escape_string($mysqli,$_POST['details'])); mysqli_query($mysqli,"UPDATE documents SET document_name = '$name', document_details = '$details', document_updated_at = NOW() WHERE document_id = $document_id AND company_id = $session_company_id"); @@ -3474,11 +3474,11 @@ if(isset($_GET['delete_document'])){ if(isset($_POST['add_network'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $vlan = intval($_POST['vlan']); - $network = strip_tags(mysqli_real_escape_string($mysqli,$_POST['network'])); - $gateway = strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway'])); - $dhcp_range = strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range'])); + $network = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['network']))); + $gateway = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway']))); + $dhcp_range = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range']))); $location_id = intval($_POST['location']); mysqli_query($mysqli,"INSERT INTO networks SET network_name = '$name', network_vlan = $vlan, network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_created_at = NOW(), location_id = $location_id, client_id = $client_id, company_id = $session_company_id"); @@ -3495,11 +3495,11 @@ if(isset($_POST['add_network'])){ if(isset($_POST['edit_network'])){ $network_id = intval($_POST['network_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $vlan = intval($_POST['vlan']); - $network = strip_tags(mysqli_real_escape_string($mysqli,$_POST['network'])); - $gateway = strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway'])); - $dhcp_range = strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range'])); + $network = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['network']))); + $gateway = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['gateway']))); + $dhcp_range = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['dhcp_range']))); $location_id = intval($_POST['location']); mysqli_query($mysqli,"UPDATE networks SET network_name = '$name', network_vlan = $vlan, network = '$network', network_gateway = '$gateway', network_dhcp_range = '$dhcp_range', network_updated_at = NOW(), location_id = $location_id WHERE network_id = $network_id AND company_id = $session_company_id"); @@ -3530,10 +3530,10 @@ if(isset($_GET['delete_network'])){ if(isset($_POST['add_domain'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $registrar = intval($_POST['registrar']); $webhost = intval($_POST['webhost']); - $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])); + $expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']))); if(empty($expire)){ $expire = "0000-00-00"; } @@ -3552,10 +3552,10 @@ if(isset($_POST['add_domain'])){ if(isset($_POST['edit_domain'])){ $domain_id = intval($_POST['domain_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); $registrar = intval($_POST['registrar']); $webhost = intval($_POST['webhost']); - $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])); + $expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']))); if(empty($expire)){ $expire = "0000-00-00"; } @@ -3588,10 +3588,10 @@ if(isset($_GET['delete_domain'])){ if(isset($_POST['add_certificate'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $domain = strip_tags(mysqli_real_escape_string($mysqli,$_POST['domain'])); - $issued_by = strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by'])); - $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $domain = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['domain']))); + $issued_by = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by']))); + $expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']))); if(empty($expire)){ $expire = "0000-00-00"; } @@ -3610,10 +3610,10 @@ if(isset($_POST['add_certificate'])){ if(isset($_POST['edit_certificate'])){ $certificate_id = intval($_POST['certificate_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $domain = strip_tags(mysqli_real_escape_string($mysqli,$_POST['domain'])); - $issued_by = strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by'])); - $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $domain = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['domain']))); + $issued_by = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by']))); + $expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']))); if(empty($expire)){ $expire = "0000-00-00"; } @@ -3646,10 +3646,10 @@ if(isset($_GET['delete_certificate'])){ if(isset($_POST['add_software'])){ $client_id = intval($_POST['client_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $license = strip_tags(mysqli_real_escape_string($mysqli,$_POST['license'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $license = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_type = '$type', software_license = '$license', software_notes = '$notes', software_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); @@ -3675,12 +3675,12 @@ if(isset($_POST['edit_software'])){ $software_id = intval($_POST['software_id']); $login_id = intval($_POST['login_id']); - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $type = strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])); - $license = strip_tags(mysqli_real_escape_string($mysqli,$_POST['license'])); - $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); - $username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['username'])); - $password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['password'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type']))); + $license = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['license']))); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes']))); + $username = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['username']))); + $password = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['password']))); mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_type = '$type', software_license = '$license', software_notes = '$notes', software_updated_at = NOW() WHERE software_id = $software_id AND company_id = $session_company_id"); diff --git a/setup.php b/setup.php index 6166b089..b358ea97 100644 --- a/setup.php +++ b/setup.php @@ -152,8 +152,8 @@ if(isset($_POST['add_database'])){ if(isset($_POST['add_user'])){ - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $password = md5($_POST['password']); mysqli_query($mysqli,"INSERT INTO users SET name = '$name', email = '$email', password = '$password', created_at = NOW()"); @@ -183,16 +183,16 @@ if(isset($_POST['add_company_settings'])){ $row = mysqli_fetch_array($sql); $user_id = $row['user_id']; - $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); - $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); - $address = strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])); - $city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])); - $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); - $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); + $name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']))); + $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); + $address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address']))); + $city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']))); + $state = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']))); + $zip = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']))); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); - $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); + $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); + $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_logo = '$path', company_created_at = NOW()"); diff --git a/vendor/clipboard.js/.babelrc b/vendor/clipboard.js/.babelrc deleted file mode 100644 index 42e3867e..00000000 --- a/vendor/clipboard.js/.babelrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "presets": [["env", { - "targets": { - "uglify": true - } - }]] -} diff --git a/vendor/clipboard.js/.editorconfig b/vendor/clipboard.js/.editorconfig deleted file mode 100644 index 0f1d01bd..00000000 --- a/vendor/clipboard.js/.editorconfig +++ /dev/null @@ -1,22 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# http://editorconfig.org - -root = true - -[*] -# Change these settings to your own preference -indent_style = space -indent_size = 4 - -# We recommend you to keep these unchanged -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false - -[{package.json,bower.json}] -indent_size = 2 diff --git a/vendor/clipboard.js/.github/issue_template.md b/vendor/clipboard.js/.github/issue_template.md deleted file mode 100644 index 49389c36..00000000 --- a/vendor/clipboard.js/.github/issue_template.md +++ /dev/null @@ -1,15 +0,0 @@ -### Minimal example - -> Fork this [JSFiddle](https://jsfiddle.net/zenorocha/5kk0eysw/) and reproduce your issue. - -### Expected behaviour - -I thought that by going to the page '...' and pressing the button '...' then '...' would happen. - -### Actual behaviour - -Instead of '...', what I saw was that '...' happened instead. - -### Browsers affected - -I tested on all major browsers and only IE 11 does not work. diff --git a/vendor/clipboard.js/.gitignore b/vendor/clipboard.js/.gitignore deleted file mode 100644 index ff4dcd82..00000000 --- a/vendor/clipboard.js/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -lib -npm-debug.log -bower_components -node_modules -yarn-error.log -yarn.lock diff --git a/vendor/clipboard.js/.travis.yml b/vendor/clipboard.js/.travis.yml deleted file mode 100644 index a4bb7b94..00000000 --- a/vendor/clipboard.js/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -sudo: false -language: node_js -node_js: - - stable diff --git a/vendor/clipboard.js/bower.json b/vendor/clipboard.js/bower.json deleted file mode 100644 index f7da89c9..00000000 --- a/vendor/clipboard.js/bower.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "clipboard", - "version": "2.0.4", - "description": "Modern copy to clipboard. No Flash. Just 3kb", - "license": "MIT", - "main": "dist/clipboard.js", - "ignore": [ - "/.*/", - "/demo/", - "/test/", - "/.*", - "/bower.json", - "/karma.conf.js", - "/src", - "/lib" - ], - "keywords": [ - "clipboard", - "copy", - "cut" - ] -} diff --git a/vendor/clipboard.js/composer.json b/vendor/clipboard.js/composer.json deleted file mode 100644 index a712d5a2..00000000 --- a/vendor/clipboard.js/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "zenorocha/clipboardjs", - "description": "Modern copy to clipboard. No Flash. Just 3kb gzipped https://clipboardjs.com", - "type": "component", - "homepage": "https://clipboardjs.com/", - "authors": [ - { - "name": "Zeno Rocha", - "url": "http://zenorocha.com/" - } - ], - "require": { - "robloach/component-installer": "*" - }, - "extra": { - "component": { - "scripts": [ - "dist/clipboard.js" - ], - "files": [ - "dist/clipboard.min.js" - ] - } - } -} diff --git a/vendor/clipboard.js/contributing.md b/vendor/clipboard.js/contributing.md deleted file mode 100644 index 9ab2c8f7..00000000 --- a/vendor/clipboard.js/contributing.md +++ /dev/null @@ -1,28 +0,0 @@ -# Contributing guide - -Want to contribute to Clipboard.js? Awesome! -There are many ways you can contribute, see below. - -## Opening issues - -Open an issue to report bugs or to propose new features. - -- Reporting bugs: describe the bug as clearly as you can, including steps to reproduce, what happened and what you were expecting to happen. Also include browser version, OS and other related software's (npm, Node.js, etc) versions when applicable. - -- Proposing features: explain the proposed feature, what it should do, why it is useful, how users should use it. Give us as much info as possible so it will be easier to discuss, access and implement the proposed feature. When you're unsure about a certain aspect of the feature, feel free to leave it open for others to discuss and find an appropriate solution. - -## Proposing pull requests - -Pull requests are very welcome. Note that if you are going to propose drastic changes, be sure to open an issue for discussion first, to make sure that your PR will be accepted before you spend effort coding it. - -Fork the Clipboard.js repository, clone it locally and create a branch for your proposed bug fix or new feature. Avoid working directly on the master branch. - -Implement your bug fix or feature, write tests to cover it and make sure all tests are passing (run a final `npm test` to make sure everything is correct). Then commit your changes, push your bug fix/feature branch to the origin (your forked repo) and open a pull request to the upstream (the repository you originally forked)'s master branch. - -## Documentation - -Documentation is extremely important and takes a fair deal of time and effort to write and keep updated. Please submit any and all improvements you can make to the repository's docs. - -## Known issues -If you're using npm@3 you'll probably face some issues related to peerDependencies. -https://github.com/npm/npm/issues/9204 diff --git a/vendor/clipboard.js/demo/constructor-node.html b/vendor/clipboard.js/demo/constructor-node.html deleted file mode 100644 index 44b00599..00000000 --- a/vendor/clipboard.js/demo/constructor-node.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - constructor-node - - - - -
- Copy -
- - - - - - - - diff --git a/vendor/clipboard.js/demo/constructor-nodelist.html b/vendor/clipboard.js/demo/constructor-nodelist.html deleted file mode 100644 index ece98c63..00000000 --- a/vendor/clipboard.js/demo/constructor-nodelist.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - constructor-nodelist - - - - - - - - - - - - - - - diff --git a/vendor/clipboard.js/demo/constructor-selector.html b/vendor/clipboard.js/demo/constructor-selector.html deleted file mode 100644 index 7a5f8b1f..00000000 --- a/vendor/clipboard.js/demo/constructor-selector.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - constructor-selector - - - - - - - - - - - - - - - diff --git a/vendor/clipboard.js/demo/function-target.html b/vendor/clipboard.js/demo/function-target.html deleted file mode 100644 index a1aa1913..00000000 --- a/vendor/clipboard.js/demo/function-target.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - function-target - - - - - -
hello
- - - - - - - - diff --git a/vendor/clipboard.js/demo/function-text.html b/vendor/clipboard.js/demo/function-text.html deleted file mode 100644 index 9134aadd..00000000 --- a/vendor/clipboard.js/demo/function-text.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - function-text - - - - - - - - - - - - - diff --git a/vendor/clipboard.js/demo/target-div.html b/vendor/clipboard.js/demo/target-div.html deleted file mode 100644 index 8ced2f2a..00000000 --- a/vendor/clipboard.js/demo/target-div.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - target-div - - - - -
hello
- - - - - - - - - diff --git a/vendor/clipboard.js/demo/target-input.html b/vendor/clipboard.js/demo/target-input.html deleted file mode 100644 index b13eeede..00000000 --- a/vendor/clipboard.js/demo/target-input.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - target-input - - - - - - - - - - - - - - diff --git a/vendor/clipboard.js/demo/target-textarea.html b/vendor/clipboard.js/demo/target-textarea.html deleted file mode 100644 index d42cc8ca..00000000 --- a/vendor/clipboard.js/demo/target-textarea.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - target-textarea - - - - - - - - - - - - - - diff --git a/vendor/clipboard.js/dist/clipboard.js b/vendor/clipboard.js/dist/clipboard.js deleted file mode 100644 index 14cb0865..00000000 --- a/vendor/clipboard.js/dist/clipboard.js +++ /dev/null @@ -1,978 +0,0 @@ -/*! - * clipboard.js v2.0.4 - * https://zenorocha.github.io/clipboard.js - * - * Licensed MIT © Zeno Rocha - */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["ClipboardJS"] = factory(); - else - root["ClipboardJS"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _clipboardAction = __webpack_require__(1); - -var _clipboardAction2 = _interopRequireDefault(_clipboardAction); - -var _tinyEmitter = __webpack_require__(3); - -var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); - -var _goodListener = __webpack_require__(4); - -var _goodListener2 = _interopRequireDefault(_goodListener); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Base class which takes one or more elements, adds event listeners to them, - * and instantiates a new `ClipboardAction` on each click. - */ -var Clipboard = function (_Emitter) { - _inherits(Clipboard, _Emitter); - - /** - * @param {String|HTMLElement|HTMLCollection|NodeList} trigger - * @param {Object} options - */ - function Clipboard(trigger, options) { - _classCallCheck(this, Clipboard); - - var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); - - _this.resolveOptions(options); - _this.listenClick(trigger); - return _this; - } - - /** - * Defines if attributes would be resolved using internal setter functions - * or custom functions that were passed in the constructor. - * @param {Object} options - */ - - - _createClass(Clipboard, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - this.action = typeof options.action === 'function' ? options.action : this.defaultAction; - this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; - this.text = typeof options.text === 'function' ? options.text : this.defaultText; - this.container = _typeof(options.container) === 'object' ? options.container : document.body; - } - - /** - * Adds a click event listener to the passed trigger. - * @param {String|HTMLElement|HTMLCollection|NodeList} trigger - */ - - }, { - key: 'listenClick', - value: function listenClick(trigger) { - var _this2 = this; - - this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) { - return _this2.onClick(e); - }); - } - - /** - * Defines a new `ClipboardAction` on each click event. - * @param {Event} e - */ - - }, { - key: 'onClick', - value: function onClick(e) { - var trigger = e.delegateTarget || e.currentTarget; - - if (this.clipboardAction) { - this.clipboardAction = null; - } - - this.clipboardAction = new _clipboardAction2.default({ - action: this.action(trigger), - target: this.target(trigger), - text: this.text(trigger), - container: this.container, - trigger: trigger, - emitter: this - }); - } - - /** - * Default `action` lookup function. - * @param {Element} trigger - */ - - }, { - key: 'defaultAction', - value: function defaultAction(trigger) { - return getAttributeValue('action', trigger); - } - - /** - * Default `target` lookup function. - * @param {Element} trigger - */ - - }, { - key: 'defaultTarget', - value: function defaultTarget(trigger) { - var selector = getAttributeValue('target', trigger); - - if (selector) { - return document.querySelector(selector); - } - } - - /** - * Returns the support of the given action, or all actions if no action is - * given. - * @param {String} [action] - */ - - }, { - key: 'defaultText', - - - /** - * Default `text` lookup function. - * @param {Element} trigger - */ - value: function defaultText(trigger) { - return getAttributeValue('text', trigger); - } - - /** - * Destroy lifecycle. - */ - - }, { - key: 'destroy', - value: function destroy() { - this.listener.destroy(); - - if (this.clipboardAction) { - this.clipboardAction.destroy(); - this.clipboardAction = null; - } - } - }], [{ - key: 'isSupported', - value: function isSupported() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; - - var actions = typeof action === 'string' ? [action] : action; - var support = !!document.queryCommandSupported; - - actions.forEach(function (action) { - support = support && !!document.queryCommandSupported(action); - }); - - return support; - } - }]); - - return Clipboard; -}(_tinyEmitter2.default); - -/** - * Helper function to retrieve attribute value. - * @param {String} suffix - * @param {Element} element - */ - - -function getAttributeValue(suffix, element) { - var attribute = 'data-clipboard-' + suffix; - - if (!element.hasAttribute(attribute)) { - return; - } - - return element.getAttribute(attribute); -} - -module.exports = Clipboard; - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _select = __webpack_require__(2); - -var _select2 = _interopRequireDefault(_select); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Inner class which performs selection from either `text` or `target` - * properties and then executes copy or cut operations. - */ -var ClipboardAction = function () { - /** - * @param {Object} options - */ - function ClipboardAction(options) { - _classCallCheck(this, ClipboardAction); - - this.resolveOptions(options); - this.initSelection(); - } - - /** - * Defines base properties passed from constructor. - * @param {Object} options - */ - - - _createClass(ClipboardAction, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - this.action = options.action; - this.container = options.container; - this.emitter = options.emitter; - this.target = options.target; - this.text = options.text; - this.trigger = options.trigger; - - this.selectedText = ''; - } - - /** - * Decides which selection strategy is going to be applied based - * on the existence of `text` and `target` properties. - */ - - }, { - key: 'initSelection', - value: function initSelection() { - if (this.text) { - this.selectFake(); - } else if (this.target) { - this.selectTarget(); - } - } - - /** - * Creates a fake textarea element, sets its value from `text` property, - * and makes a selection on it. - */ - - }, { - key: 'selectFake', - value: function selectFake() { - var _this = this; - - var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; - - this.removeFake(); - - this.fakeHandlerCallback = function () { - return _this.removeFake(); - }; - this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; - - this.fakeElem = document.createElement('textarea'); - // Prevent zooming on iOS - this.fakeElem.style.fontSize = '12pt'; - // Reset box model - this.fakeElem.style.border = '0'; - this.fakeElem.style.padding = '0'; - this.fakeElem.style.margin = '0'; - // Move element out of screen horizontally - this.fakeElem.style.position = 'absolute'; - this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; - // Move element to the same position vertically - var yPosition = window.pageYOffset || document.documentElement.scrollTop; - this.fakeElem.style.top = yPosition + 'px'; - - this.fakeElem.setAttribute('readonly', ''); - this.fakeElem.value = this.text; - - this.container.appendChild(this.fakeElem); - - this.selectedText = (0, _select2.default)(this.fakeElem); - this.copyText(); - } - - /** - * Only removes the fake element after another click event, that way - * a user can hit `Ctrl+C` to copy because selection still exists. - */ - - }, { - key: 'removeFake', - value: function removeFake() { - if (this.fakeHandler) { - this.container.removeEventListener('click', this.fakeHandlerCallback); - this.fakeHandler = null; - this.fakeHandlerCallback = null; - } - - if (this.fakeElem) { - this.container.removeChild(this.fakeElem); - this.fakeElem = null; - } - } - - /** - * Selects the content from element passed on `target` property. - */ - - }, { - key: 'selectTarget', - value: function selectTarget() { - this.selectedText = (0, _select2.default)(this.target); - this.copyText(); - } - - /** - * Executes the copy operation based on the current selection. - */ - - }, { - key: 'copyText', - value: function copyText() { - var succeeded = void 0; - - try { - succeeded = document.execCommand(this.action); - } catch (err) { - succeeded = false; - } - - this.handleResult(succeeded); - } - - /** - * Fires an event based on the copy operation result. - * @param {Boolean} succeeded - */ - - }, { - key: 'handleResult', - value: function handleResult(succeeded) { - this.emitter.emit(succeeded ? 'success' : 'error', { - action: this.action, - text: this.selectedText, - trigger: this.trigger, - clearSelection: this.clearSelection.bind(this) - }); - } - - /** - * Moves focus away from `target` and back to the trigger, removes current selection. - */ - - }, { - key: 'clearSelection', - value: function clearSelection() { - if (this.trigger) { - this.trigger.focus(); - } - - window.getSelection().removeAllRanges(); - } - - /** - * Sets the `action` to be performed which can be either 'copy' or 'cut'. - * @param {String} action - */ - - }, { - key: 'destroy', - - - /** - * Destroy lifecycle. - */ - value: function destroy() { - this.removeFake(); - } - }, { - key: 'action', - set: function set() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; - - this._action = action; - - if (this._action !== 'copy' && this._action !== 'cut') { - throw new Error('Invalid "action" value, use either "copy" or "cut"'); - } - } - - /** - * Gets the `action` property. - * @return {String} - */ - , - get: function get() { - return this._action; - } - - /** - * Sets the `target` property using an element - * that will be have its content copied. - * @param {Element} target - */ - - }, { - key: 'target', - set: function set(target) { - if (target !== undefined) { - if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { - if (this.action === 'copy' && target.hasAttribute('disabled')) { - throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); - } - - if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { - throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); - } - - this._target = target; - } else { - throw new Error('Invalid "target" value, use a valid Element'); - } - } - } - - /** - * Gets the `target` property. - * @return {String|HTMLElement} - */ - , - get: function get() { - return this._target; - } - }]); - - return ClipboardAction; -}(); - -module.exports = ClipboardAction; - -/***/ }), -/* 2 */ -/***/ (function(module, exports) { - -function select(element) { - var selectedText; - - if (element.nodeName === 'SELECT') { - element.focus(); - - selectedText = element.value; - } - else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { - var isReadOnly = element.hasAttribute('readonly'); - - if (!isReadOnly) { - element.setAttribute('readonly', ''); - } - - element.select(); - element.setSelectionRange(0, element.value.length); - - if (!isReadOnly) { - element.removeAttribute('readonly'); - } - - selectedText = element.value; - } - else { - if (element.hasAttribute('contenteditable')) { - element.focus(); - } - - var selection = window.getSelection(); - var range = document.createRange(); - - range.selectNodeContents(element); - selection.removeAllRanges(); - selection.addRange(range); - - selectedText = selection.toString(); - } - - return selectedText; -} - -module.exports = select; - - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - -function E () { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) -} - -E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - function listener () { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); - } - } - - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 - - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; - - return this; - } -}; - -module.exports = E; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { - -var is = __webpack_require__(5); -var delegate = __webpack_require__(6); - -/** - * Validates all params and calls the right - * listener function based on its target type. - * - * @param {String|HTMLElement|HTMLCollection|NodeList} target - * @param {String} type - * @param {Function} callback - * @return {Object} - */ -function listen(target, type, callback) { - if (!target && !type && !callback) { - throw new Error('Missing required arguments'); - } - - if (!is.string(type)) { - throw new TypeError('Second argument must be a String'); - } - - if (!is.fn(callback)) { - throw new TypeError('Third argument must be a Function'); - } - - if (is.node(target)) { - return listenNode(target, type, callback); - } - else if (is.nodeList(target)) { - return listenNodeList(target, type, callback); - } - else if (is.string(target)) { - return listenSelector(target, type, callback); - } - else { - throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); - } -} - -/** - * Adds an event listener to a HTML element - * and returns a remove listener function. - * - * @param {HTMLElement} node - * @param {String} type - * @param {Function} callback - * @return {Object} - */ -function listenNode(node, type, callback) { - node.addEventListener(type, callback); - - return { - destroy: function() { - node.removeEventListener(type, callback); - } - } -} - -/** - * Add an event listener to a list of HTML elements - * and returns a remove listener function. - * - * @param {NodeList|HTMLCollection} nodeList - * @param {String} type - * @param {Function} callback - * @return {Object} - */ -function listenNodeList(nodeList, type, callback) { - Array.prototype.forEach.call(nodeList, function(node) { - node.addEventListener(type, callback); - }); - - return { - destroy: function() { - Array.prototype.forEach.call(nodeList, function(node) { - node.removeEventListener(type, callback); - }); - } - } -} - -/** - * Add an event listener to a selector - * and returns a remove listener function. - * - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @return {Object} - */ -function listenSelector(selector, type, callback) { - return delegate(document.body, selector, type, callback); -} - -module.exports = listen; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports) { - -/** - * Check if argument is a HTML element. - * - * @param {Object} value - * @return {Boolean} - */ -exports.node = function(value) { - return value !== undefined - && value instanceof HTMLElement - && value.nodeType === 1; -}; - -/** - * Check if argument is a list of HTML elements. - * - * @param {Object} value - * @return {Boolean} - */ -exports.nodeList = function(value) { - var type = Object.prototype.toString.call(value); - - return value !== undefined - && (type === '[object NodeList]' || type === '[object HTMLCollection]') - && ('length' in value) - && (value.length === 0 || exports.node(value[0])); -}; - -/** - * Check if argument is a string. - * - * @param {Object} value - * @return {Boolean} - */ -exports.string = function(value) { - return typeof value === 'string' - || value instanceof String; -}; - -/** - * Check if argument is a function. - * - * @param {Object} value - * @return {Boolean} - */ -exports.fn = function(value) { - var type = Object.prototype.toString.call(value); - - return type === '[object Function]'; -}; - - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -var closest = __webpack_require__(7); - -/** - * Delegates event to a selector. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @param {Boolean} useCapture - * @return {Object} - */ -function _delegate(element, selector, type, callback, useCapture) { - var listenerFn = listener.apply(this, arguments); - - element.addEventListener(type, listenerFn, useCapture); - - return { - destroy: function() { - element.removeEventListener(type, listenerFn, useCapture); - } - } -} - -/** - * Delegates event to a selector. - * - * @param {Element|String|Array} [elements] - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @param {Boolean} useCapture - * @return {Object} - */ -function delegate(elements, selector, type, callback, useCapture) { - // Handle the regular Element usage - if (typeof elements.addEventListener === 'function') { - return _delegate.apply(null, arguments); - } - - // Handle Element-less usage, it defaults to global delegation - if (typeof type === 'function') { - // Use `document` as the first parameter, then apply arguments - // This is a short way to .unshift `arguments` without running into deoptimizations - return _delegate.bind(null, document).apply(null, arguments); - } - - // Handle Selector-based usage - if (typeof elements === 'string') { - elements = document.querySelectorAll(elements); - } - - // Handle Array-like based usage - return Array.prototype.map.call(elements, function (element) { - return _delegate(element, selector, type, callback, useCapture); - }); -} - -/** - * Finds closest match and invokes callback. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @return {Function} - */ -function listener(element, selector, type, callback) { - return function(e) { - e.delegateTarget = closest(e.target, selector); - - if (e.delegateTarget) { - callback.call(element, e); - } - } -} - -module.exports = delegate; - - -/***/ }), -/* 7 */ -/***/ (function(module, exports) { - -var DOCUMENT_NODE_TYPE = 9; - -/** - * A polyfill for Element.matches() - */ -if (typeof Element !== 'undefined' && !Element.prototype.matches) { - var proto = Element.prototype; - - proto.matches = proto.matchesSelector || - proto.mozMatchesSelector || - proto.msMatchesSelector || - proto.oMatchesSelector || - proto.webkitMatchesSelector; -} - -/** - * Finds the closest parent that matches a selector. - * - * @param {Element} element - * @param {String} selector - * @return {Function} - */ -function closest (element, selector) { - while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { - if (typeof element.matches === 'function' && - element.matches(selector)) { - return element; - } - element = element.parentNode; - } -} - -module.exports = closest; - - -/***/ }) -/******/ ]); -}); \ No newline at end of file diff --git a/vendor/clipboard.js/dist/clipboard.min.js b/vendor/clipboard.js/dist/clipboard.min.js deleted file mode 100644 index 02c549e3..00000000 --- a/vendor/clipboard.js/dist/clipboard.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * clipboard.js v2.0.4 - * https://zenorocha.github.io/clipboard.js - * - * Licensed MIT © Zeno Rocha - */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return function(n){var o={};function r(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=o,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function o(t,e){for(var n=0;n Modern copy to clipboard. No Flash. Just 3kb gzipped. - -Demo - -## Why - -Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated framework. - -That's why clipboard.js exists. - -## Install - -You can get it on npm. - -``` -npm install clipboard --save -``` - -Or if you're not into package management, just [download a ZIP](https://github.com/zenorocha/clipboard.js/archive/master.zip) file. - -## Setup - -First, include the script located on the `dist` folder or load it from [a third-party CDN provider](https://github.com/zenorocha/clipboard.js/wiki/CDN-Providers). - -```html - -``` - -Now, you need to instantiate it by [passing a DOM selector](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-selector.html#L18), [HTML element](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-node.html#L16-L17), or [list of HTML elements](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-nodelist.html#L18-L19). - -```js -new ClipboardJS('.btn'); -``` - -Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. But guess what? If you have hundreds of matches, this operation can consume a lot of memory. - -For this reason we use [event delegation](http://stackoverflow.com/questions/1687296/what-is-dom-event-delegation) which replaces multiple event listeners with just a single listener. After all, [#perfmatters](https://twitter.com/hashtag/perfmatters). - -# Usage - -We're living a _declarative renaissance_, that's why we decided to take advantage of [HTML5 data attributes](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes) for better usability. - -### Copy text from another element - -A pretty common use case is to copy content from another element. You can do that by adding a `data-clipboard-target` attribute in your trigger element. - -The value you include on this attribute needs to match another's element selector. - -example-2 - -```html - - - - - -``` - -### Cut text from another element - -Additionally, you can define a `data-clipboard-action` attribute to specify if you want to either `copy` or `cut` content. - -If you omit this attribute, `copy` will be used by default. - -example-3 - -```html - - - - - -``` - -As you may expect, the `cut` action only works on `` or `