File manager - Edit - /home/autoph/public_html/data03252025consolidation/app/table/subscription_table.php
Back
<?php include_once("../../cfg/db.php"); include_once("../../api/controllers/utility.php"); $utility = new Utility(); $type = $db->escape($_GET['type']); $search = ""; $offset = ""; $offset_limit = ""; if(isset($_GET['search'])){ $search = $db -> escape(trim($_GET['search'])); } else { $search = ""; } if(isset($_GET['offset'])){ $offset = $db -> escape(trim($_GET['offset'])); } else { $offset = ""; } if(isset($_GET['limit'])){ $limit = $db -> escape(trim($_GET['limit'])); $offset_limit = " LIMIT ". $offset.",".$limit; } else { $offset_limit = ""; } if($type == 1){ $company = ""; $dealer = ""; $delivery_type = ""; $message_type = ""; $reason = ""; $message_type = ""; $company = $db->escape($_GET['company']); if($company != 0 && $company != ""){ $company = " AND tbs.company_id = '$company' "; } else { $company = ""; } $dealer = $db->escape($_GET['dealer']); if($dealer != 0 && $dealer != ""){ $dealer = " AND tbs.dealer_id = '$dealer' "; } else { $dealer = ""; } if(isset($_GET['message_type']) && $_GET['message_type'] != ""){ $message_type = $db->escape($_GET['message_type']); $message_type = " AND tbs.type = '$message_type' "; } if(isset($_GET['delivery_type']) && $_GET['delivery_type'] != ""){ $delivery_type = $db->escape($_GET['delivery_type']); $delivery_type = " AND tbs.delivery_type = '$delivery_type' "; } if(isset($_GET['reason']) && $_GET['reason'] != ""){ $reason = $db->escape($_GET['reason']); $reason = " AND tbs.reason = '$reason' "; } $mask_contact = $db->escape($_GET['mask_contact']); $count = " COUNT(*) "; $fields = " tbs.id, tbs.customer_id, tbs.first_name, tbs.last_name, tbs.cited_contact, DATE_FORMAT(tbs.datetime, '%b %d, %Y') AS action_date, sc.code AS company, sd.name AS dealer, tbs.type, tbs.delivery_type, tbs.reason "; $subscription_table_query = "SELECT %s FROM txt_blast_subscription tbs INNER JOIN source_company sc ON sc.id = tbs.company_id INNER JOIN source_dealer sd ON sd.id = tbs.dealer_id WHERE (concat(tbs.first_name, tbs.last_name) LIKE '%%%s%%') " . $company . $dealer . $message_type . $delivery_type . $reason . " GROUP BY tbs.customer_id ORDER BY tbs.datetime DESC"; // echo sprintf($subscription_table_query, $fields, $search); return; $subscription_list_query = $db->sql_query(sprintf($subscription_table_query, $fields, $search) . $offset_limit); $subscription_list_count = $db->select("SELECT COUNT(*) FROM (" . sprintf($subscription_table_query, $count, $search) . ") AS COUNT"); $json_arr['rows'] = array(); while($row = $subscription_list_query->fetch_assoc()) { $delivery_type = $row['delivery_type']; $cited_contact = $row['cited_contact']; if($mask_contact == 1){ if($delivery_type == 1){ // email $cited_contact = $utility->mask_email($cited_contact); } else if($delivery_type == 2){ // mobile $cited_contact = mask($cited_contact, 4, 1); } } $json_arr['rows'] = array_merge($json_arr['rows'], array(array( 'customer_id'=>$row['customer_id'], 'customer_fullname'=>$row['first_name'] . " " . $row['last_name'], 'company_dealer'=>$row['company'] . "/" . $row['dealer'], 'type'=>$row['type'] == 1 ? "<span style='font-style: italic;'>Birthday</span>" : ($row['type'] == 2 ? "<span style='font-style: italic;'>Insurance</span>" : "<span style='font-style: italic;'>Thank you</span>"), 'delivery_type'=>$delivery_type == 1 ? "<span style='font-style: italic;'>Email</span>" : "<span style='font-style: italic;'>SMS</span>", 'cited_contact'=>$cited_contact, 'reason'=>$row['reason'] == 1 ? "<span class='badge bg-danger'>This is not me</span>" : "<span class='badge bg-info'>Just unsubscribe</span>", 'action_date'=>$row['action_date'] ))); } $json_arr['total'] = $subscription_list_count; echo json_encode($json_arr); } function mask($str, $first, $last) { $len = strlen($str); $toShow = $first + $last; return substr($str, 0, $len <= $toShow ? 0 : $first).str_repeat("*", $len - ($len <= $toShow ? 0 : $toShow)).substr($str, $len - $last, $len <= $toShow ? 0 : $last); } ?>
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings