diff --git a/app/contacts/contact_address_edit.php b/app/contacts/contact_address_edit.php index d5dfe9edf1..89789d8fca 100644 --- a/app/contacts/contact_address_edit.php +++ b/app/contacts/contact_address_edit.php @@ -46,8 +46,22 @@ $language = new text; $text = $language->get(); +//set the defaults + $address_label = ''; + $address_label_custom = ''; + $address_street = ''; + $address_extended = ''; + $address_community = ''; + $address_locality = ''; + $address_region = ''; + $address_postal_code = ''; + $address_country = ''; + $address_latitude = ''; + $address_longitude = ''; + $address_description = ''; + //action add or update - if (is_uuid($_REQUEST["id"])) { + if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; $contact_address_uuid = $_REQUEST["id"]; } @@ -56,12 +70,12 @@ } //get the contact uuid - if (is_uuid($_GET["contact_uuid"])) { + if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) { $contact_uuid = $_GET["contact_uuid"]; } //get http post variables and set them to php variables - if (count($_POST)>0) { + if (!empty($_POST)) { $address_type = $_POST["address_type"]; $address_label = $_POST["address_label"]; $address_label_custom = $_POST["address_label_custom"]; @@ -78,11 +92,11 @@ $address_description = $_POST["address_description"]; //use custom label if set - $address_label = $address_label_custom != '' ? $address_label_custom : $address_label; + $address_label = !empty($address_label_custom) ? $address_label_custom : $address_label; } //process the form data - if (count($_POST) > 0 && empty($_POST["persistformvar"])) { + if (!empty($_POST) && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -113,7 +127,7 @@ } //add or update the database - if ($_POST["persistformvar"] != "true") { + if (empty($_POST["persistformvar"])) { //update last modified $array['contacts'][0]['contact_uuid'] = $contact_uuid; @@ -140,7 +154,7 @@ $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $database = new database; - $database->execute($sql, $parameters); + $database->execute($sql, $parameters ?? null); unset($sql, $parameters); } @@ -157,7 +171,7 @@ message::add($text['message-update']); } - if (is_array($array) && @sizeof($array) != 0) { + if (!empty($array)) { $array['contact_addresses'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contact_addresses'][0]['contact_uuid'] = $contact_uuid; $array['contact_addresses'][0]['address_type'] = $address_type; @@ -188,7 +202,7 @@ } //pre-populate the form - if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + if (!empty($_GET) && !empty($_POST["persistformvar"])) { $contact_address_uuid = $_GET["id"]; $sql = "select * from v_contact_addresses "; $sql .= "where domain_uuid = :domain_uuid "; @@ -196,8 +210,8 @@ $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['contact_address_uuid'] = $contact_address_uuid; $database = new database; - $row = $database->select($sql, $parameters, 'row'); - if (is_array($row) && @sizeof($row) != 0) { + $row = $database->select($sql, $parameters ?? null, 'row'); + if (!empty($row)) { $address_type = $row["address_type"]; $address_label = $row["address_label"]; $address_street = $row["address_street"]; @@ -273,7 +287,7 @@ echo " ".$text['label-address_label']."\n"; echo "\n"; echo "\n"; - if (is_array($_SESSION["contact"]["address_label"])) { + if (!empty($_SESSION["contact"]["address_label"])) { sort($_SESSION["contact"]["address_label"]); foreach($_SESSION["contact"]["address_label"] as $row) { $address_label_options[] = ""; @@ -290,15 +304,15 @@ $default_labels[] = $text['option-billing']; $default_labels[] = $text['option-other']; foreach ($default_labels as $default_label) { - $address_label_options[] = ""; + $address_label_options[] = ""; } $address_label_found = (in_array($address_label, $default_labels)) ? true : false; } - echo " \n"; echo " \n"; - echo (is_array($address_label_options)) ? implode("\n", $address_label_options) : null; + echo (!empty($address_label_options)) ? implode("\n", $address_label_options) : null; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo "
\n"; echo $text['description-address_label']."\n"; @@ -458,4 +472,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_addresses.php b/app/contacts/contact_addresses.php index 033af7efa1..d17dee8b81 100644 --- a/app/contacts/contact_addresses.php +++ b/app/contacts/contact_addresses.php @@ -41,8 +41,11 @@ exit; } +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //set the uuid - if (is_uuid($_GET['id'])) { + if (!empty($_GET['id']) && is_uuid($_GET['id'])) { $contact_uuid = $_GET['id']; } @@ -52,17 +55,17 @@ $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by address_primary desc, address_label asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $parameters['contact_uuid'] = $contact_uuid; + $parameters['contact_uuid'] = $contact_uuid ?? ''; $database = new database; $contact_addresses = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //show if exists - if (is_array($contact_addresses) && @sizeof($contact_addresses) != 0) { + if (!empty($contact_addresses)) { //show the content echo "
\n"; - echo "
".$text['label-addresses']."
\n"; + echo "
".!empty($text['label-addresses'])."
\n"; echo "
\n"; echo "
\n"; @@ -70,21 +73,21 @@ echo "\n"; if (permission_exists('contact_address_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } - echo "".$text['label-address_label']."\n"; - echo "".$text['label-address_address']."\n"; - echo "".$text['label-address_locality'].", ".$text['label-address_region']."\n"; - echo "".$text['label-address_country']."\n"; + echo "".!empty($text['label-address_label'])."\n"; + echo "".!empty($text['label-address_address'])."\n"; + echo "".!empty($text['label-address_locality']).", ".!empty($text['label-address_region'])."\n"; + echo "".!empty($text['label-address_country'])."\n"; echo " \n"; - echo "".$text['label-address_description']."\n"; - if (permission_exists('contact_address_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo "".!empty($text['label-address_description'])."\n"; + if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') { echo "  \n"; } echo "\n"; - if (is_array($contact_addresses) && @sizeof($contact_addresses) != 0) { + if (!empty($contact_addresses)) { $x = 0; foreach ($contact_addresses as $row) { $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code']; @@ -99,13 +102,13 @@ echo " \n"; } echo " ".escape($row['address_label'])." ".($row['address_primary'] ? " " : null)."\n"; - $address = escape($row['address_street']).($row['address_extended'] != '' ? " ".escape($row['address_extended']) : null); + $address = escape($row['address_street']).(!empty($row['address_extended']) ? " ".escape($row['address_extended']) : null); echo " ".$address." \n"; - echo " ".escape($row['address_locality']).(($row['address_locality'] != '' && $row['address_region'] != '') ? ", " : null).escape($row['address_region'])." \n"; + echo " ".escape($row['address_locality']).((!empty($row['address_locality']) && !empty($row['address_region'])) ? ", " : null).escape($row['address_region'])." \n"; echo " ".escape($row['address_country'])." \n"; - echo " \n"; + echo " \n"; echo " ".escape($row['address_description'])." \n"; - if (permission_exists('contact_address_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo " \n"; @@ -121,4 +124,4 @@ } -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_addresses_view.php b/app/contacts/contact_addresses_view.php index a6d6bb7b19..511a98c283 100644 --- a/app/contacts/contact_addresses_view.php +++ b/app/contacts/contact_addresses_view.php @@ -47,13 +47,13 @@ $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by address_primary desc, address_label asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $parameters['contact_uuid'] = $contact_uuid; + $parameters['contact_uuid'] = $contact_uuid ?? ''; $database = new database; $contact_addresses = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //show if exists - if (is_array($contact_addresses) && @sizeof($contact_addresses) != 0) { + if (!empty($contact_addresses)) { //show the content echo "
\n"; @@ -99,4 +99,4 @@ } -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_attachment.php b/app/contacts/contact_attachment.php index 245e153f24..75759c7a8c 100644 --- a/app/contacts/contact_attachment.php +++ b/app/contacts/contact_attachment.php @@ -36,11 +36,11 @@ $text = $language->get(); //get attachment uuid - $contact_attachment_uuid = $_GET['id']; - $action = $_GET['action']; + $contact_attachment_uuid = $_GET['id'] ?? ''; + $action = $_GET['action'] ?? ''; //get media - if (is_uuid($contact_attachment_uuid)) { + if (!empty($contact_attachment_uuid) && is_uuid($contact_attachment_uuid)) { $sql = "select attachment_filename, attachment_content from v_contact_attachments "; $sql .= "where contact_attachment_uuid = :contact_attachment_uuid "; @@ -48,15 +48,15 @@ $parameters['contact_attachment_uuid'] = $contact_attachment_uuid; $parameters['domain_uuid'] = $domain_uuid; $database = new database; - $attachment = $database->select($sql, $parameters, 'row'); + $attachment = $database->select($sql, $parameters ?? null, 'row'); unset($sql, $parameters); - $attachment_type = strtolower(pathinfo($attachment['attachment_filename'], PATHINFO_EXTENSION)); + $attachment_type = strtolower(pathinfo($attachment['attachment_filename'] ?? '', PATHINFO_EXTENSION)); //determine mime type $content_type = 'application/octet-stream'; //set default - $allowed_attachment_types = json_decode($_SESSION['contacts']['allowed_attachment_types']['text'], true); - if (is_array($allowed_attachment_types) && sizeof($allowed_attachment_types) != 0) { + $allowed_attachment_types = json_decode($_SESSION['contacts']['allowed_attachment_types']['text'] ?? '', true); + if (!empty($allowed_attachment_types)) { if ($allowed_attachment_types[$attachment_type] != '') { $content_type = $allowed_attachment_types[$attachment_type]; } @@ -82,4 +82,4 @@ } -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_attachment_edit.php b/app/contacts/contact_attachment_edit.php index e5bcdf32e3..159f228437 100644 --- a/app/contacts/contact_attachment_edit.php +++ b/app/contacts/contact_attachment_edit.php @@ -43,13 +43,13 @@ $text = $language->get(); //action add or update - $contact_attachment_uuid = $_REQUEST['id']; - $contact_uuid = $_REQUEST['contact_uuid']; + $contact_attachment_uuid = $_REQUEST['id'] ?? ''; + $contact_uuid = $_REQUEST['contact_uuid'] ?? ''; - if (is_uuid($contact_attachment_uuid) && is_uuid($contact_uuid)) { + if (!empty($contact_attachment_uuid) && !empty($contact_uuid) && is_uuid($contact_attachment_uuid) && is_uuid($contact_uuid)) { $action = 'update'; } - else if (is_uuid($contact_uuid)) { + else if (!empty($contact_uuid) && is_uuid($contact_uuid)) { $action = 'add'; } else { @@ -57,7 +57,7 @@ } //get http post variables and set them to php variables - if (is_array($_POST) && sizeof($_POST) != 0) { + if (!empty($_POST)) { $attachment = $_FILES['attachment']; $attachment_primary = $_POST['attachment_primary']; @@ -71,7 +71,7 @@ exit; } - if (!is_array($attachment) || sizeof($attachment) == 0) { + if (empty($attachment) || sizeof($attachment) == 0) { $attachment_type = strtolower(pathinfo($_POST['attachment_filename'], PATHINFO_EXTENSION)); } else { @@ -87,7 +87,7 @@ $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $database = new database; - $database->execute($sql, $parameters); + $database->execute($sql, $parameters ?? null); unset($sql, $parameters); $allowed_primary_attachment = true; @@ -96,7 +96,7 @@ //format array $allowed_extensions = array_keys(json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true)); $array['contact_attachments'][$index]['contact_attachment_uuid'] = $action == 'update' ? $contact_attachment_uuid : uuid(); - $array['contact_attachments'][$index]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['contact_attachments'][$index]['domain_uuid'] = $_SESSION['domain_uuid'] ?? ''; $array['contact_attachments'][$index]['contact_uuid'] = $contact_uuid; $array['contact_attachments'][$index]['attachment_primary'] = $allowed_primary_attachment ? 1 : 0; if ($attachment['error'] == '0' && in_array(strtolower(pathinfo($attachment['name'], PATHINFO_EXTENSION)), $allowed_extensions)) { @@ -124,7 +124,7 @@ } //get form data - if (is_array($_GET) && sizeof($_GET) != 0) { + if (!empty($_GET)) { $sql = "select * from v_contact_attachments "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_attachment_uuid = :contact_attachment_uuid "; @@ -132,7 +132,7 @@ $parameters['contact_attachment_uuid'] = $contact_attachment_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); - if (is_array($row) && @sizeof($row) != 0) { + if (!empty($row)) { $attachment_primary = $row["attachment_primary"]; $attachment_filename = $row["attachment_filename"]; $attachment_content = $row["attachment_content"]; @@ -180,7 +180,7 @@ echo " ".$text['label-attachment']."\n"; echo "\n"; echo "\n"; - $attachment_type = strtolower(pathinfo($attachment_filename, PATHINFO_EXTENSION)); + $attachment_type = strtolower(pathinfo($attachment_filename ?? '', PATHINFO_EXTENSION)); if ($action == 'update') { echo "\n"; if ($attachment_type == 'jpg' || $attachment_type == 'jpeg' || $attachment_type == 'gif' || $attachment_type == 'png') { @@ -226,7 +226,7 @@ echo " ".$text['label-attachment_description']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "\n"; echo "\n"; @@ -244,4 +244,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/contacts/contact_attachments.php b/app/contacts/contact_attachments.php index 3a0aa3bb8d..e01a95a0eb 100644 --- a/app/contacts/contact_attachments.php +++ b/app/contacts/contact_attachments.php @@ -41,19 +41,22 @@ exit; } +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //get the contact attachment list $sql = "select *, length(decode(attachment_content,'base64')) as attachment_size from v_contact_attachments "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "order by attachment_primary desc, attachment_filename asc "; $parameters['domain_uuid'] = $domain_uuid; - $parameters['contact_uuid'] = $contact_uuid; + $parameters['contact_uuid'] = $contact_uuid ?? ''; $database = new database; $contact_attachments = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //show if exists - if (is_array($contact_attachments) && @sizeof($contact_attachments) != 0) { + if (!empty($contact_attachments)) { //styles and attachment layer echo "