Changeset 3406310
- Timestamp:
- 11/30/2025 08:54:43 PM (3 months ago)
- Location:
- dialbunny/trunk
- Files:
-
- 3 added
- 24 edited
-
app.php (modified) (4 diffs)
-
dialbunny.php (modified) (12 diffs)
-
lib/components/countries.php (added)
-
lib/config/initiate_tables.php (modified) (1 diff)
-
lib/controllers/admin.php (modified) (1 diff)
-
lib/controllers/dashboard.php (modified) (9 diffs)
-
lib/controllers/webcalling.php (modified) (1 diff)
-
lib/views/admin/add.php (modified) (1 diff)
-
lib/views/admin/header.php (modified) (2 diffs)
-
lib/views/admin/license.php (modified) (3 diffs)
-
lib/views/admin/released.php (modified) (4 diffs)
-
lib/views/admin/setup.php (modified) (6 diffs)
-
lib/views/dashboard/addresses.php (added)
-
lib/views/dashboard/ai_assistant.php (modified) (11 diffs)
-
lib/views/dashboard/calendar.php (modified) (16 diffs)
-
lib/views/dashboard/choose.php (modified) (13 diffs)
-
lib/views/dashboard/contacts/contacts.php (modified) (4 diffs)
-
lib/views/dashboard/contacts/default.php (modified) (9 diffs)
-
lib/views/dashboard/inbound.php (modified) (8 diffs)
-
lib/views/dashboard/index.php (modified) (7 diffs)
-
lib/views/dashboard/messages/default.php (modified) (7 diffs)
-
lib/views/dashboard/messages/messages.php (modified) (4 diffs)
-
lib/views/dashboard/messages/view.php (modified) (3 diffs)
-
lib/views/dashboard/profile.php (added)
-
lib/views/dashboard/recents.php (modified) (4 diffs)
-
lib/views/dashboard/released.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dialbunny/trunk/app.php
r3396401 r3406310 132 132 </div> 133 133 <div class="ms-2"> 134 <a href="<?php echo esc_url(wp_nonce_url($dialbunnyDashboardUrl, 'DialBunny', 'user_nonce')) ; ?>" class="text-gray-800 text-hover-primary fs-6 fw-bold lh-1"><?php echo esc_html($current_user->display_name); ?></a>134 <a href="<?php echo esc_url(wp_nonce_url($dialbunnyDashboardUrl, 'DialBunny', 'user_nonce')) ?>&dashboardpage=profile" class="text-gray-800 text-hover-primary fs-6 fw-bold lh-1"><?php echo esc_html($current_user->display_name); ?></a> 135 135 <span style="max-width: 170px;" class="text-muted fw-semibold d-block fs-7 lh-1 text-truncate"><?php echo esc_html($current_user->user_email); ?></span> 136 136 </div> … … 185 185 echo 'Recent Phone Calls'; 186 186 break; 187 case 'profile': 188 echo 'Settings → Profile'; 189 break; 187 190 188 191 default: … … 202 205 </div> 203 206 <div class="d-flex align-items-center flex-shrink-0 mb-0 mb-lg-0"> 207 <a href="<?php echo esc_url(wp_nonce_url($dialbunnyDashboardUrl, 'DialBunny', 'user_nonce')) ?>&dashboardpage=profile" class="btn btn-icon btn-color-gray-700 btn-active-color-primary btn-outline w-40px h-40px position-relative ms-3 ms-lg-4 p-2"> 208 <span class="fas fa-gear fa-xl"></span> 209 </a> 204 210 <a href="<?php echo esc_url(admin_url()); ?>" class="btn btn-icon btn-color-gray-700 btn-active-color-primary btn-outline w-40px h-40px position-relative ms-3 ms-lg-4 p-2"> 205 211 <svg x="0px" y="0px" width="100" height="100" viewBox="0 0 26 26"> … … 212 218 <?php 213 219 // Direct database query used below – Safely gets data from the database using $wpdb->prepare(), which handles proper escaping and prevents SQL injection. 214 $ licenseKey = $wpdb->get_results($wpdb->prepare("SELECT license_key FROM {$wpdb->prefix}dialbunny_api_keys WHERE id = %s LIMIT 1",'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery215 if (strlen($ licenseKey[0]->license_key) != 27 && stripos($licenseKey[0]->license_key, 'd') == false) { echo '<div class="content d-flex flex-column flex-column-fluid"><div class="container-xxl">' . wp_kses_post(dialbunny_main_danger("No Active License Key!", "Phone calls and text messages will be limited until you add a license key.")) . '</div></div>'; }220 $dialbunny_licenseKey = $wpdb->get_results($wpdb->prepare("SELECT license_key FROM {$wpdb->prefix}dialbunny_api_keys WHERE id = %s LIMIT 1",'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 221 if (strlen($dialbunny_licenseKey[0]->license_key) != 27 && stripos($dialbunny_licenseKey[0]->license_key, 'd') == false) { echo '<div class="content d-flex flex-column flex-column-fluid"><div class="container-xxl">' . wp_kses_post(dialbunny_main_danger("No Active License Key!", "Phone calls and text messages will be limited until you add a license key.")) . '</div></div>'; } 216 222 switch ($page) 217 223 { 218 case 'keypad':224 case 'keypad': 219 225 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/keypad.php'); 220 226 break; 221 case 'howitworks':227 case 'howitworks': 222 228 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/howitworks.php'); 223 229 break; 224 case 'choose':230 case 'choose': 225 231 if (get_option('dialbunny_user_can_request_number') == true || current_user_can('administrator')) { include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/choose.php'); } 226 232 break; 227 case 'released':233 case 'released': 228 234 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/released.php'); 229 235 break; 230 case 'inbound':236 case 'inbound': 231 237 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/inbound.php'); 232 238 break; 233 case 'aiassistant':239 case 'aiassistant': 234 240 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/ai_assistant.php'); 235 241 break; 236 case 'calendar':242 case 'calendar': 237 243 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/calendar.php'); 238 244 break; 239 case 'messages':245 case 'messages': 240 246 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/messages/messages.php'); 241 247 break; 242 case 'contacts':248 case 'contacts': 243 249 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/contacts/contacts.php'); 244 250 break; 245 case 'recents':251 case 'recents': 246 252 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/recents.php'); 253 break; 254 case 'profile': 255 include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/profile.php'); 247 256 break; 248 257 -
dialbunny/trunk/dialbunny.php
r3396401 r3406310 4 4 Plugin URI: https://dialbunny.com/ 5 5 Description: Easily manage inbound and outbound phone calls and text messages 6 Version: 1.1. 56 Version: 1.1.6 7 7 Author:DialBunny 8 8 Author URI: https://dialbunny.com … … 40 40 { 41 41 // Change styling for DialBunny plugin dashboard 42 add_action('admin_enqueue_scripts', array($this,' load_custom_blank_page_styles'), 1);42 add_action('admin_enqueue_scripts', array($this,'dialbunny_load_custom_blank_page_styles'), 999); 43 43 44 44 // Only apply the Bootstrap "light" theme on the DialBunny dashboard page … … 92 92 } 93 93 94 function load_custom_blank_page_styles($hook)94 function dialbunny_load_custom_blank_page_styles($hook) 95 95 { 96 96 // This only applies to DialBunny dashboard for a clean interface 97 97 if ($hook == 'toplevel_page_dialbunny_dashboard') 98 98 { 99 // Dequeue Latepoint styles in the DialBunny dashboard when the plugin is active 100 wp_dequeue_style( 'latepoint-admin' ); 101 wp_deregister_style( 'latepoint-admin' ); 102 wp_dequeue_style( 'latepoint-blocks' ); 103 wp_deregister_style( 'latepoint-blocks' ); 104 wp_dequeue_style( 'wp-components' ); 105 wp_deregister_style( 'wp-components' ); 99 106 // Dequeue 100 107 wp_dequeue_style( 'dashicons' ); … … 143 150 include(plugin_dir_path(__FILE__) . 'lib/components/alerts.php' ); 144 151 include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); 152 include(plugin_dir_path(__FILE__) . 'lib/components/countries.php' ); 145 153 include(plugin_dir_path(__FILE__) . 'lib/components/timezone.php' ); 146 154 include(plugin_dir_path(__FILE__) . 'lib/components/formatnumber.php' ); … … 159 167 'manage_options', 160 168 'dialbunny_setup', 161 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/setup.php' ); },169 function () { $current_page = 'setup'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/setup.php' ); }, 162 170 null 163 171 ); … … 168 176 'manage_options', 169 177 'dialbunny_additional', 170 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/additional.php' ); },178 function () { $current_page = 'additional'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/additional.php' ); }, 171 179 null 172 180 ); … … 177 185 'manage_options', 178 186 'dialbunny_availability', 179 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/availability.php' ); },187 function () { $current_page = 'availability'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/availability.php' ); }, 180 188 null 181 189 ); … … 186 194 'manage_options', 187 195 'dialbunny_license', 188 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/license.php' ); },196 function () { $current_page = 'license'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/license.php' ); }, 189 197 null 190 198 ); … … 195 203 'manage_options', 196 204 'dialbunny_info', 197 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/info.php' ); },205 function () { $current_page = 'info'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/info.php' ); }, 198 206 null 199 207 ); … … 204 212 'manage_options', 205 213 'dialbunny_add', 206 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/add.php' ); },214 function () { $current_page = 'add'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/add.php' ); }, 207 215 null 208 216 ); … … 213 221 'manage_options', 214 222 'dialbunny_remove', 215 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/remove.php' ); },223 function () { $current_page = 'remove'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/remove.php' ); }, 216 224 null 217 225 ); … … 222 230 'manage_options', 223 231 'dialbunny_released', 224 function () { include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/released.php' ); },232 function () { $current_page = 'released'; include(plugin_dir_path(__FILE__) . 'lib/views/admin/header.php' ); include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' ); include(plugin_dir_path(__FILE__) . 'lib/views/admin/released.php' ); }, 225 233 null 226 234 ); -
dialbunny/trunk/lib/config/initiate_tables.php
r3396401 r3406310 140 140 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 141 141 dbDelta($sql); 142 143 // Create Addresses table 144 $charset_collate = $wpdb->get_charset_collate(); 145 $table_prefix = $wpdb->prefix; 146 147 $sql = "CREATE TABLE " . $table_prefix."dialbunny_addresses" . " ( 148 id varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL UNIQUE, 149 user varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, 150 twilio_address_sid varchar(255) COLLATE utf8mb4_unicode_ci, 151 friendly_name varchar(255) COLLATE utf8mb4_unicode_ci, 152 country varchar(255) COLLATE utf8mb4_unicode_ci, 153 customer varchar(255) COLLATE utf8mb4_unicode_ci, 154 line1 varchar(255) COLLATE utf8mb4_unicode_ci, 155 line2 varchar(255) COLLATE utf8mb4_unicode_ci, 156 city varchar(255) COLLATE utf8mb4_unicode_ci, 157 state varchar(255) COLLATE utf8mb4_unicode_ci, 158 zip varchar(255) COLLATE utf8mb4_unicode_ci, 159 validated varchar(255) COLLATE utf8mb4_unicode_ci, 160 emergency varchar(255) COLLATE utf8mb4_unicode_ci, 161 created_at timestamp NULL DEFAULT NULL, 162 updated_at timestamp NULL DEFAULT NULL 163 ) $charset_collate;"; 164 165 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 166 dbDelta($sql); 142 167 } 143 168 } -
dialbunny/trunk/lib/controllers/admin.php
r3384851 r3406310 123 123 if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; } 124 124 if ( !current_user_can('administrator') ) { return; } 125 if ( !isset($_POST['idValue']) && !isset($_POST['phone']) && !isset($_POST['phone'])) { return; }125 if ( !isset($_POST['idValue']) && !isset($_POST['phone'])) { return; } 126 126 127 127 global $wpdb; 128 $id = sanitize_text_field(wp_unslash($_POST['idValue'])); if ( ! preg_match('/^[a-f0-9]+\.[0-9]+$/', $input) ) { echo esc_html('Error removing released phone number. Invalid ID.'); exit; }129 $phone = sanitize_text_field(wp_unslash($_POST['phone'])); if (! preg_match('/^\+?[0-9]{1,15}$/', $phone)) { echo esc_html('Error removing released phone number. Invalid Phone Number.'); exit; }128 $id = sanitize_text_field(wp_unslash($_POST['idValue'])); 129 $phone = sanitize_text_field(wp_unslash($_POST['phone'])); 130 130 131 131 $table = $wpdb->prefix . 'dialbunny_released_numbers'; 132 132 // Direct database query used below – Safely deletes data from the database using $wpdb->delete(), which handles proper escaping and prevents SQL injection. 133 $deleted = $wpdb->delete($table, array('id' => $id), array('% d')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery133 $deleted = $wpdb->delete($table, array('id' => $id), array('%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 134 134 135 135 echo $deleted ? esc_html("$phone removed successfully!") : esc_html__("Failed to remove released number!", 'dialbunny'); -
dialbunny/trunk/lib/controllers/dashboard.php
r3336718 r3406310 151 151 $contains = sanitize_text_field(wp_unslash($_POST['contains'] ?? '')); 152 152 $type = sanitize_text_field(wp_unslash($_POST['type'] ?? '')); 153 $user_nonce = sanitize_text_field(wp_unslash($_POST['user_nonce'])); 153 $requirements= sanitize_text_field(wp_unslash($_POST['addressrequirements'] ?? '')); 154 $beta = sanitize_text_field(wp_unslash($_POST['beta'] ?? '')); 155 $user_nonce = sanitize_text_field(wp_unslash($_POST['user_nonce'])); 154 156 155 157 // Build redirect URL safely … … 161 163 'contains' => $contains, 162 164 'type' => $type, 163 'user_nonce' => $user_nonce, // carry it forward 165 'requirements'=> $requirements, 166 'beta' => $beta, 167 'user_nonce' => $user_nonce, // carry it forward 164 168 ], admin_url('admin.php')); 165 169 … … 173 177 if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; } 174 178 global $wpdb; 179 $user_id = get_current_user_id(); 175 180 $number_raw = sanitize_text_field(wp_unslash($_POST['number'] ?? '')); 176 181 $country_code = ''; … … 179 184 // Define known country codes and lengths 180 185 $country_codes = [ 181 '+358' => 4, // Finland 182 '+353' => 4, // Ireland 183 '+31' => 3, // Netherlands 184 '+47' => 3, // Norway 185 '+46' => 3, // Sweden 186 '+45' => 3, // Denmark 187 '+44' => 3, // UK 188 '+1' => 2, // USA & Canada 186 '+1' => 2, // United States, Canada, NANP countries 187 '+7' => 2, // Russia, Kazakhstan 188 '+20' => 3, // Egypt 189 '+27' => 3, // South Africa 190 '+30' => 3, // Greece 191 '+31' => 3, // Netherlands 192 '+32' => 3, // Belgium 193 '+33' => 3, // France 194 '+34' => 3, // Spain 195 '+36' => 3, // Hungary 196 '+39' => 3, // Italy 197 '+40' => 3, // Romania 198 '+41' => 3, // Switzerland 199 '+43' => 3, // Austria 200 '+44' => 3, // United Kingdom 201 '+45' => 3, // Denmark 202 '+46' => 3, // Sweden 203 '+47' => 3, // Norway 204 '+48' => 3, // Poland 205 '+49' => 3, // Germany 206 '+51' => 3, // Peru 207 '+52' => 3, // Mexico 208 '+53' => 3, // Cuba 209 '+54' => 3, // Argentina 210 '+55' => 3, // Brazil 211 '+56' => 3, // Chile 212 '+57' => 3, // Colombia 213 '+58' => 3, // Venezuela 214 '+60' => 3, // Malaysia 215 '+61' => 3, // Australia 216 '+62' => 3, // Indonesia 217 '+63' => 3, // Philippines 218 '+64' => 3, // New Zealand 219 '+65' => 3, // Singapore 220 '+66' => 3, // Thailand 221 '+81' => 3, // Japan 222 '+82' => 3, // South Korea 223 '+84' => 3, // Vietnam 224 '+86' => 3, // China 225 '+90' => 3, // Turkey 226 '+91' => 3, // India 227 '+92' => 3, // Pakistan 228 '+93' => 3, // Afghanistan 229 '+94' => 3, // Sri Lanka 230 '+95' => 3, // Myanmar 231 '+98' => 3, // Iran' 232 '+211' => 4, // South Sudan 233 '+212' => 4, // Morocco 234 '+213' => 4, // Algeria 235 '+216' => 4, // Tunisia 236 '+218' => 4, // Libya 237 '+220' => 4, // Gambia 238 '+221' => 4, // Senegal 239 '+222' => 4, // Mauritania 240 '+223' => 4, // Mali 241 '+224' => 4, // Guinea 242 '+225' => 4, // Côte d'Ivoire 243 '+226' => 4, // Burkina Faso 244 '+227' => 4, // Niger 245 '+228' => 4, // Togo 246 '+229' => 4, // Benin 247 '+230' => 4, // Mauritius 248 '+231' => 4, // Liberia 249 '+232' => 4, // Sierra Leone 250 '+233' => 4, // Ghana 251 '+234' => 4, // Nigeria 252 '+235' => 4, // Chad 253 '+236' => 4, // Central African Republic 254 '+237' => 4, // Cameroon 255 '+238' => 4, // Cape Verde 256 '+239' => 4, // São Tomé & Príncipe 257 '+240' => 4, // Equatorial Guinea 258 '+241' => 4, // Gabon 259 '+242' => 4, // Congo (Brazzaville) 260 '+243' => 4, // Congo (Kinshasa) 261 '+244' => 4, // Angola 262 '+245' => 4, // Guinea-Bissau 263 '+246' => 4, // British Indian Ocean Territory 264 '+248' => 4, // Seychelles 265 '+249' => 4, // Sudan 266 '+250' => 4, // Rwanda 267 '+251' => 4, // Ethiopia 268 '+252' => 4, // Somalia 269 '+253' => 4, // Djibouti 270 '+254' => 4, // Kenya 271 '+255' => 4, // Tanzania 272 '+256' => 4, // Uganda 273 '+257' => 4, // Burundi 274 '+258' => 4, // Mozambique 275 '+260' => 4, // Zambia 276 '+261' => 4, // Madagascar 277 '+262' => 4, // Réunion / Mayotte 278 '+263' => 4, // Zimbabwe 279 '+264' => 4, // Namibia 280 '+265' => 4, // Malawi 281 '+266' => 4, // Lesotho 282 '+267' => 4, // Botswana 283 '+268' => 4, // Eswatini 284 '+269' => 4, // Comoros 285 '+290' => 4, // Saint Helena 286 '+291' => 4, // Eritrea 287 '+297' => 4, // Aruba 288 '+298' => 4, // Faroe Islands 289 '+299' => 4, // Greenland 290 '+1242' => 5, // Bahamas 291 '+1246' => 5, // Barbados 292 '+1264' => 5, // Anguilla 293 '+1268' => 5, // Antigua & Barbuda 294 '+1284' => 5, // British Virgin Islands 295 '+1340' => 5, // U.S. Virgin Islands 296 '+1345' => 5, // Cayman Islands 297 '+1441' => 5, // Bermuda 298 '+1473' => 5, // Grenada 299 '+1649' => 5, // Turks & Caicos 300 '+1664' => 5, // Montserrat 301 '+1670' => 5, // Northern Mariana Islands 302 '+1671' => 5, // Guam 303 '+1684' => 5, // American Samoa 304 '+1758' => 5, // Saint Lucia 305 '+1767' => 5, // Dominica 306 '+1784' => 5, // Saint Vincent & the Grenadines 307 '+1809' => 5, // Dominican Republic 308 '+1829' => 5, // Dominican Republic (overlay) 309 '+1849' => 5, // Dominican Republic (overlay) 310 '+1868' => 5, // Trinidad & Tobago 311 '+1869' => 5, // Saint Kitts & Nevis 312 '+1876' => 5, // Jamaica 189 313 ]; 190 314 … … 211 335 $keys = new DialBunnyKeysClass(); 212 336 $client = new Client($keys->TWILIO_SID(), $keys->TWILIO_TOKEN()); 337 $incoming_phone_number; 213 338 214 339 // Request and purchase the phone number from TWILIO 215 $incoming_phone_number = $client->incomingPhoneNumbers->create([ 340 if (isset($_POST['addressidentity']) && sanitize_text_field(wp_unslash($_POST['addressidentity'])) == 'none') 341 { 342 $incoming_phone_number = $client->incomingPhoneNumbers->create([ 216 343 "friendlyName" => wp_get_current_user()->user_login, 217 344 "emergencyStatus" => "Inactive", … … 221 348 "voiceMethod" => "POST", 222 349 "phoneNumber" => $country_code . $phone_number, 223 ]); 224 225 if ($incoming_phone_number->status === "in-use") { 350 ]); 351 } 352 else 353 { 354 $incoming_phone_number = $client->incomingPhoneNumbers->create([ 355 "friendlyName" => wp_get_current_user()->user_login, 356 "emergencyStatus" => "Inactive", 357 "voiceApplicationSid" => $keys->TwiML_App_SID(), 358 "smsApplicationSid" => $keys->TwiML_App_SID(), 359 "smsMethod" => "POST", 360 "voiceMethod" => "POST", 361 "phoneNumber" => $country_code . $phone_number, 362 "addressSid" => sanitize_text_field(wp_unslash($_POST['addressidentity'] ?? '')), 363 "bundleSid" => sanitize_text_field(wp_unslash($_POST['bundleidentity'] ?? '')), 364 ]); 365 } 366 if ($incoming_phone_number) { 226 367 $table = $wpdb->prefix . 'dialbunny_phone_details'; 227 368 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 228 $existing = $wpdb->get_ var($wpdb->prepare("SELECT idFROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery369 $existing = $wpdb->get_row($wpdb->prepare("SELECT id,managed_number_code,managed_number FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 229 370 230 371 $now = current_time('mysql', 1); … … 246 387 } else { 247 388 // Direct database query used below – Safely updates data into the database using $wpdb->update(), which handles proper escaping and prevents SQL injection. 248 $wpdb->update($table, $data, ['user' => $user_id]); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 389 // Move released number to the released table 390 $released_table = $wpdb->prefix . 'dialbunny_released_numbers'; 391 $current_details = [ 392 'id' => uniqid(), 393 'user' => $user_id, 394 'countrycode' => $existing->managed_number_code, 395 'phone' => $existing->managed_number, 396 'created_at' => current_time('mysql', 1), 397 'updated_at' => current_time('mysql', 1), 398 ]; 399 $wpdb->insert($released_table, $current_details); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 400 // Update the user's managed number to mark it as released 401 $updated = $wpdb->update($table, $data, [ // phpcs:ignore WordPress.DB.DirectDatabaseQuery 402 'managed_number' => $existing->managed_number, 403 'managed_number_code' => $existing->managed_number_code, 404 'user' => $user_id, 405 ]); 249 406 } 250 407 … … 255 412 } 256 413 } catch (Exception $e) { 257 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=choose& error=twilio&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce']))));414 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=choose&addressrequired&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 258 415 } 259 416 exit; … … 587 744 } 588 745 746 // Create an address for phone numbers 747 /*function create_address() 748 { 749 if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; } 750 global $wpdb; 751 $keys = new DialBunnyKeysClass(); 752 $client = new Client($keys->TWILIO_SID(), $keys->TWILIO_TOKEN()); 753 $dialbunny_address; 754 //create address with twilio 755 $dialbunny_address = $client->addresses->create( 756 sanitize_text_field(wp_unslash( $_POST['customer'] )), // CustomerName 757 sanitize_text_field(wp_unslash( $_POST['line1'] )), // Street 758 sanitize_text_field(wp_unslash( $_POST['city'] )), // City 759 sanitize_text_field(wp_unslash( $_POST['state'] )), // Region 760 sanitize_text_field(wp_unslash( $_POST['zip'] )), // PostalCode 761 sanitize_text_field(wp_unslash( $_POST['countrycode'] )), // IsoCountry 762 ["streetSecondary" => sanitize_text_field(wp_unslash( $_POST['line2'] )),"friendlyName" => sanitize_text_field(wp_unslash( $_POST['friendly'] ))] 763 ); 764 if ($dialbunny_address) 765 { 766 // Sanitize all inputs for insertion into local database 767 $data = [ 768 'id' => uniqid(), 769 'user' => get_current_user_id(), 770 'twilio_address_sid'=>$dialbunny_address->sid, 771 'customer' => sanitize_text_field(wp_unslash( $_POST['customer'] ?? '' )), 772 'friendly_name' => sanitize_text_field(wp_unslash( $_POST['friendly'] ?? '' )), 773 'line1' => sanitize_text_field(wp_unslash( $_POST['line1'] ?? '' )), 774 'line2' => sanitize_text_field(wp_unslash( $_POST['line2'] ?? '' )), 775 'city' => sanitize_text_field(wp_unslash( $_POST['city'] ?? '' )), 776 'state' => sanitize_text_field(wp_unslash( $_POST['state'] ?? '' )), 777 'zip' => sanitize_text_field(wp_unslash( $_POST['zip'] ?? '' )), 778 'country' => sanitize_text_field(wp_unslash( $_POST['countrycode'] ?? 'US' )), 779 'created_at' => current_time('mysql', 1), 780 'updated_at' => current_time('mysql', 1) 781 ]; 782 // Basic validation 783 $required = ['customer', 'friendly_name', 'line1', 'city', 'state', 'zip']; 784 foreach ( $required as $field ) { 785 if ( empty($field) ) { 786 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error1&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 787 return; 788 } 789 } 790 // Insert into DB 791 $inserted = $wpdb->insert( $wpdb->prefix.'dialbunny_addresses', $data ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 792 793 if ( $inserted ) { 794 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 795 } else { 796 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error1&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 797 } 798 } 799 else { wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error1&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); } 800 }*/ 801 802 // Update address 803 /*function update_address() 804 { 805 if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; } 806 if ( !isset($_POST['addressidentity'])) { return; } 807 global $wpdb; 808 $keys = new DialBunnyKeysClass(); 809 $client = new Client($keys->TWILIO_SID(), $keys->TWILIO_TOKEN()); 810 $dialbunny_address; 811 // Update Twilio address on twilios end 812 $dialbunny_address = $client->addresses(sanitize_text_field( $_POST['twilio_address_sid']))->update([ 813 'customerName' => sanitize_text_field(wp_unslash( $_POST['customer'] )), 814 'friendlyName' => sanitize_text_field(wp_unslash( $_POST['friendly'] )), 815 'street' => sanitize_text_field(wp_unslash( $_POST['line1'] )), 816 'streetSecondary'=> sanitize_text_field(wp_unslash( $_POST['line2'] )), 817 'city' => sanitize_text_field(wp_unslash( $_POST['city'] )), 818 'region' => sanitize_text_field(wp_unslash( $_POST['state'] )), 819 'postalCode' => sanitize_text_field(wp_unslash( $_POST['zip'] )), 820 'isoCountry' => strtoupper( sanitize_text_field(wp_unslash( $_POST['countrycode'] )) ), 821 ]); 822 if ($dialbunny_address) 823 { 824 // Sanitize all inputs 825 $data = [ 826 'customer' => sanitize_text_field(wp_unslash( $_POST['customer'] ?? '' )), 827 'friendly_name' => sanitize_text_field(wp_unslash( $_POST['friendly'] ?? '' )), 828 'line1' => sanitize_text_field(wp_unslash( $_POST['line1'] ?? '' )), 829 'line2' => sanitize_text_field(wp_unslash( $_POST['line2'] ?? '' )), 830 'city' => sanitize_text_field(wp_unslash( $_POST['city'] ?? '' )), 831 'state' => sanitize_text_field(wp_unslash( $_POST['state'] ?? '' )), 832 'zip' => sanitize_text_field(wp_unslash( $_POST['zip'] ?? '' )), 833 'updated_at' => current_time('mysql', 1) 834 ]; 835 // Basic validation 836 $required = ['customer', 'friendly_name', 'line1', 'city', 'state', 'zip']; 837 foreach ( $required as $field ) { 838 if ( empty($field) ) { 839 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error2&addressidentity='.sanitize_text_field( $_POST['addressidentity']).'user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 840 return; 841 } 842 } 843 // update row 844 $updated = $wpdb->update( $wpdb->prefix.'dialbunny_addresses', $data, ['user' => get_current_user_id(),'id' => sanitize_text_field($_POST['addressidentity'])] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 845 846 if ( $updated ) { 847 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&addressidentity='.sanitize_text_field( $_POST['addressidentity']).'&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 848 } else { 849 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error2&addressidentity='.sanitize_text_field( $_POST['addressidentity']).'&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 850 } 851 } 852 else { wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error2&addressidentity='.sanitize_text_field( $_POST['addressidentity']).'&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); } 853 }*/ 854 855 // Delete address forever 856 /*function remove_address() 857 { 858 if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; } 859 if ( !isset($_POST['addressidentity'])) { return; } 860 global $wpdb; 861 $keys = new DialBunnyKeysClass(); 862 $client = new Client($keys->TWILIO_SID(), $keys->TWILIO_TOKEN()); 863 $dialbunny_address; 864 // delete twilio address on twitios end 865 $dialbunny_address = $client->addresses(sanitize_text_field(wp_unslash( $_POST['twilio_address_sid'])))->delete(); 866 if ($dialbunny_address) 867 { 868 // delete row 869 $deleted = $wpdb->delete( $wpdb->prefix.'dialbunny_addresses', ['user' => get_current_user_id(),'id' => sanitize_text_field(wp_unslash($_POST['addressidentity']))]); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 870 871 if ( $deleted ) { 872 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 873 } else { 874 wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error3&addressidentity='.sanitize_text_field(wp_unslash( $_POST['addressidentity'])).'&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); 875 } 876 } 877 else { wp_safe_redirect(admin_url('admin.php?page=dialbunny_dashboard&dashboardpage=addresses&error3&addressidentity='.sanitize_text_field(wp_unslash( $_POST['addressidentity'])).'&user_nonce='.sanitize_text_field(wp_unslash($_POST['user_nonce'])))); } 878 }*/ 589 879 } 590 880 ?> -
dialbunny/trunk/lib/controllers/webcalling.php
r3396401 r3406310 78 78 if (isset($_POST['BrowserOutgoing']) && $_POST['BrowserOutgoing'] === 'true') 79 79 { 80 if (!isset($_POST['To'])) { exit; } 80 if (!isset($_POST['To_number'])) { exit; } 81 if (!isset($_POST['To_code'])) { exit; } 81 82 $response = new VoiceResponse(); 82 83 $user_id = filter_input(INPUT_POST, 'User', FILTER_VALIDATE_INT); if ($user_id === false || $user_id === null) { exit; } -
dialbunny/trunk/lib/views/admin/add.php
r3396401 r3406310 10 10 <div class="dialbunny-card"> 11 11 <h2 class="dialbunny-title">Manually Adding Phone Numbers</h2> 12 <p class="dialbunny-description">Follow these steps to manually add a phone number to a user ’s account:</p>12 <p class="dialbunny-description">Follow these steps to manually add a phone number to a user's account:</p> 13 13 <ol class="dialbunny-list"> 14 14 <li>Go to your Twilio account.</li> -
dialbunny/trunk/lib/views/admin/header.php
r3396401 r3406310 1 1 <?php if ( ! defined( 'ABSPATH' ) ) exit; ?> 2 <?php3 4 // Define the page slug (adjust to your plugin's admin page slug)5 $page_slug = 'dialbunny_';6 7 // Define current page8 $current_page = isset($_GET['page']) ? wp_unslash(sanitize_text_field($_GET['page'])) : '';9 10 // Base URL for tabs11 $base_url = admin_url('admin.php?page=' . $page_slug);12 ?>13 2 14 3 <div class="wrap modern-admin-header"> … … 16 5 <h1 class="header-title">DialBunny Admin Settings</h1> 17 6 <div class="header-actions"> 18 <a href="<?php echo esc_url( $base_url. "dashboard"); ?>" class="button button-primary">Dashboard</a>19 <a href="<?php echo esc_url( $base_url. "setup"); ?>" class="button button-secondary">Settings</a>7 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "dashboard"); ?>" class="button button-primary">Dashboard</a> 8 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "setup"); ?>" class="button button-secondary">Settings</a> 20 9 </div> 21 10 </div> 22 11 <div class="tab-container"> 23 12 <div class="tab-nav"> 24 <a href="<?php echo esc_url( $base_url. "setup"); ?>"25 class="tab-button <?php echo $current_page === $page_slug.'setup' ? 'active' : ''; ?><?php echo $current_page === $page_slug.'additional' ? 'active' : ''; ?>">Setup</a>26 <a href="<?php echo esc_url( $base_url. "info"); ?>"27 class="tab-button <?php echo $current_page === $page_slug.'info' ? 'active' : ''; ?><?php echo $current_page === $page_slug.'availability' ? 'active' : ''; ?>">Info</a>28 <a href="<?php echo esc_url( $base_url. "add"); ?>"29 class="tab-button <?php echo $current_page === $page_slug.'add' ? 'active' : ''; ?>">Add</a>30 <a href="<?php echo esc_url( $base_url. "remove"); ?>"31 class="tab-button <?php echo $current_page === $page_slug.'remove' ? 'active' : ''; ?>">Remove</a>32 <a href="<?php echo esc_url( $base_url. "released"); ?>"33 class="tab-button <?php echo $current_page === $page_slug.'released' ? 'active' : ''; ?>">Released</a>34 <a href="<?php echo esc_url( $base_url. "license"); ?>"35 class="tab-button <?php echo $current_page === $page_slug.'license' ? 'active' : ''; ?>">License</a>13 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "setup"); ?>" 14 class="tab-button <?php echo $current_page === 'setup' ? 'active' : ''; ?><?php echo $current_page === 'additional' ? 'active' : ''; ?>">Setup</a> 15 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "info"); ?>" 16 class="tab-button <?php echo $current_page === 'info' ? 'active' : ''; ?><?php echo $current_page === 'availability' ? 'active' : ''; ?>">Info</a> 17 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "add"); ?>" 18 class="tab-button <?php echo $current_page === 'add' ? 'active' : ''; ?>">Add</a> 19 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "remove"); ?>" 20 class="tab-button <?php echo $current_page === 'remove' ? 'active' : ''; ?>">Remove</a> 21 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "released"); ?>" 22 class="tab-button <?php echo $current_page === 'released' ? 'active' : ''; ?>">Released</a> 23 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "license"); ?>" 24 class="tab-button <?php echo $current_page === 'license' ? 'active' : ''; ?>">License</a> 36 25 </div> 37 26 </div> 38 27 39 28 <?php // Sub-tab menu for specific tabs (setup and additional settings) 40 if ($current_page == $page_slug.'setup' || $current_page == $page_slug.'additional') : ?>29 if ($current_page == 'setup' || $current_page == 'additional') : ?> 41 30 <div class="subtab-container"> 42 31 <div class="subtab-nav"> 43 <a href="<?php echo esc_url( $base_url. "setup"); ?>"44 class="subtab-button <?php echo $current_page === $page_slug.'setup' ? 'active' : ''; ?>">API Keys</a>45 <a href="<?php echo esc_url( $base_url. "additional"); ?>"46 class="subtab-button <?php echo $current_page === $page_slug.'additional' ? 'active' : ''; ?>">Additional Settings</a>32 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "setup"); ?>" 33 class="subtab-button <?php echo $current_page === 'setup' ? 'active' : ''; ?>">API Keys</a> 34 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "additional"); ?>" 35 class="subtab-button <?php echo $current_page === 'additional' ? 'active' : ''; ?>">Additional Settings</a> 47 36 </div> 48 37 </div> 49 38 <?php endif; ?> 50 39 <?php // Sub-tab menu for specific tabs (Information) 51 if ($current_page == $page_slug.'info' || $current_page == $page_slug.'availability') : ?>40 if ($current_page == 'info' || $current_page == 'availability') : ?> 52 41 <div class="subtab-container"> 53 42 <div class="subtab-nav"> 54 <a href="<?php echo esc_url( $base_url. "info"); ?>"55 class="subtab-button <?php echo $current_page === $page_slug.'info' ? 'active' : ''; ?>">Information</a>56 <a href="<?php echo esc_url( $base_url. "availability"); ?>"57 class="subtab-button <?php echo $current_page === $page_slug.'availability' ? 'active' : ''; ?>">Number Availability</a>43 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "info"); ?>" 44 class="subtab-button <?php echo $current_page === 'info' ? 'active' : ''; ?>">Information</a> 45 <a href="<?php echo esc_url(admin_url('admin.php?page=' . 'dialbunny_') . "availability"); ?>" 46 class="subtab-button <?php echo $current_page === 'availability' ? 'active' : ''; ?>">Number Availability</a> 58 47 </div> 59 48 </div> -
dialbunny/trunk/lib/views/admin/license.php
r3384851 r3406310 3 3 global $wpdb; 4 4 // Direct database query used below – Safely gets data from the database using $wpdb->prepare() 5 $ keys = $wpdb->get_results($wpdb->prepare("SELECT license_key FROM {$wpdb->prefix}dialbunny_api_keys WHERE id = %s LIMIT 1", 'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery5 $dialbunny_keys = $wpdb->get_results($wpdb->prepare("SELECT license_key FROM {$wpdb->prefix}dialbunny_api_keys WHERE id = %s LIMIT 1", 'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 6 6 ?> 7 7 … … 9 9 <?php 10 10 // Display notice based on license key validation 11 if (isset($ keys[0]->license_key) && strlen($keys[0]->license_key) == 27 && stripos($keys[0]->license_key, 'd') !== false) {11 if (isset($dialbunny_keys[0]->license_key) && strlen($dialbunny_keys[0]->license_key) == 27 && stripos($dialbunny_keys[0]->license_key, 'd') !== false) { 12 12 echo '<div class="dialbunny-notice dialbunny-notice-success"><p><strong>License Key is Active!</strong> Your license code is active!</p><button class="dialbunny-notice-dismiss">Dismiss</button></div>'; 13 13 } else { … … 30 30 <label for="license_key" class="dialbunny-label">License Key</label> 31 31 <input required type="text" name="license_key" id="license_key" placeholder="Enter your license key" 32 value="<?php if (isset($ keys[0]->license_key)) { echo esc_html($keys[0]->license_key); } ?>"32 value="<?php if (isset($dialbunny_keys[0]->license_key)) { echo esc_html($dialbunny_keys[0]->license_key); } ?>" 33 33 class="dialbunny-input"> 34 34 </div> -
dialbunny/trunk/lib/views/admin/released.php
r3384851 r3406310 2 2 <?php 3 3 global $wpdb; 4 $ table = $wpdb->prefix . 'dialbunny_released_numbers';5 $ records = $wpdb->get_results("SELECT id, countrycode, phone FROM {$table} LIMIT 50"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery4 $dialbunny_table = $wpdb->prefix . 'dialbunny_released_numbers'; 5 $dialbunny_records = $wpdb->get_results("SELECT id, countrycode, phone FROM {$dialbunny_table} LIMIT 50"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 6 6 ?> 7 7 … … 27 27 <div class="dialbunny-card"> 28 28 <h2 class="dialbunny-title">Released Numbers</h2> 29 <?php if (!empty($ records)) : ?>29 <?php if (!empty($dialbunny_records)) : ?> 30 30 <div class="dialbunny-table-container"> 31 31 <table class="dialbunny-table"> … … 37 37 </thead> 38 38 <tbody> 39 <?php foreach ($ records as $record) :40 $id = intval($record->id);41 $ countrycode = esc_html($record->countrycode);42 $ phone = esc_html($record->phone);43 $ fullNumber = $countrycode . $phone;39 <?php foreach ($dialbunny_records as $dialbunny_record) : 40 $id = $dialbunny_record->id; 41 $dialbunny_countrycode = esc_html($dialbunny_record->countrycode); 42 $dialbunny_phone = esc_html($dialbunny_record->phone); 43 $dialbunny_fullNumber = $dialbunny_countrycode . $dialbunny_phone; 44 44 ?> 45 45 <tr> 46 <td><?php echo esc_html($ fullNumber); ?></td>46 <td><?php echo esc_html($dialbunny_fullNumber); ?></td> 47 47 <td> 48 48 <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post" class="dialbunny-form-inline"> … … 50 50 <input type="hidden" name="action" value="dialbunny_remove_released"> 51 51 <input type="hidden" name="idValue" value="<?php echo esc_attr($id); ?>"> 52 <input type="hidden" name="phone" value="<?php echo esc_attr($ fullNumber); ?>">52 <input type="hidden" name="phone" value="<?php echo esc_attr($dialbunny_fullNumber); ?>"> 53 53 <button type="submit" class="dialbunny-button dialbunny-button-delete">Remove Permanently</button> 54 54 </form> -
dialbunny/trunk/lib/views/admin/setup.php
r3384851 r3406310 2 2 <?php 3 3 global $wpdb; 4 $ table = $wpdb->prefix . 'dialbunny_api_keys';5 $ keys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table} WHERE id = %s LIMIT 1", 'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery6 $d ecrypt = new DialBunnyKeysClass();4 $dialbunny_table = $wpdb->prefix . 'dialbunny_api_keys'; 5 $dialbunny_keys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$dialbunny_table} WHERE id = %s LIMIT 1", 'ACWJB59')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 6 $dialbunny_decrypt = new DialBunnyKeysClass(); 7 7 ?> 8 8 … … 26 26 <label for="twilio_sid" class="dialbunny-label">Twilio SID</label> 27 27 <input required type="password" name="TWILIO_SID" id="twilio_sid" 28 value="<?php if (isset($ keys[0]->twilio_sid)) { echo esc_html($decrypt->decrypt_data($keys[0]->twilio_sid)); } ?>"28 value="<?php if (isset($dialbunny_keys[0]->twilio_sid)) { echo esc_html($dialbunny_decrypt->decrypt_data($dialbunny_keys[0]->twilio_sid)); } ?>" 29 29 placeholder="Enter Twilio SID" class="dialbunny-input"> 30 30 </div> … … 32 32 <label for="twilio_token" class="dialbunny-label">Twilio Auth Token</label> 33 33 <input required type="password" name="TWILIO_TOKEN" id="twilio_token" 34 value="<?php if (isset($ keys[0]->twilio_token)) { echo esc_html($decrypt->decrypt_data($keys[0]->twilio_token)); } ?>"34 value="<?php if (isset($dialbunny_keys[0]->twilio_token)) { echo esc_html($dialbunny_decrypt->decrypt_data($dialbunny_keys[0]->twilio_token)); } ?>" 35 35 placeholder="Enter Twilio Auth Token" class="dialbunny-input"> 36 36 </div> … … 49 49 <label for="twiml_app_sid" class="dialbunny-label">TwiML App SID</label> 50 50 <input type="password" name="TwiML_App_SID" id="twiml_app_sid" 51 value="<?php if (isset($ keys[0]->TwiML_App_SID)) { echo esc_html($decrypt->decrypt_data($keys[0]->TwiML_App_SID)); } ?>"51 value="<?php if (isset($dialbunny_keys[0]->TwiML_App_SID)) { echo esc_html($dialbunny_decrypt->decrypt_data($dialbunny_keys[0]->TwiML_App_SID)); } ?>" 52 52 placeholder="Enter TwiML App SID" class="dialbunny-input"> 53 53 </div> … … 61 61 <label for="api_key" class="dialbunny-label">API SID Key</label> 62 62 <input type="password" name="API_KEY" id="api_key" 63 value="<?php if (isset($ keys[0]->API_KEY)) { echo esc_html($decrypt->decrypt_data($keys[0]->API_KEY)); } ?>"63 value="<?php if (isset($dialbunny_keys[0]->API_KEY)) { echo esc_html($dialbunny_decrypt->decrypt_data($dialbunny_keys[0]->API_KEY)); } ?>" 64 64 placeholder="Enter API SID Key" class="dialbunny-input"> 65 65 </div> … … 67 67 <label for="api_secret" class="dialbunny-label">API Secret</label> 68 68 <input type="password" name="API_SECRET" id="api_secret" 69 value="<?php if (isset($ keys[0]->API_SECRET)) { echo esc_html($decrypt->decrypt_data($keys[0]->API_SECRET)); } ?>"69 value="<?php if (isset($dialbunny_keys[0]->API_SECRET)) { echo esc_html($dialbunny_decrypt->decrypt_data($dialbunny_keys[0]->API_SECRET)); } ?>" 70 70 placeholder="Enter API Secret" class="dialbunny-input"> 71 71 </div> -
dialbunny/trunk/lib/views/dashboard/ai_assistant.php
r3384851 r3406310 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 $ table = $wpdb->prefix . 'dialbunny_phone_details';6 $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details'; 7 7 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 8 $ saveData = $wpdb->get_results($wpdb->prepare("SELECT voice_assistant FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery9 $d ecodedData = json_decode($saveData[0]->voice_assistant, true);8 $dialbunny_saveData = $wpdb->get_results($wpdb->prepare("SELECT voice_assistant FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 9 $dialbunny_decodedData = json_decode($dialbunny_saveData[0]->voice_assistant, true); 10 10 ?> 11 11 <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your AI assistant settings.")); } ?> … … 109 109 <label class="col-12 col-form-label fw-semibold fs-6">SID:</label> 110 110 <div class="col-12"> 111 <input type="text" maxlength="250" name="twilio_sid" class="form-control form-control-lg form-control-solid" placeholder="Twilio Assistant SID" value="<?php if (isset($d ecodedData['twilio_sid'])) { echo esc_html($decodedData['twilio_sid']); } ?>" />111 <input type="text" maxlength="250" name="twilio_sid" class="form-control form-control-lg form-control-solid" placeholder="Twilio Assistant SID" value="<?php if (isset($dialbunny_decodedData['twilio_sid'])) { echo esc_html($dialbunny_decodedData['twilio_sid']); } ?>" /> 112 112 </div> 113 113 </div> … … 135 135 <label class="col-12 col-form-label fw-semibold fs-6">Inbound SIP Url:</label> 136 136 <div class="col-12"> 137 <input type="text" maxlength="250" name="vapi_sip" class="form-control form-control-lg form-control-solid" placeholder="Vapi Assistant SIP Url" value="<?php if (isset($d ecodedData['vapi_sip'])) { echo esc_html($decodedData['vapi_sip']); } ?>" />137 <input type="text" maxlength="250" name="vapi_sip" class="form-control form-control-lg form-control-solid" placeholder="Vapi Assistant SIP Url" value="<?php if (isset($dialbunny_decodedData['vapi_sip'])) { echo esc_html($dialbunny_decodedData['vapi_sip']); } ?>" /> 138 138 </div> 139 139 </div> … … 199 199 <div class="mb-10 cursor-pointer"> 200 200 <div class="form-check cursor-pointer"> 201 <input class="form-check-input cursor-pointer" type="radio" value="twilio" id="flexCheckDefault1" name="radio" <?php if (isset($d ecodedData['voice_company']) && $decodedData['voice_company'] == 'twilio') { echo 'checked="checked"'; } ?>>201 <input class="form-check-input cursor-pointer" type="radio" value="twilio" id="flexCheckDefault1" name="radio" <?php if (isset($dialbunny_decodedData['voice_company']) && $dialbunny_decodedData['voice_company'] == 'twilio') { echo 'checked="checked"'; } ?>> 202 202 <label class="fs-5 text-gray-900 fw-semibold cursor-pointer" for="flexCheckDefault1">Twilio</label> 203 203 </div> … … 205 205 <div class="cursor-pointer"> 206 206 <div class="form-check cursor-pointer"> 207 <input class="form-check-input cursor-pointer" type="radio" value="vapi" id="flexCheckDefault2" name="radio" <?php if (isset($d ecodedData['voice_company']) && $decodedData['voice_company'] == 'vapi') { echo 'checked="checked"'; } ?>>207 <input class="form-check-input cursor-pointer" type="radio" value="vapi" id="flexCheckDefault2" name="radio" <?php if (isset($dialbunny_decodedData['voice_company']) && $dialbunny_decodedData['voice_company'] == 'vapi') { echo 'checked="checked"'; } ?>> 208 208 <label class="fs-5 text-gray-900 fw-semibold cursor-pointer" for="flexCheckDefault2">Vapi</label> 209 209 </div> … … 236 236 <div class="col-sm-6"> 237 237 <div class="form-check form-switch form-check-custom form-check-solid me-10"> 238 <input role="button" class="form-check-input h-20px w-30px hover::primary" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($d ecodedData['ai_initiated']) && $decodedData['ai_initiated'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="initiated"/>238 <input role="button" class="form-check-input h-20px w-30px hover::primary" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($dialbunny_decodedData['ai_initiated']) && $dialbunny_decodedData['ai_initiated'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="initiated"/> 239 239 </div> 240 240 </div> … … 248 248 <div class="col-sm-6"> 249 249 <div class="form-check form-switch form-check-custom form-check-solid me-10"> 250 <input role="button" class="form-check-input h-20px w-30px" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($d ecodedData['ai_busy']) && $decodedData['ai_busy'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="busy" />250 <input role="button" class="form-check-input h-20px w-30px" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($dialbunny_decodedData['ai_busy']) && $dialbunny_decodedData['ai_busy'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="busy" /> 251 251 </div> 252 252 </div> … … 260 260 <div class="col-sm-6"> 261 261 <div class="form-check form-switch form-check-custom form-check-solid me-10"> 262 <input role="button" class="form-check-input h-20px w-30px" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($d ecodedData['ai_timetable']) && $decodedData['ai_timetable'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="timetable"/>262 <input role="button" class="form-check-input h-20px w-30px" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($dialbunny_decodedData['ai_timetable']) && $dialbunny_decodedData['ai_timetable'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="timetable"/> 263 263 </div> 264 264 </div> … … 287 287 <label class="col-12 col-form-label fw-semibold fs-6">Greeting Message:</label> 288 288 <div class="col-12"> 289 <input id="phoneNumber" type="text" maxlength="250" name="greeting" class="form-control form-control-lg form-control-solid" placeholder="Hi! Ask me anything!" value="<?php if (!empty($d ecodedData['greeting'])) { echo esc_html($decodedData['greeting']); } else { echo 'Hi! Ask me anything!'; } ?>" />289 <input id="phoneNumber" type="text" maxlength="250" name="greeting" class="form-control form-control-lg form-control-solid" placeholder="Hi! Ask me anything!" value="<?php if (!empty($dialbunny_decodedData['greeting'])) { echo esc_html($dialbunny_decodedData['greeting']); } else { echo 'Hi! Ask me anything!'; } ?>" /> 290 290 </div> 291 291 </div> … … 293 293 <label class="col-12 col-form-label fw-semibold fs-6">Voice:</label> 294 294 <div class="col-12"> 295 <input id="phoneNumber" type="text" maxlength="25" name="voice" class="form-control form-control-lg form-control-solid" placeholder="en-US-Journey-O" value="<?php if (!empty($d ecodedData['voice'])) { echo esc_html($decodedData['voice']); } else { echo 'en-US-Journey-O'; } ?>" />295 <input id="phoneNumber" type="text" maxlength="25" name="voice" class="form-control form-control-lg form-control-solid" placeholder="en-US-Journey-O" value="<?php if (!empty($dialbunny_decodedData['voice'])) { echo esc_html($dialbunny_decodedData['voice']); } else { echo 'en-US-Journey-O'; } ?>" /> 296 296 </div> 297 297 </div> … … 364 364 <div class="col-sm-6"> 365 365 <div class="form-check form-switch form-check-custom form-check-solid me-10"> 366 <input role="button" class="form-check-input h-20px w-30px hover::primary" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($d ecodedData['ai_messages']) && $decodedData['ai_messages'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="messages"/>366 <input role="button" class="form-check-input h-20px w-30px hover::primary" type="checkbox" onclick="dialbunny_changeCheckboxValue(this)" <?php if (isset($dialbunny_decodedData['ai_messages']) && $dialbunny_decodedData['ai_messages'] == "1") { echo 'checked="checked" value="1"'; } else { echo 'value="0"'; } ?> name="messages"/> 367 367 </div> 368 368 </div> -
dialbunny/trunk/lib/views/dashboard/calendar.php
r3325864 r3406310 62 62 63 63 <?php 64 $ table = $wpdb->prefix . 'dialbunny_phone_details';65 $ user_id = get_current_user_id();64 $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details'; 65 $dialbunny_user_id = get_current_user_id(); 66 66 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 67 $ saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery68 $ json_data;69 if (isset($ saveData[0]->business_hours)) { $json_data = json_decode($saveData[0]->business_hours); }67 $dialbunny_saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $dialbunny_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 68 $dialbunny_json_data; 69 if (isset($dialbunny_saveData[0]->business_hours)) { $dialbunny_json_data = json_decode($dialbunny_saveData[0]->business_hours); } 70 70 ?> 71 71 <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your timetable settings.")); } ?> … … 90 90 <div class="row mb-6"> 91 91 <label class="col-lg-3 col-form-label fw-semibold fs-6">Sunday </label> <?php 92 if (isset($ json_data->sunday_status) && $json_data->sunday_status == 1)92 if (isset($dialbunny_json_data->sunday_status) && $dialbunny_json_data->sunday_status == 1) 93 93 { 94 94 echo '<div class="col-lg-1 col-form-label"><button id="sunday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 95 95 echo '<input id="sunday_status" type="hidden" name="sunday_status" value="1"></input>'; 96 96 } 97 else if (isset($ json_data->sunday_status) && $json_data->sunday_status == 0)97 else if (isset($dialbunny_json_data->sunday_status) && $dialbunny_json_data->sunday_status == 0) 98 98 { 99 99 echo '<div class="col-lg-1 col-form-label"><button id="sunday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 108 108 <div class="row"> 109 109 <div class="col-lg-6 fv-row"> 110 <input id="sunday1" <?php if (isset($ json_data->sunday_status) && $json_data->sunday_status == 0) { echo 'readonly'; } ?> type="time" name="sunday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->sunday1)) { echo esc_html($json_data->sunday1); } ?>" />111 </div> 112 <div class="col-lg-6 fv-row"> 113 <input id="sunday2" <?php if (isset($ json_data->sunday_status) && $json_data->sunday_status == 0) { echo 'readonly'; } ?> type="time" name="sunday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->sunday2)) { echo esc_html($json_data->sunday2); } ?>" />110 <input id="sunday1" <?php if (isset($dialbunny_json_data->sunday_status) && $dialbunny_json_data->sunday_status == 0) { echo 'readonly'; } ?> type="time" name="sunday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->sunday1)) { echo esc_html($dialbunny_json_data->sunday1); } ?>" /> 111 </div> 112 <div class="col-lg-6 fv-row"> 113 <input id="sunday2" <?php if (isset($dialbunny_json_data->sunday_status) && $dialbunny_json_data->sunday_status == 0) { echo 'readonly'; } ?> type="time" name="sunday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->sunday2)) { echo esc_html($dialbunny_json_data->sunday2); } ?>" /> 114 114 </div> 115 115 </div> … … 119 119 <div class="row mb-6"> 120 120 <label class="col-lg-3 col-form-label fw-semibold fs-6">Monday</label> <?php 121 if (isset($ json_data->monday_status) && $json_data->monday_status == 1)121 if (isset($dialbunny_json_data->monday_status) && $dialbunny_json_data->monday_status == 1) 122 122 { 123 123 echo '<div class="col-lg-1 col-form-label"><button id="monday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 124 124 echo '<input id="monday_status" type="hidden" name="monday_status" value="1"></input>'; 125 125 } 126 else if (isset($ json_data->monday_status) && $json_data->monday_status == 0)126 else if (isset($dialbunny_json_data->monday_status) && $dialbunny_json_data->monday_status == 0) 127 127 { 128 128 echo '<div class="col-lg-1 col-form-label"><button id="monday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 137 137 <div class="row"> 138 138 <div class="col-lg-6 fv-row"> 139 <input id="monday1" <?php if (isset($ json_data->monday_status) && $json_data->monday_status == 0) { echo 'readonly'; } ?> type="time" name="monday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->monday1)) { echo esc_html($json_data->monday1); } ?>" />140 </div> 141 <div class="col-lg-6 fv-row"> 142 <input id="monday2" <?php if (isset($ json_data->monday_status) && $json_data->monday_status == 0) { echo 'readonly'; } ?> type="time" name="monday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->monday2)) { echo esc_html($json_data->monday2); } ?>" />139 <input id="monday1" <?php if (isset($dialbunny_json_data->monday_status) && $dialbunny_json_data->monday_status == 0) { echo 'readonly'; } ?> type="time" name="monday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->monday1)) { echo esc_html($dialbunny_json_data->monday1); } ?>" /> 140 </div> 141 <div class="col-lg-6 fv-row"> 142 <input id="monday2" <?php if (isset($dialbunny_json_data->monday_status) && $dialbunny_json_data->monday_status == 0) { echo 'readonly'; } ?> type="time" name="monday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->monday2)) { echo esc_html($dialbunny_json_data->monday2); } ?>" /> 143 143 </div> 144 144 </div> … … 147 147 <div class="row mb-6"> 148 148 <label class="col-lg-3 col-form-label fw-semibold fs-6">Tuesday</label> <?php 149 if (isset($ json_data->tuesday_status) && $json_data->tuesday_status == 1)149 if (isset($dialbunny_json_data->tuesday_status) && $dialbunny_json_data->tuesday_status == 1) 150 150 { 151 151 echo '<div class="col-lg-1 col-form-label"><button id="tuesday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 152 152 echo '<input id="tuesday_status" type="hidden" name="tuesday_status" value="1"></input>'; 153 153 } 154 else if (isset($ json_data->tuesday_status) && $json_data->tuesday_status == 0)154 else if (isset($dialbunny_json_data->tuesday_status) && $dialbunny_json_data->tuesday_status == 0) 155 155 { 156 156 echo '<div class="col-lg-1 col-form-label"><button id="tuesday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 165 165 <div class="row"> 166 166 <div class="col-lg-6 fv-row"> 167 <input id="tuesday1" <?php if (isset($ json_data->tuesday_status) && $json_data->tuesday_status == 0) { echo 'readonly'; } ?> type="time" name="tuesday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->tuesday1)) { echo esc_html($json_data->tuesday1); } ?>" />168 </div> 169 <div class="col-lg-6 fv-row"> 170 <input id="tuesday2" <?php if (isset($ json_data->tuesday_status) && $json_data->tuesday_status == 0) { echo 'readonly'; } ?> type="time" name="tuesday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->tuesday2)) { echo esc_html($json_data->tuesday2); } ?>" />167 <input id="tuesday1" <?php if (isset($dialbunny_json_data->tuesday_status) && $dialbunny_json_data->tuesday_status == 0) { echo 'readonly'; } ?> type="time" name="tuesday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->tuesday1)) { echo esc_html($dialbunny_json_data->tuesday1); } ?>" /> 168 </div> 169 <div class="col-lg-6 fv-row"> 170 <input id="tuesday2" <?php if (isset($dialbunny_json_data->tuesday_status) && $dialbunny_json_data->tuesday_status == 0) { echo 'readonly'; } ?> type="time" name="tuesday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->tuesday2)) { echo esc_html($dialbunny_json_data->tuesday2); } ?>" /> 171 171 </div> 172 172 </div> … … 175 175 <div class="row mb-6"> 176 176 <label class="col-lg-3 col-form-label fw-semibold fs-6">Wednesday</label> <?php 177 if (isset($ json_data->wednesday_status) && $json_data->wednesday_status == 1)177 if (isset($dialbunny_json_data->wednesday_status) && $dialbunny_json_data->wednesday_status == 1) 178 178 { 179 179 echo '<div class="col-lg-1 col-form-label"><button id="wednesday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 180 180 echo '<input id="wednesday_status" type="hidden" name="wednesday_status" value="1"></input>'; 181 181 } 182 else if (isset($ json_data->wednesday_status) && $json_data->wednesday_status == 0)182 else if (isset($dialbunny_json_data->wednesday_status) && $dialbunny_json_data->wednesday_status == 0) 183 183 { 184 184 echo '<div class="col-lg-1 col-form-label"><button id="wednesday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 193 193 <div class="row"> 194 194 <div class="col-lg-6 fv-row"> 195 <input id="wednesday1" <?php if (isset($ json_data->wednesday_status) && $json_data->wednesday_status == 0) { echo 'readonly'; } ?> type="time" name="wednesday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->wednesday1)) { echo esc_html($json_data->wednesday1); } ?>" />196 </div> 197 <div class="col-lg-6 fv-row"> 198 <input id="wednesday2" <?php if (isset($ json_data->wednesday_status) && $json_data->wednesday_status == 0) { echo 'readonly'; } ?> type="time" name="wednesday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->wednesday2)) { echo esc_html($json_data->wednesday2); } ?>" />195 <input id="wednesday1" <?php if (isset($dialbunny_json_data->wednesday_status) && $dialbunny_json_data->wednesday_status == 0) { echo 'readonly'; } ?> type="time" name="wednesday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->wednesday1)) { echo esc_html($dialbunny_json_data->wednesday1); } ?>" /> 196 </div> 197 <div class="col-lg-6 fv-row"> 198 <input id="wednesday2" <?php if (isset($dialbunny_json_data->wednesday_status) && $dialbunny_json_data->wednesday_status == 0) { echo 'readonly'; } ?> type="time" name="wednesday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->wednesday2)) { echo esc_html($dialbunny_json_data->wednesday2); } ?>" /> 199 199 </div> 200 200 </div> … … 203 203 <div class="row mb-6"> 204 204 <label class="col-lg-3 col-form-label fw-semibold fs-6">Thursday</label> <?php 205 if (isset($ json_data->thursday_status) && $json_data->thursday_status == 1)205 if (isset($dialbunny_json_data->thursday_status) && $dialbunny_json_data->thursday_status == 1) 206 206 { 207 207 echo '<div class="col-lg-1 col-form-label"><button id="thursday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 208 208 echo '<input id="thursday_status" type="hidden" name="thursday_status" value="1"></input>'; 209 209 } 210 else if (isset($ json_data->thursday_status) && $json_data->thursday_status == 0)210 else if (isset($dialbunny_json_data->thursday_status) && $dialbunny_json_data->thursday_status == 0) 211 211 { 212 212 echo '<div class="col-lg-1 col-form-label"><button id="thursday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 221 221 <div class="row"> 222 222 <div class="col-lg-6 fv-row"> 223 <input id="thursday1" <?php if (isset($ json_data->thursday_status) && $json_data->thursday_status == 0) { echo 'readonly'; } ?> type="time" name="thursday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->thursday1)) { echo esc_html($json_data->thursday1); } ?>" />224 </div> 225 <div class="col-lg-6 fv-row"> 226 <input id="thursday2" <?php if (isset($ json_data->thursday_status) && $json_data->thursday_status == 0) { echo 'readonly'; } ?> type="time" name="thursday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->thursday2)) { echo esc_html($json_data->thursday2); } ?>" />223 <input id="thursday1" <?php if (isset($dialbunny_json_data->thursday_status) && $dialbunny_json_data->thursday_status == 0) { echo 'readonly'; } ?> type="time" name="thursday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->thursday1)) { echo esc_html($dialbunny_json_data->thursday1); } ?>" /> 224 </div> 225 <div class="col-lg-6 fv-row"> 226 <input id="thursday2" <?php if (isset($dialbunny_json_data->thursday_status) && $dialbunny_json_data->thursday_status == 0) { echo 'readonly'; } ?> type="time" name="thursday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->thursday2)) { echo esc_html($dialbunny_json_data->thursday2); } ?>" /> 227 227 </div> 228 228 </div> … … 231 231 <div class="row mb-6"> 232 232 <label class="col-lg-3 col-form-label fw-semibold fs-6">Friday</label> <?php 233 if (isset($ json_data->friday_status) && $json_data->friday_status == 1)233 if (isset($dialbunny_json_data->friday_status) && $dialbunny_json_data->friday_status == 1) 234 234 { 235 235 echo '<div class="col-lg-1 col-form-label"><button id="friday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 236 236 echo '<input id="friday_status" type="hidden" name="friday_status" value="1"></input>'; 237 237 } 238 else if (isset($ json_data->friday_status) && $json_data->friday_status == 0)238 else if (isset($dialbunny_json_data->friday_status) && $dialbunny_json_data->friday_status == 0) 239 239 { 240 240 echo '<div class="col-lg-1 col-form-label"><button id="friday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 249 249 <div class="row"> 250 250 <div class="col-lg-6 fv-row"> 251 <input id="friday1" <?php if (isset($ json_data->friday_status) && $json_data->friday_status == 0) { echo 'readonly'; } ?> type="time" name="friday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->friday1)) { echo esc_html($json_data->friday1); } ?>" />252 </div> 253 <div class="col-lg-6 fv-row"> 254 <input id="friday2" <?php if (isset($ json_data->friday_status) && $json_data->friday_status == 0) { echo 'readonly'; } ?> type="time" name="friday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->friday2)) { echo esc_html($json_data->friday2); } ?>" />251 <input id="friday1" <?php if (isset($dialbunny_json_data->friday_status) && $dialbunny_json_data->friday_status == 0) { echo 'readonly'; } ?> type="time" name="friday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->friday1)) { echo esc_html($dialbunny_json_data->friday1); } ?>" /> 252 </div> 253 <div class="col-lg-6 fv-row"> 254 <input id="friday2" <?php if (isset($dialbunny_json_data->friday_status) && $dialbunny_json_data->friday_status == 0) { echo 'readonly'; } ?> type="time" name="friday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->friday2)) { echo esc_html($dialbunny_json_data->friday2); } ?>" /> 255 255 </div> 256 256 </div> … … 260 260 <div class="row"> 261 261 <label class="col-lg-3 col-form-label fw-semibold fs-6">Saturday</label> <?php 262 if (isset($ json_data->saturday_status) && $json_data->saturday_status == 1)262 if (isset($dialbunny_json_data->saturday_status) && $dialbunny_json_data->saturday_status == 1) 263 263 { 264 264 echo '<div class="col-lg-1 col-form-label"><button id="saturday" type="button" onclick="changeStatus(this.id);" class="badge badge-success border-0">Open</button></div>'; 265 265 echo '<input id="saturday_status" type="hidden" name="saturday_status" value="1"></input>'; 266 266 } 267 else if (isset($ json_data->saturday_status) && $json_data->saturday_status == 0)267 else if (isset($dialbunny_json_data->saturday_status) && $dialbunny_json_data->saturday_status == 0) 268 268 { 269 269 echo '<div class="col-lg-1 col-form-label"><button id="saturday" type="button" onclick="changeStatus(this.id);" class="badge badge-danger border-0">Closed</button></div>'; … … 278 278 <div class="row"> 279 279 <div class="col-lg-6 fv-row"> 280 <input id="saturday1" <?php if (isset($ json_data->saturday_status) && $json_data->saturday_status == 0) { echo 'readonly'; } ?> type="time" name="saturday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($json_data->saturday1)) { echo esc_html($json_data->saturday1); } ?>" />281 </div> 282 <div class="col-lg-6 fv-row"> 283 <input id="saturday2" <?php if (isset($ json_data->saturday_status) && $json_data->saturday_status == 0) { echo 'readonly'; } ?> type="time" name="saturday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($json_data->saturday2)) { echo esc_html($json_data->saturday2); } ?>" />280 <input id="saturday1" <?php if (isset($dialbunny_json_data->saturday_status) && $dialbunny_json_data->saturday_status == 0) { echo 'readonly'; } ?> type="time" name="saturday1" class="form-control form-control-lg form-control-solid mb-3 mb-lg-0" placeholder="Start Time" value="<?php if (isset($dialbunny_json_data->saturday1)) { echo esc_html($dialbunny_json_data->saturday1); } ?>" /> 281 </div> 282 <div class="col-lg-6 fv-row"> 283 <input id="saturday2" <?php if (isset($dialbunny_json_data->saturday_status) && $dialbunny_json_data->saturday_status == 0) { echo 'readonly'; } ?> type="time" name="saturday2" class="form-control form-control-lg form-control-solid" placeholder="End Time" value="<?php if (isset($dialbunny_json_data->saturday2)) { echo esc_html($dialbunny_json_data->saturday2); } ?>" /> 284 284 </div> 285 285 </div> … … 309 309 <?php 310 310 // Escaped inside the dialbunny_timezone() function 311 if (isset($ saveData[0]->timezone)) { echo dialbunny_timezone($saveData[0]->timezone, 'timezone'); } else { echo dialbunny_timezone('none', 'timezone'); } // phpcs:ignore WordPress.Security.EscapeOutput ?>311 if (isset($dialbunny_saveData[0]->timezone)) { echo dialbunny_timezone($dialbunny_saveData[0]->timezone, 'timezone'); } else { echo dialbunny_timezone('none', 'timezone'); } // phpcs:ignore WordPress.Security.EscapeOutput ?> 312 312 </div> 313 313 </div> -
dialbunny/trunk/lib/views/dashboard/choose.php
r3325864 r3406310 1 1 <?php if ( ! defined( 'ABSPATH' ) ) exit; ?> 2 <?php if ( !isset($_GET['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['user_nonce'])), 'DialBunny') ) { echo 'Sorry, we couldn ’t verify your request due to a security check failure.'; return; } ?>2 <?php if ( !isset($_GET['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['user_nonce'])), 'DialBunny') ) { echo 'Sorry, we couldn\'t verify your request due to a security check failure.'; return; } ?> 3 3 <div class="content d-flex flex-column flex-column-fluid" id="content"> 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 6 use Twilio\Rest\Client; 7 $keys = new DialBunnyKeysClass(); 8 $sid = $keys->TWILIO_SID(); 9 $token = $keys->TWILIO_TOKEN(); 10 $client = null; 11 $data = []; 12 $errorMessage = false; 13 if (!empty($sid) && !empty($token)) { 14 $client = new Client($sid, $token); 7 $dialbunny_keys = new DialBunnyKeysClass(); 8 $dialbunny_sid = $dialbunny_keys->TWILIO_SID(); 9 $dialbunny_token = $dialbunny_keys->TWILIO_TOKEN(); 10 $dialbunny_client = null; 11 $dialbunny_data = []; 12 $dialbunny_errorMessage = false; 13 $dialbunny_address_items = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_addresses WHERE user = %d limit 50", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 14 if (!empty($dialbunny_sid) && !empty($dialbunny_token)) { 15 $dialbunny_client = new Client($dialbunny_sid, $dialbunny_token); 15 16 } 16 $searchData = [ 17 //'excludeAllAddressRequired' => false, 18 //'smsEnabled' => true, 19 'voiceEnabled' => true, 20 ]; 17 // Address Requirements Filter 18 $dialbunny_searchData = []; 19 if ( isset( $_GET['requirements'] ) ) { 20 $req = sanitize_text_field( wp_unslash( $_GET['requirements'] ) ); 21 switch ( $req ) { 22 case 'none': 23 // Only show numbers that require NO address at all 24 $dialbunny_searchData['excludeAllAddressRequired'] = true; 25 $dialbunny_searchData['excludeLocalAddressRequired'] = false; 26 $dialbunny_searchData['excludeForeignAddressRequired'] = false; 27 break; 28 29 case 'local': 30 // Hide numbers that require a LOCAL address (most restrictive) 31 $dialbunny_searchData['excludeLocalAddressRequired'] = true; 32 break; 33 34 case 'foreign': 35 // Hide numbers that require a FOREIGN address 36 $dialbunny_searchData['excludeForeignAddressRequired'] = true; 37 break; 38 39 case 'any': 40 default: 41 break; 42 } 43 } 44 if ( isset( $_GET['beta'] ) && sanitize_text_field( wp_unslash( $_GET['beta'] ) ) === 'none' ) { 45 $dialbunny_searchData['beta'] = false; // Exclude beta numbers 46 } 21 47 if (!empty($_GET['areacode'])) { 22 $ searchData['areaCode'] = sanitize_text_field(wp_unslash($_GET['areacode']));48 $dialbunny_searchData['areaCode'] = sanitize_text_field(wp_unslash($_GET['areacode'])); 23 49 } 24 50 25 51 if (!empty($_GET['contains'])) { 26 $ searchData['contains'] = sanitize_text_field(wp_unslash($_GET['contains']));52 $dialbunny_searchData['contains'] = sanitize_text_field(wp_unslash($_GET['contains'])); 27 53 } 28 if (!empty($_GET['countrycode']) && !empty($_GET['type']) && $ client) {29 $ countryCode = sanitize_text_field(wp_unslash($_GET['countrycode']));54 if (!empty($_GET['countrycode']) && !empty($_GET['type']) && $dialbunny_client) { 55 $dialbunny_countryCode = sanitize_text_field(wp_unslash($_GET['countrycode'])); 30 56 $type = sanitize_text_field(wp_unslash($_GET['type'])); 31 32 57 try { 33 58 switch ($type) { 59 case 'all': 60 $dialbunny_local_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->local->read($dialbunny_searchData, 5); 61 $dialbunny_tollFree_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->tollFree->read($dialbunny_searchData, 5); 62 $dialbunny_mobile_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->mobile->read($dialbunny_searchData, 5); 63 break; 34 64 case 'local': 35 $d ata = $client->availablePhoneNumbers($countryCode)->local->read($searchData, 15);65 $dialbunny_local_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->local->read($dialbunny_searchData, 15); 36 66 break; 37 67 case 'TollFree': 38 $d ata = $client->availablePhoneNumbers($countryCode)->tollFree->read($searchData, 15);68 $dialbunny_tollFree_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->tollFree->read($dialbunny_searchData, 15); 39 69 break; 40 70 case 'mobile': 41 $d ata = $client->availablePhoneNumbers($countryCode)->mobile->read($searchData, 15);71 $dialbunny_mobile_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->mobile->read($dialbunny_searchData, 15); 42 72 break; 43 73 } 44 74 } catch (Exception $e) { 45 $ errorMessage = true;75 $dialbunny_errorMessage = true; 46 76 } 47 77 } 48 78 ?> 79 <?php if (isset($_GET['addressrequired'])) { echo wp_kses_post(dialbunny_main_danger("Address & Bundle Required", "A valid address and bundle is required to get the requested phone number. Go to Twilio and create a local address and bundle and then add the SID's when requesting the phone number again.")); } ?> 49 80 <?php if (isset($_GET['erroraddingnumber'])) { echo wp_kses_post(dialbunny_main_danger("Phone Number Could Not Be Added", "An error has occurred and we could not process your request.")); } ?> 50 <?php if (!isset($ client)) { echo wp_kses_post(dialbunny_main_danger("Twilio API Keys Not Setup", "Missing or incorrect twilio api credentials.")); } ?>81 <?php if (!isset($dialbunny_client)) { echo wp_kses_post(dialbunny_main_danger("Twilio API Keys Not Setup", "Missing or incorrect twilio api credentials.")); } ?> 51 82 <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" class="form"> 52 83 <?php wp_nonce_field( 'DialBunny', 'user_nonce' ); ?> … … 56 87 <div class="d-flex align-items-center"> 57 88 <div class="position-relative w-md-400px me-2"> 58 <select name="countrycode" aria-label="Select a Country Code" data-placeholder="Select A Country Code" class="form-select form-select-solid form-select-lg fw-semibold mb-0 mb-lg-0"> 59 <option data-countryCode="CA" <?php if (isset($_GET['countrycode']) && sanitize_text_field(wp_unslash($_GET['countrycode'])) == 'CA') { echo 'selected'; } ?> value="CA">Canada</option> 60 <option data-countryCode="US" <?php if ( isset($_GET['countrycode']) && sanitize_text_field(wp_unslash($_GET['countrycode'])) == 'US' ) { echo 'selected'; } ?> value="US" <?php if (!isset($_GET['countrycode'])) { echo 'selected'; } ?>>United States </option> 89 <select name="countrycode" data-placeholder="Select A Country Code" class="form-select form-select-solid form-select-lg fw-semibold mb-0 mb-lg-0"> 90 <?php 91 $dialbunny_selected_country = isset($_GET['countrycode']) ? sanitize_text_field(wp_unslash($_GET['countrycode'])) : 'US'; 92 foreach ($dialbunny_countries_list as $dialbunny_code => $dialbunny_label) { 93 $dialbunny_selected = selected($dialbunny_selected_country, $dialbunny_code, false); 94 echo '<option value="' . esc_attr($dialbunny_code) . '" ' . esc_html($dialbunny_selected) . '>' . esc_html($dialbunny_label) . '</option>'; 95 } 96 ?> 61 97 </select> 62 98 </div> 63 99 <div class="d-flex align-items-center"> 64 <button type="submit" class="btn btn-primary me-5">Search</button>100 <button type="submit" onclick="this.innerHTML='<span class="spinner-border spinner-border-sm"></span> Searching...'; this.disabled=true; this.form.submit();" class="btn btn-primary me-5">Search</button> 65 101 </div> 66 102 </div> … … 68 104 <div class="separator separator-dashed mt-9 mb-6"></div> 69 105 <div class="row g-8" data-select2-id="select2-data-123-mnoi"> 70 <div class="col-lg- 4">106 <div class="col-lg-3"> 71 107 <label class="fs-6 form-label fw-bold text-gray-900"> 72 108 <span class="">Area Code</span> … … 77 113 </span> 78 114 </label> 79 <input type="number" value="<?php if (isset($_GET['areacode'])) { echo esc_html(sanitize_text_field(wp_unslash($_GET['areacode']))); } ?>" class="form-control form-control form-control-solid" name="areacode" >80 </div> 81 <div class="col-lg- 4">115 <input type="number" value="<?php if (isset($_GET['areacode'])) { echo esc_html(sanitize_text_field(wp_unslash($_GET['areacode']))); } ?>" class="form-control form-control form-control-solid" name="areacode" placeholder="Area Code"> 116 </div> 117 <div class="col-lg-3"> 82 118 <label class="fs-6 form-label fw-bold text-gray-900"> 83 119 <span class="">Contains</span> … … 88 124 </span> 89 125 </label> 90 <input type="text" value="<?php if (isset($_GET['contains'])) { echo esc_html(sanitize_text_field(wp_unslash($_GET['contains']))); } ?>" class="form-control form-control form-control-solid" name="contains" >91 </div> 92 <div class="col-lg- 4">126 <input type="text" value="<?php if (isset($_GET['contains'])) { echo esc_html(sanitize_text_field(wp_unslash($_GET['contains']))); } ?>" class="form-control form-control form-control-solid" name="contains" placeholder="Contains"> 127 </div> 128 <div class="col-lg-6"> 93 129 <label class="fs-6 form-label fw-bold text-gray-900"> 94 130 <span class="">Type</span> … … 101 137 <div class="nav-group nav-group-fluid"> 102 138 <label> 103 <input type="radio" class="btn-check" name="type" value="local" <?php if (!isset($_GET['type']) || isset($_GET['type']) && sanitize_text_field(wp_unslash($_GET['type'])) == 'local' ) { echo 'checked="checked"'; } ?>> 139 <input type="radio" class="btn-check" name="type" value="all" <?php if (!isset($_GET['type']) || isset($_GET['type']) && sanitize_text_field(wp_unslash($_GET['type'])) == 'all' ) { echo 'checked="checked"'; } ?>> 140 <span class="btn btn-sm btn-color-muted btn-active btn-active-primary fw-bold px-4">All</span> 141 </label> 142 <label> 143 <input type="radio" class="btn-check" name="type" value="local" <?php if (isset($_GET['type']) && sanitize_text_field(wp_unslash($_GET['type'])) == 'local' ) { echo 'checked="checked"'; } ?>> 104 144 <span class="btn btn-sm btn-color-muted btn-active btn-active-primary fw-bold px-4">Local</span> 105 145 </label> … … 115 155 </div> 116 156 </div> 157 <div class="row g-8 mt-3"> 158 <div class="col-lg-3"> 159 <label class="fs-6 form-label fw-bold text-gray-900"> 160 <span class="">Requirements</span> 161 <span class="ms-1" data-bs-toggle="tooltip" title="Some local authorities require you to provide an address before purchasing a phone number."> 162 <i class="fs-6"> 163 <span class="fas fa-info-circle"></span> 164 </i> 165 </span> 166 </label> 167 <select name="addressrequirements" aria-label="Select" data-placeholder="Select" class="form-select form-select-solid form-select-lg fw-semibold mb-0 mb-lg-0"> 168 <option name="addressrequirements" value="any" <?php if (!isset($_GET['requirements']) || isset($_GET['requirements']) && sanitize_text_field(wp_unslash($_GET['requirements'])) == 'any' ) { echo 'selected'; } ?>>Any</option> 169 <option name="addressrequirements" value="none" <?php if (isset($_GET['requirements']) && sanitize_text_field(wp_unslash($_GET['requirements'])) == 'none' ) { echo 'selected'; } ?>>None</option> 170 <option name="addressrequirements" value="local" <?php if (isset($_GET['requirements']) && sanitize_text_field(wp_unslash($_GET['requirements'])) == 'local' ) { echo 'selected'; } ?>>Exclude Local Address Requirements</option> 171 <option name="addressrequirements" value="foreign" <?php if (isset($_GET['requirements']) && sanitize_text_field(wp_unslash($_GET['requirements'])) == 'foreign' ) { echo 'selected'; } ?>>Exclude Foreign Address Requirements</option> 172 </select> 173 </div> 174 <div class="col-lg-3"> 175 <label class="fs-6 form-label fw-bold text-gray-900"> 176 <span class="">Beta Numbers</span> 177 <span class="ms-1" data-bs-toggle="tooltip" title="These are newly released phone numbers on Twilios platform."> 178 <i class="fs-6"> 179 <span class="fas fa-info-circle"></span> 180 </i> 181 </span> 182 </label> 183 <select name="beta" aria-label="Select" data-placeholder="Select" class="form-select form-select-solid form-select-lg fw-semibold mb-0 mb-lg-0"> 184 <option name="beta" value="any" <?php if (!isset($_GET['beta']) || isset($_GET['beta']) && sanitize_text_field(wp_unslash($_GET['beta'])) == 'any' ) { echo 'selected'; } ?>>Any</option> 185 <option name="beta" value="none" <?php if (isset($_GET['beta']) && sanitize_text_field(wp_unslash($_GET['beta'])) == 'none' ) { echo 'selected'; } ?>>Exclude Beta Numbers</option> 186 </select> 187 </div> 188 <div class="col-lg-6"> 189 <label class="fs-6 form-label fw-bold text-gray-900"> 190 <span class="">Capabilities</span> 191 <span class="ms-1" data-bs-toggle="tooltip" title="These are the capabilities of searchable phone numbers."> 192 <i class="fs-6"> 193 <span class="fas fa-info-circle"></span> 194 </i> 195 </span> 196 </label> 197 <div class="nav-group nav-group-fluid p-4"> 198 <input class="form-check-input" type="checkbox" checked><label class="form-check-label px-3" for="drop-remove">Voice</label></input> 199 <input class="form-check-input" type="checkbox" checked><label class="form-check-label px-3" for="drop-remove">SMS</label></input> 200 <input class="form-check-input" type="checkbox" checked><label class="form-check-label px-3" for="drop-remove">MMS</label></input> 201 </div> 202 </div> 203 </div> 117 204 </div> 118 205 </div> … … 127 214 128 215 <div class="table-responsive"> <?php 129 if (isset($_GET['countrycode']) && !empty($data))216 if (isset($_GET['countrycode']) && (!empty($dialbunny_local_data) || !empty($dialbunny_tollFree_data) || !empty($dialbunny_mobile_data))) 130 217 { 131 218 echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">'; … … 135 222 echo '<th>Capabilities</th>'; 136 223 echo '<th>Type</th>'; 137 echo '<th> AddressRequirements</th>';224 echo '<th>Local Regulatory Requirements</th>'; 138 225 echo '<th></th>'; 139 226 echo '</tr>'; 140 227 echo '</thead>'; 141 228 echo '<tbody>'; 142 foreach ($d ata as $record)229 foreach ($dialbunny_local_data as $dialbunny_record) 143 230 { 144 231 echo '<tr class="align-middle">'; 145 echo '<td class="col-3">' . esc_html($ record->friendlyName) . '<br>' . esc_html($record->locality) . ' ' . esc_html($record->region) . '</td>';232 echo '<td class="col-3">' . esc_html($dialbunny_record->friendlyName) . '<br>' . esc_html($dialbunny_record->locality) . ' ' . esc_html($dialbunny_record->region) . '</td>'; 146 233 147 234 echo '<td class="col-2">'; 148 if ($record->capabilities->sms == 1) { echo '<span class="badge badge-success">SMS</span><br>'; } else { echo '<span class="badge badge-danger">SMS</span><br>'; } 149 if ($record->capabilities->voice == 1) { echo '<span class="badge badge-success">VOICE</span>'; } else { echo '<span class="badge badge-danger">VOICE</span>'; } 150 echo '</td>'; 151 if (sanitize_text_field(wp_unslash($_GET['type'])) == 'local') { echo '<td class="col-2">local</td>'; } 152 else if (sanitize_text_field(wp_unslash($_GET['type'])) == 'TollFree') { echo '<td class="col-2">TollFree</td>'; } 153 else if (sanitize_text_field(wp_unslash($_GET['type'])) == 'mobile') { echo '<td class="col-2">mobile</td>'; } 154 echo '<td class="col-2"><span class="badge badge-dark">'. esc_html($record->addressRequirements) .'</span></td>'; 155 echo '<td class="col-2"><button type="button" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($record->phoneNumber) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($record->phoneNumber) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Get Number</button></td>'; 235 if ($dialbunny_record->capabilities->sms == 1) { echo '<span class="badge badge-success">SMS</span><br>'; } else { echo '<span class="badge badge-danger">SMS</span><br>'; } 236 if ($dialbunny_record->capabilities->mms == 1) { echo '<span class="badge badge-success">MMS</span><br>'; } else { echo '<span class="badge badge-danger">MMS</span><br>'; } 237 if ($dialbunny_record->capabilities->voice == 1) { echo '<span class="badge badge-success">VOICE</span>'; } else { echo '<span class="badge badge-danger">VOICE</span>'; } 238 echo '</td>'; 239 echo '<td class="col-2">Local<br>'; 240 if ($dialbunny_record->beta == 1) { echo '<span class="badge badge-danger">Beta</span>'; } 241 echo '</td>'; 242 echo '<td class="col-2"><span class="badge badge-dark">'. esc_html($dialbunny_record->addressRequirements) .'</span></td>'; 243 echo '<td class="col-2"><button type="button" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($dialbunny_record->phoneNumber) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($dialbunny_record->phoneNumber) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Get Number</button></td>'; 244 echo '</tr>'; 245 } 246 foreach ($dialbunny_tollFree_data as $dialbunny_record) 247 { 248 echo '<tr class="align-middle">'; 249 echo '<td class="col-3">' . esc_html($dialbunny_record->friendlyName) . '<br>' . esc_html($dialbunny_record->locality) . ' ' . esc_html($dialbunny_record->region) . '</td>'; 250 251 echo '<td class="col-2">'; 252 if ($dialbunny_record->capabilities->sms == 1) { echo '<span class="badge badge-success">SMS</span><br>'; } else { echo '<span class="badge badge-danger">SMS</span><br>'; } 253 if ($dialbunny_record->capabilities->mms == 1) { echo '<span class="badge badge-success">MMS</span><br>'; } else { echo '<span class="badge badge-danger">MMS</span><br>'; } 254 if ($dialbunny_record->capabilities->voice == 1) { echo '<span class="badge badge-success">VOICE</span>'; } else { echo '<span class="badge badge-danger">VOICE</span>'; } 255 echo '</td>'; 256 echo '<td class="col-2">Toll-Free<br>'; 257 if ($dialbunny_record->beta == 1) { echo '<span class="badge badge-danger">Beta</span>'; } 258 echo '</td>'; 259 echo '<td class="col-2"><span class="badge badge-dark">'. esc_html($dialbunny_record->addressRequirements) .'</span></td>'; 260 echo '<td class="col-2"><button type="button" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($dialbunny_record->phoneNumber) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($dialbunny_record->phoneNumber) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Get Number</button></td>'; 261 echo '</tr>'; 262 } 263 foreach ($dialbunny_mobile_data as $dialbunny_record) 264 { 265 echo '<tr class="align-middle">'; 266 echo '<td class="col-3">' . esc_html($dialbunny_record->friendlyName) . '<br>' . esc_html($dialbunny_record->locality) . ' ' . esc_html($dialbunny_record->region) . '</td>'; 267 268 echo '<td class="col-2">'; 269 if ($dialbunny_record->capabilities->sms == 1) { echo '<span class="badge badge-success">SMS</span><br>'; } else { echo '<span class="badge badge-danger">SMS</span><br>'; } 270 if ($dialbunny_record->capabilities->mms == 1) { echo '<span class="badge badge-success">MMS</span><br>'; } else { echo '<span class="badge badge-danger">MMS</span><br>'; } 271 if ($dialbunny_record->capabilities->voice == 1) { echo '<span class="badge badge-success">VOICE</span>'; } else { echo '<span class="badge badge-danger">VOICE</span>'; } 272 echo '</td>'; 273 echo '<td class="col-2">Mobile<br>'; 274 if ($dialbunny_record->beta == 1) { echo '<span class="badge badge-danger">Beta</span>'; } 275 echo '</td>'; 276 echo '<td class="col-2"><span class="badge badge-dark">'. esc_html($dialbunny_record->addressRequirements) .'</span></td>'; 277 echo '<td class="col-2"><button type="button" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($dialbunny_record->phoneNumber) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($dialbunny_record->phoneNumber) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Get Number</button></td>'; 156 278 echo '</tr>'; 157 279 } … … 159 281 echo '</table>'; 160 282 } 161 else if (isset($_GET['countrycode']) && empty($data))283 else if (isset($_GET['countrycode'])) 162 284 { 163 285 echo '<div class="card border border-gray-300 border-dashed rounded p-6"> … … 171 293 </div>'; 172 294 } 173 else if (!isset($_GET['countrycode']) && empty($data))295 else if (!isset($_GET['countrycode'])) 174 296 { 175 297 echo '<div class="card border border-gray-300 border-dashed rounded p-6"> … … 189 311 </div> 190 312 </div> 191 <div class="modal fade" tabindex="-1" id="modal_1"> 192 <div class="modal-dialog"> 193 <div class="modal-content"> 194 <div class="modal-header pb-0 border-0 justify-content-end"> 195 <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> 196 <i class="fs-1"> 197 <span class="fas fa-times"></span> 198 </i> 199 </div> 200 </div> 201 <div class="modal-body"> 202 <div class="mb-13"> 203 <h1 id="requestedNumberUI" class="mb-3">Get Number</h1> 204 <div class="text-muted fw-semibold fs-5">To get started, just click on "Get Number".</div> 205 </div> 206 <div class="stepper stepper-pills stepper-column d-flex flex-column flex-xl-row flex-row-fluid first" id="modal_create_app_stepper"> 207 <div class="d-flex justify-content-center justify-content-xl-start flex-row-auto w-100 w-xl-300px"> 208 <div class="stepper-nav ps-lg-10"> 209 <div class="stepper-item pending"> 210 <div class="stepper-wrapper"> 211 <div class="stepper-icon w-40px h-40px"> 212 <i class="stepper-check fs-2"></i> 213 <span class="stepper-number">1</span> 214 </div> 215 <div class="stepper-label"> 216 <h3 class="stepper-title">Enjoy Your Number</h3> 217 <div class="stepper-desc">After requesting a number, it will be added to your account allowing you to start making calls almost immediately.</div> 313 314 <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" class="form"> 315 <input type="hidden" name="action" value="dialbunny_request_number"></input> 316 <?php wp_nonce_field( 'DialBunny', 'user_nonce' ); ?> 317 <div class="modal fade" tabindex="-1" id="modal_1"> 318 <div class="modal-dialog"> 319 <div class="modal-content"> 320 <div class="modal-header pb-0 border-0 justify-content-end"> 321 <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> 322 <i class="fs-1"> 323 <span class="fas fa-times"></span> 324 </i> 325 </div> 326 </div> 327 <div class="modal-body"> 328 <div class="mb-13"> 329 <h1 id="requestedNumberUI" class="mb-3">Get Number</h1> 330 <div class="text-muted fw-semibold fs-5">To get started, just click on "Get Number".</div> 331 </div> 332 333 <div class="stepper stepper-pills stepper-column d-flex flex-column flex-xl-row flex-row-fluid first mb-8"> 334 <div class="d-flex justify-content-center justify-content-xl-start flex-row-auto w-100 w-xl-300px"> 335 <div class="stepper-nav ps-lg-10"> 336 <div class="stepper-item pending"> 337 <div class="stepper-wrapper"> 338 <div class="stepper-icon w-40px h-40px"> 339 <i class="stepper-check fs-2"></i> 340 <span class="stepper-number">1</span> 341 </div> 342 <div class="stepper-label"> 343 <h3 class="stepper-title">Associated Costs</h3> 344 <div class="stepper-desc">Twilio charges fees for each phone number which can vary depending on the country of origin. It should also be noted that your Twilio account should be funded before requesting a number.</div> 345 </div> 218 346 </div> 219 347 </div> … … 221 349 </div> 222 350 </div> 223 </div> 224 </div> 225 <div class="modal-footer"> 226 <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button> 227 <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" class="form"> 228 <input type="hidden" name="action" value="dialbunny_request_number"></input> 229 <?php wp_nonce_field( 'DialBunny', 'user_nonce' ); ?> 230 <input type="hidden" name="number" id="requestedNumber"></input> 231 <input type="hidden" name="location" id="requestedLocation"></input> 232 <input type="hidden" name="type" id="requestedType"></input> 233 <button type='submit' class='btn btn-primary'>Get Number</button> 234 </form> 351 <div class="stepper stepper-pills stepper-column d-flex flex-column flex-xl-row flex-row-fluid first mb-8"> 352 <div class="d-flex justify-content-center justify-content-xl-start flex-row-auto w-100 w-xl-300px"> 353 <div class="stepper-nav ps-lg-10"> 354 <div class="stepper-item pending"> 355 <div class="stepper-wrapper"> 356 <div class="stepper-icon w-40px h-40px"> 357 <i class="stepper-check fs-2"></i> 358 <span class="stepper-number">2</span> 359 </div> 360 <div class="stepper-label"> 361 <h3 class="stepper-title">Regulatory Requirements</h3> 362 <div class="stepper-desc" id="addressRequirementText">Some phone numbers have local regulatory requirements. If the phone number you chose has these requirements then add your Twilio Bundle and Address SID below. You can find and create <a target="_blank" href="https://console.twilio.com/us1/develop/phone-numbers/regulatory-compliance/addresses">addresses here</a> and <a target="_blank" href="https://console.twilio.com/us1/develop/phone-numbers/regulatory-compliance/bundles">bundles here</a></div> 363 <input type="text" value="" class="form-control form-control form-control-solid mt-4" name="addressidentity" placeholder="Twilio Address SID"> 364 <input type="text" value="" class="form-control form-control form-control-solid mt-4" name="bundleidentity" placeholder="Twilio Bundle SID"> 365 </div> 366 </div> 367 </div> 368 </div> 369 </div> 370 </div> 371 <div class="stepper stepper-pills stepper-column d-flex flex-column flex-xl-row flex-row-fluid first mb-8"> 372 <div class="d-flex justify-content-center justify-content-xl-start flex-row-auto w-100 w-xl-300px"> 373 <div class="stepper-nav ps-lg-10"> 374 <div class="stepper-item pending"> 375 <div class="stepper-wrapper"> 376 <div class="stepper-icon w-40px h-40px"> 377 <i class="stepper-check fs-2"></i> 378 <span class="stepper-number">3</span> 379 </div> 380 <div class="stepper-label"> 381 <h3 class="stepper-title">Enjoy Your Number</h3> 382 <div class="stepper-desc">After requesting a number, it will be added to your account allowing you to start making calls almost immediately.</div> 383 </div> 384 </div> 385 </div> 386 </div> 387 </div> 388 </div> 389 390 </div> 391 <div class="modal-footer"> 392 <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button> 393 <input type="hidden" name="number" id="requestedNumber"></input> 394 <input type="hidden" name="location" id="requestedLocation"></input> 395 <input type="hidden" name="type" id="requestedType"></input> 396 <button type='submit' class='btn btn-primary'>Get Number</button> 397 </div> 235 398 </div> 236 399 </div> 237 400 </div> 238 </ div>401 </form> -
dialbunny/trunk/lib/views/dashboard/contacts/contacts.php
r3328438 r3406310 1 1 <?php if ( ! defined( 'ABSPATH' ) ) exit; ?> 2 <?php if ( !isset($_GET['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['user_nonce'])), 'DialBunny') ) { echo 'Sorry, we couldn ’t verify your request due to a security check failure.'; return; } ?>2 <?php if ( !isset($_GET['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['user_nonce'])), 'DialBunny') ) { echo 'Sorry, we couldn\'t verify your request due to a security check failure.'; return; } ?> 3 3 <div class="content d-flex flex-column flex-column-fluid" id="content"> 4 4 <div class="container-xxl" id="content_container"> 5 5 6 6 <?php 7 $ user_id = get_current_user_id();8 $ table = $wpdb->prefix . 'dialbunny_contacts';7 $dialbunny_user_id = get_current_user_id(); 8 $dialbunny_table = $wpdb->prefix . 'dialbunny_contacts'; 9 9 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 10 $ numberOfContacts = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery10 $dialbunny_numberOfContacts = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d", $dialbunny_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 11 11 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 12 $ numberOfBlocked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND blocked = 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery12 $dialbunny_numberOfBlocked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND blocked = 1", $dialbunny_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 13 13 // Defaults 14 if ($ numberOfContacts === null) { $numberOfContacts = 0; }15 if ($ numberOfBlocked === null) { $numberOfBlocked = 0; }14 if ($dialbunny_numberOfContacts === null) { $dialbunny_numberOfContacts = 0; } 15 if ($dialbunny_numberOfBlocked === null) { $dialbunny_numberOfBlocked = 0; } 16 16 // Pagination 17 $ resultsPage = 1;18 $ limit = '12';19 $ limit_offset = 0;20 $ limit_count = 12;17 $dialbunny_resultsPage = 1; 18 $dialbunny_limit = '12'; 19 $dialbunny_limit_offset = 0; 20 $dialbunny_limit_count = 12; 21 21 // Handle pagination 22 22 if (isset($_GET['resultsPage']) && is_numeric($_GET['resultsPage']) && intval($_GET['resultsPage']) > 1) { 23 $ resultsPage = intval($_GET['resultsPage']);24 $ limit_offset = ($resultsPage - 1) * $limit_count;23 $dialbunny_resultsPage = intval($_GET['resultsPage']); 24 $dialbunny_limit_offset = ($dialbunny_resultsPage - 1) * $dialbunny_limit_count; 25 25 } 26 26 ?> … … 54 54 <span class="fas fa-user"></span> 55 55 </i> 56 <div class="fs-4 fw-bold"><?php echo esc_html($ numberOfContacts); ?></div>56 <div class="fs-4 fw-bold"><?php echo esc_html($dialbunny_numberOfContacts); ?></div> 57 57 </div> 58 <div class="fw-semibold fs-6 text-gray-400"><?php if (strlen($ numberOfContacts) < 2) { echo 'Contact'; } else { echo 'Contacts'; } ?></div>58 <div class="fw-semibold fs-6 text-gray-400"><?php if (strlen($dialbunny_numberOfContacts) < 2) { echo 'Contact'; } else { echo 'Contacts'; } ?></div> 59 59 </div> 60 60 <div class="border border-gray-300 border-dashed rounded min-w-125px py-3 px-4 me-6 mb-3"> … … 63 63 <span class="fas fa-user"></span> 64 64 </i> 65 <div class="fs-4 fw-bold counted"><?php echo esc_html($ numberOfBlocked); ?></div>65 <div class="fs-4 fw-bold counted"><?php echo esc_html($dialbunny_numberOfBlocked); ?></div> 66 66 </div> 67 67 <div class="fw-semibold fs-6 text-gray-400">Blocked</div> … … 97 97 include('new.php'); 98 98 } else { 99 $ user_id = (int) wp_get_current_user()->ID;100 $ table = $wpdb->prefix . 'dialbunny_contacts';99 $dialbunny_user_id = (int) wp_get_current_user()->ID; 100 $dialbunny_table = $wpdb->prefix . 'dialbunny_contacts'; 101 101 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 102 $opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE id = %s AND user = %d LIMIT 1", $contact, $ user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery102 $opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE id = %s AND user = %d LIMIT 1", $contact, $dialbunny_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 103 103 if (!empty($opened_item)) { 104 104 include('view.php'); -
dialbunny/trunk/lib/views/dashboard/contacts/default.php
r3328438 r3406310 50 50 <tbody class="fs-6"> 51 51 <?php 52 $ table = $wpdb->prefix . 'dialbunny_contacts';53 $ user_id = get_current_user_id();52 $dialbunny_table = $wpdb->prefix . 'dialbunny_contacts'; 53 $dialbunny_user_id = get_current_user_id(); 54 54 $search = isset($_GET['search']) ? '%' . $wpdb->esc_like(sanitize_text_field(wp_unslash($_GET['search']))) . '%' : ''; 55 55 … … 57 57 if (strlen($search) > 2) { 58 58 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 59 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND name LIKE %s LIMIT 25",$user_id,$search)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery59 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND name LIKE %s LIMIT 25",$dialbunny_user_id,$search)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 60 60 } else { 61 61 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 62 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d LIMIT %d, %d",$user_id,$limit_offset,$limit_count)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery62 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d LIMIT %d, %d",$dialbunny_user_id,$dialbunny_limit_offset,$dialbunny_limit_count)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 63 63 } 64 64 ?> 65 <?php if (!empty($ opened_item)): ?>66 <?php foreach ($ opened_item as $item): ?>65 <?php if (!empty($dialbunny_opened_item)): ?> 66 <?php foreach ($dialbunny_opened_item as $dialbunny_item): ?> 67 67 <?php 68 $ bgicon = 'light-primary';69 $ texticon = 'primary';70 switch ((int) $ item->icon) {71 case 2: $ bgicon = 'light-success'; $texticon = 'success'; break;72 case 3: $ bgicon = 'light-info'; $texticon = 'info'; break;73 case 4: $ bgicon = 'light-danger'; $texticon = 'danger'; break;74 case 5: $ bgicon = 'light-warning'; $texticon = 'warning'; break;75 case 6: $ bgicon = 'secondary'; $texticon = 'dark'; break;68 $dialbunny_bgicon = 'light-primary'; 69 $dialbunny_texticon = 'primary'; 70 switch ((int) $dialbunny_item->icon) { 71 case 2: $dialbunny_bgicon = 'light-success'; $dialbunny_texticon = 'success'; break; 72 case 3: $dialbunny_bgicon = 'light-info'; $dialbunny_texticon = 'info'; break; 73 case 4: $dialbunny_bgicon = 'light-danger'; $dialbunny_texticon = 'danger'; break; 74 case 5: $dialbunny_bgicon = 'light-warning'; $dialbunny_texticon = 'warning'; break; 75 case 6: $dialbunny_bgicon = 'secondary'; $dialbunny_texticon = 'dark'; break; 76 76 } 77 77 78 $ contactUrl = esc_url(add_query_arg([78 $dialbunny_contactUrl = esc_url(add_query_arg([ 79 79 'dashboardpage' => 'contacts', 80 'contact' => $ item->id,80 'contact' => $dialbunny_item->id, 81 81 'user_nonce' => sanitize_text_field(wp_unslash($_GET['user_nonce'])) 82 82 ], $dialbunnyDashboardUrl)); … … 86 86 <div class="d-flex align-items-center"> 87 87 <div class="symbol symbol-40px symbol-circle me-5"> 88 <span class="symbol-label bg-<?php echo esc_attr($ bgicon); ?> text-<?php echo esc_attr($texticon); ?> fs-6 fw-bolder">89 <?php echo esc_html(ucfirst(substr($ item->name, 0, 1))); ?>88 <span class="symbol-label bg-<?php echo esc_attr($dialbunny_bgicon); ?> text-<?php echo esc_attr($dialbunny_texticon); ?> fs-6 fw-bolder"> 89 <?php echo esc_html(ucfirst(substr($dialbunny_item->name, 0, 1))); ?> 90 90 </span> 91 91 </div> 92 92 <div class="d-flex flex-column justify-content-center"> 93 <a href="<?php echo esc_url($ contactUrl); ?>" class="mb-1 text-gray-800 text-hover-primary">94 <?php echo esc_html($ item->name); ?>93 <a href="<?php echo esc_url($dialbunny_contactUrl); ?>" class="mb-1 text-gray-800 text-hover-primary"> 94 <?php echo esc_html($dialbunny_item->name); ?> 95 95 </a> 96 <div class="fw-semibold fs-6 text-gray-400"><?php echo esc_html(dialbunny_formatNumber($ item->phone)); ?></div>96 <div class="fw-semibold fs-6 text-gray-400"><?php echo esc_html(dialbunny_formatNumber($dialbunny_item->phone)); ?></div> 97 97 </div> 98 98 </div> 99 99 </td> 100 <td><?php echo esc_html($ item->company); ?></td>100 <td><?php echo esc_html($dialbunny_item->company); ?></td> 101 101 <td> 102 <?php if ($ item->blocked == 1): ?>102 <?php if ($dialbunny_item->blocked == 1): ?> 103 103 <span class="badge badge-light-danger fw-bold px-4 py-3">Blocked</span> 104 <?php elseif (!empty($ item->status)): ?>105 <span class="badge badge-light-<?php echo esc_attr($ item->statuscolor ?? 'primary'); ?> fw-bold px-4 py-3">106 <?php echo esc_html($ item->status); ?>104 <?php elseif (!empty($dialbunny_item->status)): ?> 105 <span class="badge badge-light-<?php echo esc_attr($dialbunny_item->statuscolor ?? 'primary'); ?> fw-bold px-4 py-3"> 106 <?php echo esc_html($dialbunny_item->status); ?> 107 107 </span> 108 108 <?php else: ?> … … 111 111 </td> 112 112 <td class="text-end"> 113 <a href="<?php echo esc_url($ contactUrl); ?>" class="btn btn-light btn-sm">View</a>113 <a href="<?php echo esc_url($dialbunny_contactUrl); ?>" class="btn btn-light btn-sm">View</a> 114 114 </td> 115 115 </tr> … … 137 137 <div class="separator mb-6"></div> 138 138 <div class="d-flex align-items-center justify-content-center justify-content-md-end"> 139 <?php if ($ resultsPage > 1 && strlen($search) <= 2): ?>139 <?php if ($dialbunny_resultsPage > 1 && strlen($search) <= 2): ?> 140 140 <?php 141 $ prevUrl = esc_url(add_query_arg([141 $dialbunny_prevUrl = esc_url(add_query_arg([ 142 142 'dashboardpage' => 'contacts', 143 'resultsPage' => $ resultsPage - 1,143 'resultsPage' => $dialbunny_resultsPage - 1, 144 144 'list' => '', 145 145 'user_nonce' => sanitize_text_field(wp_unslash($_GET['user_nonce'])) 146 146 ], $dialbunnyDashboardUrl)); 147 147 ?> 148 <a href="<?php echo esc_url($ prevUrl); ?>" class="btn btn-light btn-sm me-3">148 <a href="<?php echo esc_url($dialbunny_prevUrl); ?>" class="btn btn-light btn-sm me-3"> 149 149 <span class="menu-bullet"> 150 150 <span class="fa fa-arrow-left"></span> … … 153 153 <?php endif; ?> 154 154 155 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($ resultsPage); ?></span>156 157 <?php if (isset($ opened_item) && ($resultsPage * 12) < $numberOfContacts && strlen($search) <= 2): ?>155 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($dialbunny_resultsPage); ?></span> 156 157 <?php if (isset($dialbunny_opened_item) && ($dialbunny_resultsPage * 12) < $numberOfContacts && strlen($search) <= 2): ?> 158 158 <?php 159 $ nextUrl = add_query_arg([159 $dialbunny_nextUrl = add_query_arg([ 160 160 'dashboardpage' => 'contacts', 161 'resultsPage' => $ resultsPage + 1,161 'resultsPage' => $dialbunny_resultsPage + 1, 162 162 'list' => '', 163 163 'user_nonce' => sanitize_text_field(wp_unslash($_GET['user_nonce'])) 164 164 ], $dialbunnyDashboardUrl); 165 165 ?> 166 <a href="<?php echo esc_url($ nextUrl); ?>" class="btn btn-light btn-sm me-3">166 <a href="<?php echo esc_url($dialbunny_nextUrl); ?>" class="btn btn-light btn-sm me-3"> 167 167 <span class="menu-bullet"> 168 168 <span class="fa fa-arrow-right"></span> … … 177 177 <div class="row g-6 g-xl-9"> 178 178 <?php 179 if (!empty($ opened_item)) {180 foreach ($ opened_item as $item) {181 $ bgicon = "light-primary";182 $ texticon = "primary";183 184 switch ($ item->icon) {185 case 2: $ bgicon = "light-success"; $texticon = "success"; break;186 case 3: $ bgicon = "light-info"; $texticon = "info"; break;187 case 4: $ bgicon = "light-danger"; $texticon = "danger"; break;188 case 5: $ bgicon = "light-warning"; $texticon = "warning"; break;189 case 6: $ bgicon = "secondary"; $texticon = "dark"; break;179 if (!empty($dialbunny_opened_item)) { 180 foreach ($dialbunny_opened_item as $dialbunny_item) { 181 $dialbunny_bgicon = "light-primary"; 182 $dialbunny_texticon = "primary"; 183 184 switch ($dialbunny_item->icon) { 185 case 2: $dialbunny_bgicon = "light-success"; $dialbunny_texticon = "success"; break; 186 case 3: $dialbunny_bgicon = "light-info"; $dialbunny_texticon = "info"; break; 187 case 4: $dialbunny_bgicon = "light-danger"; $dialbunny_texticon = "danger"; break; 188 case 5: $dialbunny_bgicon = "light-warning"; $dialbunny_texticon = "warning"; break; 189 case 6: $dialbunny_bgicon = "secondary"; $dialbunny_texticon = "dark"; break; 190 190 } 191 191 192 192 echo '<div class="col-md-6 col-xxl-4"><div class="card"><div class="card-body d-flex flex-center flex-column pt-12 p-9">'; 193 echo '<div class="symbol symbol-65px symbol-circle mb-5"><span class="symbol-label fs-2x fw-semibold text-' . esc_attr($ texticon) . ' bg-' . esc_attr($bgicon) . '">' . esc_html(ucfirst(substr($item->name, 0, 1))) . '</span></div>';194 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=contacts&contact='.$ item->id, 'DialBunny', 'user_nonce')) . '" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">' . esc_html($item->name) . '</a>';195 echo '<div class="fw-semibold text-gray-400 mb-6">' . esc_html(dialbunny_formatNumber($ item->phone)) . '</div>';196 197 if ($ item->blocked == 1) {193 echo '<div class="symbol symbol-65px symbol-circle mb-5"><span class="symbol-label fs-2x fw-semibold text-' . esc_attr($dialbunny_texticon) . ' bg-' . esc_attr($dialbunny_bgicon) . '">' . esc_html(ucfirst(substr($dialbunny_item->name, 0, 1))) . '</span></div>'; 194 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=contacts&contact='.$dialbunny_item->id, 'DialBunny', 'user_nonce')) . '" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">' . esc_html($dialbunny_item->name) . '</a>'; 195 echo '<div class="fw-semibold text-gray-400 mb-6">' . esc_html(dialbunny_formatNumber($dialbunny_item->phone)) . '</div>'; 196 197 if ($dialbunny_item->blocked == 1) { 198 198 echo '<span class="badge badge-light-danger fw-bold px-4 py-3">Blocked</span>'; 199 } elseif (!empty($ item->status)) {200 $ status_color = !empty($item->statuscolor) ? esc_attr($item->statuscolor) : 'primary';201 echo '<span class="badge badge-light-' . esc_html($ status_color) . ' fw-bold px-4 py-3">' . esc_html($item->status) . '</span>';199 } elseif (!empty($dialbunny_item->status)) { 200 $dialbunny_status_color = !empty($dialbunny_item->statuscolor) ? esc_attr($dialbunny_item->statuscolor) : 'primary'; 201 echo '<span class="badge badge-light-' . esc_html($dialbunny_status_color) . ' fw-bold px-4 py-3">' . esc_html($dialbunny_item->status) . '</span>'; 202 202 } else { 203 203 echo '<span class="badge badge-light-success fw-bold px-4 py-3">Normal</span>'; … … 214 214 </div> 215 215 <div class="d-flex align-items-center justify-content-center justify-content-md-end pt-10"> 216 <?php if ($ resultsPage > 1 && strlen($search) <= 2): ?>216 <?php if ($dialbunny_resultsPage > 1 && strlen($search) <= 2): ?> 217 217 <a href="<?php echo esc_url(add_query_arg([ 218 218 'dashboardpage' => 'contacts', 219 'resultsPage' => $ resultsPage - 1,219 'resultsPage' => $dialbunny_resultsPage - 1, 220 220 'block' => '', 221 221 'user_nonce' => sanitize_text_field(wp_unslash($_GET['user_nonce'])) … … 226 226 </a> 227 227 <?php endif; ?> 228 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($ resultsPage); ?></span>229 <?php if (isset($ opened_item) && ($resultsPage * 12) < $numberOfContacts && strlen($search) <= 2): ?>228 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($dialbunny_resultsPage); ?></span> 229 <?php if (isset($dialbunny_opened_item) && ($dialbunny_resultsPage * 12) < $numberOfContacts && strlen($search) <= 2): ?> 230 230 <a href="<?php echo esc_url(add_query_arg([ 231 231 'dashboardpage' => 'contacts', 232 'resultsPage' => $ resultsPage + 1,232 'resultsPage' => $dialbunny_resultsPage + 1, 233 233 'block' => '', 234 234 'user_nonce' => sanitize_text_field(wp_unslash($_GET['user_nonce'])) -
dialbunny/trunk/lib/views/dashboard/inbound.php
r3326827 r3406310 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 $ table = $wpdb->prefix . 'dialbunny_phone_details';6 $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details'; 7 7 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 8 $ saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery8 $dialbunny_saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 9 9 ?> 10 10 <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your inbound call settings.")); } ?> … … 35 35 <div class="col-lg-4 fv-row"> 36 36 <?php 37 $ mainNumber1 = explode("-", $saveData[0]->call1 ?? null);38 if (isset($ saveData[0]->call1))37 $dialbunny_mainNumber1 = explode("-", $dialbunny_saveData[0]->call1 ?? null); 38 if (isset($dialbunny_saveData[0]->call1)) 39 39 { 40 40 // Escaped inside the dialbunny_country_code() function 41 echo dialbunny_country_code($ mainNumber1[0], "countrycode1"); // phpcs:ignore WordPress.Security.EscapeOutput41 echo dialbunny_country_code($dialbunny_mainNumber1[0], "countrycode1"); // phpcs:ignore WordPress.Security.EscapeOutput 42 42 } 43 43 else { echo dialbunny_country_code("none", "countrycode1"); } // phpcs:ignore WordPress.Security.EscapeOutput ?> 44 44 </div> 45 45 <div class="col-lg-8 fv-row"> 46 <input id="phoneNumber" type="number" maxlength="16" name="call1" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($ saveData[0]->call1)) { echo esc_html($mainNumber1[1]); } ?>" />46 <input id="phoneNumber" type="number" maxlength="16" name="call1" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($dialbunny_saveData[0]->call1)) { echo esc_html($dialbunny_mainNumber1[1]); } ?>" /> 47 47 </div> 48 48 <?php 49 if (isset($ saveData[0]->call1) && strlen($mainNumber1[1]) > 3 && $saveData[0]->call1_verified == 0) {49 if (isset($dialbunny_saveData[0]->call1) && strlen($dialbunny_mainNumber1[1]) > 3 && $dialbunny_saveData[0]->call1_verified == 0) { 50 50 echo ' 51 51 <div class="fv-row mt-6"> … … 73 73 <div class="col-lg-4 fv-row"> 74 74 <?php 75 $ mainNumber2 = explode("-", $saveData[0]->call2 ?? null);76 if (isset($ saveData[0]->call2))75 $dialbunny_mainNumber2 = explode("-", $dialbunny_saveData[0]->call2 ?? null); 76 if (isset($dialbunny_saveData[0]->call2)) 77 77 { 78 78 // Escaped inside the dialbunny_country_code() function 79 echo dialbunny_country_code($ mainNumber2[0], "countrycode2"); // phpcs:ignore WordPress.Security.EscapeOutput79 echo dialbunny_country_code($dialbunny_mainNumber2[0], "countrycode2"); // phpcs:ignore WordPress.Security.EscapeOutput 80 80 } 81 81 else { echo dialbunny_country_code("none", "countrycode2"); } // phpcs:ignore WordPress.Security.EscapeOutput ?> 82 82 </div> 83 83 <div class="col-lg-8 fv-row"> 84 <input id="phoneNumber2" type="number" maxlength="16" name="call2" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($ saveData[0]->call2)) { echo esc_html($mainNumber2[1]); } ?>" />84 <input id="phoneNumber2" type="number" maxlength="16" name="call2" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($dialbunny_saveData[0]->call2)) { echo esc_html($dialbunny_mainNumber2[1]); } ?>" /> 85 85 </div> <?php 86 if (isset($ saveData[0]->call2) && strlen($mainNumber2[1]) > 3 && $saveData[0]->call2_verified == 0) {86 if (isset($dialbunny_saveData[0]->call2) && strlen($dialbunny_mainNumber2[1]) > 3 && $dialbunny_saveData[0]->call2_verified == 0) { 87 87 echo ' 88 88 <div class="fv-row mt-6"> … … 110 110 <div class="col-lg-4 fv-row"> 111 111 <?php 112 $ mainNumber3 = explode("-", $saveData[0]->call3 ?? null);113 if (isset($ saveData[0]->call3))112 $dialbunny_mainNumber3 = explode("-", $dialbunny_saveData[0]->call3 ?? null); 113 if (isset($dialbunny_saveData[0]->call3)) 114 114 { 115 115 // Escaped inside the dialbunny_country_code() function 116 echo dialbunny_country_code($ mainNumber3[0], "countrycode3"); // phpcs:ignore WordPress.Security.EscapeOutput116 echo dialbunny_country_code($dialbunny_mainNumber3[0], "countrycode3"); // phpcs:ignore WordPress.Security.EscapeOutput 117 117 } 118 118 else { echo dialbunny_country_code("none", "countrycode3"); } // phpcs:ignore WordPress.Security.EscapeOutput ?> 119 119 </div> 120 120 <div class="col-lg-8 fv-row"> 121 <input id="phoneNumber3" type="number" maxlength="16" name="call3" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($ saveData[0]->call3)) { echo esc_html($mainNumber3[1]); } ?>" />121 <input id="phoneNumber3" type="number" maxlength="16" name="call3" class="form-control form-control-lg form-control-solid" placeholder="Phone Number" value="<?php if (isset($dialbunny_saveData[0]->call3)) { echo esc_html($dialbunny_mainNumber3[1]); } ?>" /> 122 122 </div> <?php 123 if (isset($ saveData[0]->call3) && strlen($mainNumber3[1]) > 10 && $saveData[0]->call3_verified == 0) {123 if (isset($dialbunny_saveData[0]->call3) && strlen($dialbunny_mainNumber3[1]) > 10 && $dialbunny_saveData[0]->call3_verified == 0) { 124 124 echo ' 125 125 <div class="fv-row mt-6"> … … 198 198 <div class="row mb-6"> 199 199 <div class="col-lg-12 fv-row"> 200 <textarea type="textarea" maxlength="500" rows="6" name="welcome" class="form-control form-control-lg form-control-solid" placeholder="Please hold while we transfer you to the next available representative."><?php if (isset($ saveData[0]->welcome) && $saveData[0]->welcome != null) { echo esc_html($saveData[0]->welcome); } ?></textarea>200 <textarea type="textarea" maxlength="500" rows="6" name="welcome" class="form-control form-control-lg form-control-solid" placeholder="Please hold while we transfer you to the next available representative."><?php if (isset($dialbunny_saveData[0]->welcome) && $dialbunny_saveData[0]->welcome != null) { echo esc_html($dialbunny_saveData[0]->welcome); } ?></textarea> 201 201 </div> 202 202 </div> … … 229 229 <div class="row"> 230 230 <div class="col-lg-12 fv-row"> 231 <textarea type="textarea" maxlength="500" rows="6" name="busy" class="form-control form-control-lg form-control-solid" placeholder="Sorry there are currently no available representatives."><?php if (isset($ saveData[0]->busy) && $saveData[0]->busy != null) { echo esc_html($saveData[0]->busy); } ?></textarea>231 <textarea type="textarea" maxlength="500" rows="6" name="busy" class="form-control form-control-lg form-control-solid" placeholder="Sorry there are currently no available representatives."><?php if (isset($dialbunny_saveData[0]->busy) && $dialbunny_saveData[0]->busy != null) { echo esc_html($dialbunny_saveData[0]->busy); } ?></textarea> 232 232 </div> 233 233 </div> … … 260 260 <div class="row"> 261 261 <div class="col-lg-12 fv-row"> 262 <textarea type="textarea" maxlength="500" rows="6" name="outside_hours_message" class="form-control form-control-lg form-control-solid" placeholder="Sorry you are calling outside of business hours, we are available between nine A.M and five P.M, monday to friday."><?php if (isset($ saveData[0]->outside_hours_message) && $saveData[0]->outside_hours_message != null) { echo esc_html($saveData[0]->outside_hours_message); } ?></textarea>262 <textarea type="textarea" maxlength="500" rows="6" name="outside_hours_message" class="form-control form-control-lg form-control-solid" placeholder="Sorry you are calling outside of business hours, we are available between nine A.M and five P.M, monday to friday."><?php if (isset($dialbunny_saveData[0]->outside_hours_message) && $dialbunny_saveData[0]->outside_hours_message != null) { echo esc_html($dialbunny_saveData[0]->outside_hours_message); } ?></textarea> 263 263 </div> 264 264 </div> … … 292 292 <h1 class="d-flex justify-content-center align-items-center mb-6">Call the number below</h1> 293 293 <h3 class="d-flex justify-content-center align-items-center mb-6"> 294 <?php if (isset($ saveData[0]->managed_number) && isset($saveData[0]->managed_number_code) && strlen(trim($saveData[0]->managed_number)) > 3)295 { echo esc_html($ saveData[0]->managed_number_code . ' ' . dialbunny_formatNumber($saveData[0]->managed_number)); }294 <?php if (isset($dialbunny_saveData[0]->managed_number) && isset($dialbunny_saveData[0]->managed_number_code) && strlen(trim($dialbunny_saveData[0]->managed_number)) > 3) 295 { echo esc_html($dialbunny_saveData[0]->managed_number_code . ' ' . dialbunny_formatNumber($dialbunny_saveData[0]->managed_number)); } 296 296 else { echo 'You don\'t have a number setup yet'; } 297 297 ?> </h3> -
dialbunny/trunk/lib/views/dashboard/index.php
r3396401 r3406310 3 3 <div class="container-xxl" id="content_container"> 4 4 <?php 5 $ table = $wpdb->prefix . 'dialbunny_phone_details';5 $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details'; 6 6 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 7 $ saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery7 $dialbunny_saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 8 8 $dialbunny_recents = $wpdb->prefix . 'dialbunny_recents'; 9 $ recent_day = 0;10 $ recent_7day = 0;11 $ recent_30day = 0;12 if (isset($ saveData[0]->managed_number)) {9 $dialbunny_recent_day = 0; 10 $dialbunny_recent_7day = 0; 11 $dialbunny_recent_30day = 0; 12 if (isset($dialbunny_saveData[0]->managed_number)) { 13 13 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 14 $ recent_day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 1 DAY) AND (to_number = %s OR from_number = %s)",$saveData[0]->managed_number,$saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery15 $ recent_7day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) AND (to_number = %s OR from_number = %s)",$saveData[0]->managed_number,$saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery16 $ recent_30day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY) AND (to_number = %s OR from_number = %s)",$saveData[0]->managed_number,$saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery14 $dialbunny_recent_day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 1 DAY) AND (to_number = %s OR from_number = %s)",$dialbunny_saveData[0]->managed_number,$dialbunny_saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 15 $dialbunny_recent_7day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) AND (to_number = %s OR from_number = %s)",$dialbunny_saveData[0]->managed_number,$dialbunny_saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 16 $dialbunny_recent_30day = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}dialbunny_recents WHERE created_at >= DATE_SUB(NOW(), INTERVAL 30 DAY) AND (to_number = %s OR from_number = %s)",$dialbunny_saveData[0]->managed_number,$dialbunny_saveData[0]->managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 17 17 } 18 $ json_data = null;19 if (isset($ saveData[0]->business_hours)) {20 $ json_data = json_decode($saveData[0]->business_hours);18 $dialbunny_json_data = null; 19 if (isset($dialbunny_saveData[0]->business_hours)) { 20 $dialbunny_json_data = json_decode($dialbunny_saveData[0]->business_hours); 21 21 } 22 22 ?> … … 39 39 <div class="d-flex flex-stack"> 40 40 <div class="m-0"> 41 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($ recent_day); ?> </span>41 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($dialbunny_recent_day); ?> </span> 42 42 <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 24 Hours </span> 43 43 </div> … … 46 46 <div class="d-flex flex-stack"> 47 47 <div class="m-0"> 48 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($ recent_7day); ?> </span>48 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($dialbunny_recent_7day); ?> </span> 49 49 <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 7 Days </span> 50 50 </div> … … 53 53 <div class="d-flex flex-stack"> 54 54 <div class="m-0"> 55 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($ recent_30day); ?> </span>55 <span class="text-gray-800 fw-bold d-block fs-2hx lh-1 ls-n2"> <?php echo number_format($dialbunny_recent_30day); ?> </span> 56 56 <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 30 Days </span> 57 57 </div> … … 87 87 <h3 class="card-title">Your Number</h3> 88 88 <div class="card-toolbar"> 89 <?php if (isset($ saveData[0]->managed_number) && isset($saveData[0]->managed_number_code) && strlen((string)$saveData[0]->managed_number) > 3) { echo '<button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#release_managed_number">Release</button>'; } ?>89 <?php if (isset($dialbunny_saveData[0]->managed_number) && isset($dialbunny_saveData[0]->managed_number_code) && strlen((string)$dialbunny_saveData[0]->managed_number) > 3) { echo '<button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#release_managed_number">Release</button>'; } ?> 90 90 </div> 91 91 </div> … … 93 93 <div class="d-flex flex-column flex-grow-1 py-2 py-lg-13 me-2"> 94 94 <p class="fw-bold text-gray-900 fs-1 mb-2"> 95 <?php if (isset($ saveData[0]->managed_number) && isset($saveData[0]->managed_number_code) && strlen((string)$saveData[0]->managed_number) > 3)95 <?php if (isset($dialbunny_saveData[0]->managed_number) && isset($dialbunny_saveData[0]->managed_number_code) && strlen((string)$dialbunny_saveData[0]->managed_number) > 3) 96 96 { 97 echo esc_html($ saveData[0]->managed_number_code) . ' ' . esc_html(dialbunny_formatNumber($saveData[0]->managed_number));97 echo esc_html($dialbunny_saveData[0]->managed_number_code) . ' ' . esc_html(dialbunny_formatNumber($dialbunny_saveData[0]->managed_number)); 98 98 } 99 99 else { echo 'You don\'t have a number setup yet'; } … … 181 181 <input type="hidden" name="action" value="dialbunny_release_managed_number_user"></input> 182 182 <?php 183 if (isset($ saveData[0]->managed_number) && isset($saveData[0]->managed_number_code))183 if (isset($dialbunny_saveData[0]->managed_number) && isset($dialbunny_saveData[0]->managed_number_code)) 184 184 { 185 echo '<input type="hidden" name="countrycode" value="'. esc_html($ saveData[0]->managed_number_code) .'"></input>';186 echo '<input type="hidden" name="phone" value="'. esc_html($ saveData[0]->managed_number) .'"></input>';187 echo '<input type="hidden" name="sid" value="'. esc_html($ saveData[0]->managed_number) .'"></input>';185 echo '<input type="hidden" name="countrycode" value="'. esc_html($dialbunny_saveData[0]->managed_number_code) .'"></input>'; 186 echo '<input type="hidden" name="phone" value="'. esc_html($dialbunny_saveData[0]->managed_number) .'"></input>'; 187 echo '<input type="hidden" name="sid" value="'. esc_html($dialbunny_saveData[0]->managed_number) .'"></input>'; 188 188 } 189 189 ?> -
dialbunny/trunk/lib/views/dashboard/messages/default.php
r3328438 r3406310 51 51 <?php 52 52 // Check to see if user wants to search or not - Requires mysql 8.0 or higher 53 $ user_id = get_current_user_id();54 $ managed_number = $phone_details[0]->managed_number;53 $dialbunny_user_id = get_current_user_id(); 54 $dialbunny_managed_number = $phone_details[0]->managed_number; 55 55 $search = isset($_GET['search']) ? '%' . $wpdb->esc_like(sanitize_text_field(wp_unslash($_GET['search']))) . '%' : ''; 56 56 if (strlen($search) > 2) { 57 57 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 58 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT *, ROW_NUMBER() OVER (PARTITION BY from_number, to_number ORDER BY created_at DESC) AS rn FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s) AND message LIKE %s LIMIT 25", $user_id, $managed_number, $managed_number, $search)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery58 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT *, ROW_NUMBER() OVER (PARTITION BY from_number, to_number ORDER BY created_at DESC) AS rn FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s) AND message LIKE %s LIMIT 25", $dialbunny_user_id, $dialbunny_managed_number, $dialbunny_managed_number, $search)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 59 59 } else { 60 60 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 61 $ opened_item = $wpdb->get_results( $wpdb->prepare("SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY LEAST(from_number, to_number), GREATEST(from_number, to_number) ORDER BY created_at DESC) AS rn FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s)) AS ranked_messages WHERE rn = 1 ORDER BY created_at DESC LIMIT %d,%d", $user_id, $managed_number,$managed_number,$limit_offset,$limit_count)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery61 $dialbunny_opened_item = $wpdb->get_results( $wpdb->prepare("SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY LEAST(from_number, to_number), GREATEST(from_number, to_number) ORDER BY created_at DESC) AS rn FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s)) AS ranked_messages WHERE rn = 1 ORDER BY created_at DESC LIMIT %d,%d", $dialbunny_user_id, $dialbunny_managed_number,$dialbunny_managed_number,$dialbunny_limit_offset,$dialbunny_limit_count)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 62 62 } 63 63 // check to see if the user has a managed number 64 64 if (isset($phone_details[0]->managed_number) && isset($phone_details[0]->managed_number_code)) 65 65 { 66 foreach ($ opened_item as $item)66 foreach ($dialbunny_opened_item as $dialbunny_item) 67 67 { 68 68 // Check to see if contact exists 69 $ phoneNumberCountryCode;70 $ phoneNumber;71 if ($phone_details[0]->managed_number_code == $ item->from_countrycode && $phone_details[0]->managed_number == $item->from_number) { $phoneNumberCountryCode = $item->to_countrycode; $phoneNumber = $item->to_number; }72 else { $ phoneNumberCountryCode = $item->from_countrycode; $phoneNumber = $item->from_number; }69 $dialbunny_phoneNumberCountryCode; 70 $dialbunny_phoneNumber; 71 if ($phone_details[0]->managed_number_code == $dialbunny_item->from_countrycode && $phone_details[0]->managed_number == $dialbunny_item->from_number) { $dialbunny_phoneNumberCountryCode = $dialbunny_item->to_countrycode; $dialbunny_phoneNumber = $dialbunny_item->to_number; } 72 else { $dialbunny_phoneNumberCountryCode = $dialbunny_item->from_countrycode; $dialbunny_phoneNumber = $dialbunny_item->from_number; } 73 73 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 74 $ contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",wp_get_current_user()->ID,$phoneNumberCountryCode,$phoneNumber)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery75 if ($ contact == null)74 $dialbunny_contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",wp_get_current_user()->ID,$dialbunny_phoneNumberCountryCode,$dialbunny_phoneNumber)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 75 if ($dialbunny_contact == null) 76 76 { 77 $di splayName = dialbunny_formatNumber($phoneNumber);78 if ($ item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $displayName = 'You'; }77 $dialbunny_displayName = dialbunny_formatNumber($dialbunny_phoneNumber); 78 if ($dialbunny_item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $dialbunny_displayName = 'You'; } 79 79 echo '<tr>'; 80 80 echo '<td><div class="d-flex align-items-center">'; … … 82 82 echo '<span class="symbol-label bg-secondary text-secondary fs-6 fw-bolder"></span>'; 83 83 echo '</div>'; 84 echo '<div class="d-flex flex-column justify-content-center"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="mb-1 text-gray-800 text-hover-primary">'.esc_html($displayName).'</a><div class="fw-semibold fs-6 text-gray-400">Not in contacts</div></div></div></td>';85 echo '<td>'.esc_html(mb_strimwidth($ item->message, 0, 25, "...")).'</td>';86 if ($ item->reading == 0) { echo '<td><span class="badge badge-light-primary fw-bold px-4 py-3">Unread</span></td>'; }84 echo '<div class="d-flex flex-column justify-content-center"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="mb-1 text-gray-800 text-hover-primary">'.esc_html($dialbunny_displayName).'</a><div class="fw-semibold fs-6 text-gray-400">Not in contacts</div></div></div></td>'; 85 echo '<td>'.esc_html(mb_strimwidth($dialbunny_item->message, 0, 25, "...")).'</td>'; 86 if ($dialbunny_item->reading == 0) { echo '<td><span class="badge badge-light-primary fw-bold px-4 py-3">Unread</span></td>'; } 87 87 else { echo '<td><span class="badge badge-light-success fw-bold px-4 py-3">Read</span></td>'; } 88 echo '<td class="text-end"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="btn btn-light btn-sm">View</a></td>';88 echo '<td class="text-end"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="btn btn-light btn-sm">View</a></td>'; 89 89 echo '</tr>'; 90 90 } 91 91 else 92 92 { 93 $di splayName = $contact[0]->name;94 if ($ item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $displayName = 'You'; }95 $ bgicon = "light-primary";96 $ texticon = "primary";97 if ($ contact[0]->icon == 2) { $bgicon = "light-success"; $texticon = "success"; }98 if ($ contact[0]->icon == 3) { $bgicon = "light-info"; $texticon = "info"; }99 if ($ contact[0]->icon == 4) { $bgicon = "light-danger"; $texticon = "danger"; }100 if ($ contact[0]->icon == 5) { $bgicon = "light-warning"; $texticon = "warning"; }101 if ($ contact[0]->icon == 6) { $bgicon = "secondary"; $texticon = "dark"; }93 $dialbunny_displayName = $dialbunny_contact[0]->name; 94 if ($dialbunny_item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $dialbunny_displayName = 'You'; } 95 $dialbunny_bgicon = "light-primary"; 96 $dialbunny_texticon = "primary"; 97 if ($dialbunny_contact[0]->icon == 2) { $dialbunny_bgicon = "light-success"; $dialbunny_texticon = "success"; } 98 if ($dialbunny_contact[0]->icon == 3) { $dialbunny_bgicon = "light-info"; $dialbunny_texticon = "info"; } 99 if ($dialbunny_contact[0]->icon == 4) { $dialbunny_bgicon = "light-danger"; $dialbunny_texticon = "danger"; } 100 if ($dialbunny_contact[0]->icon == 5) { $dialbunny_bgicon = "light-warning"; $dialbunny_texticon = "warning"; } 101 if ($dialbunny_contact[0]->icon == 6) { $dialbunny_bgicon = "secondary"; $dialbunny_texticon = "dark"; } 102 102 echo '<tr>'; 103 103 echo '<td><div class="d-flex align-items-center">'; 104 104 echo '<div class="symbol symbol-40px symbol-circle me-5">'; 105 echo '<span class="symbol-label bg-'.esc_html($ bgicon).' text-'.esc_html($texticon).' fs-6 fw-bolder">'.esc_html(ucfirst(substr($contact[0]->name, 0, 1))).'</span>';105 echo '<span class="symbol-label bg-'.esc_html($dialbunny_bgicon).' text-'.esc_html($dialbunny_texticon).' fs-6 fw-bolder">'.esc_html(ucfirst(substr($dialbunny_contact[0]->name, 0, 1))).'</span>'; 106 106 echo '</div>'; 107 echo '<div class="d-flex flex-column justify-content-center"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="mb-1 text-gray-800 text-hover-primary">'.esc_html($displayName).'</a><div class="fw-semibold fs-6 text-gray-400">'.esc_html(dialbunny_formatNumber($phoneNumber)).'</div></div></div></td>';108 echo '<td>'.esc_html(mb_strimwidth($ item->message, 0, 25, "...")).'</td>';109 if ($ item->reading == 0) { echo '<td><span class="badge badge-light-primary fw-bold px-4 py-3">Unread</span></td>'; }107 echo '<div class="d-flex flex-column justify-content-center"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="mb-1 text-gray-800 text-hover-primary">'.esc_html($dialbunny_displayName).'</a><div class="fw-semibold fs-6 text-gray-400">'.esc_html(dialbunny_formatNumber($dialbunny_phoneNumber)).'</div></div></div></td>'; 108 echo '<td>'.esc_html(mb_strimwidth($dialbunny_item->message, 0, 25, "...")).'</td>'; 109 if ($dialbunny_item->reading == 0) { echo '<td><span class="badge badge-light-primary fw-bold px-4 py-3">Unread</span></td>'; } 110 110 else { echo '<td><span class="badge badge-light-success fw-bold px-4 py-3">Read</span></td>'; } 111 echo '<td class="text-end"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="btn btn-light btn-sm">View</a></td>';111 echo '<td class="text-end"><a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="btn btn-light btn-sm">View</a></td>'; 112 112 echo '</tr>'; 113 113 } 114 114 } 115 if ($ opened_item == null)115 if ($dialbunny_opened_item == null) 116 116 { 117 117 echo '<tr>'; … … 140 140 <div class="separator mb-6"></div> 141 141 <div class="d-flex align-items-center justify-content-center justify-content-md-end"> 142 <?php if ($ resultsPage > 1 && strlen($search) <= 2)143 { 144 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($ resultsPage - 1), 'DialBunny', 'user_nonce')) .'&list" class="btn btn-light btn-sm me-3">';142 <?php if ($dialbunny_resultsPage > 1 && strlen($search) <= 2) 143 { 144 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($dialbunny_resultsPage - 1), 'DialBunny', 'user_nonce')) .'&list" class="btn btn-light btn-sm me-3">'; 145 145 echo '<span class="menu-bullet">'; 146 146 echo '<span class="fa fa-arrow-left"></span>'; … … 149 149 } 150 150 ?> 151 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($ resultsPage); ?></span>152 <?php if (isset($ opened_item) && ($resultsPage * 12) < $numberOfMessages && strlen($search) <= 2)153 { 154 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($ resultsPage + 1), 'DialBunny', 'user_nonce')) .'&list" class="btn btn-light btn-sm me-3">';151 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($dialbunny_resultsPage); ?></span> 152 <?php if (isset($dialbunny_opened_item) && ($dialbunny_resultsPage * 12) < $numberOfMessages && strlen($search) <= 2) 153 { 154 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($dialbunny_resultsPage + 1), 'DialBunny', 'user_nonce')) .'&list" class="btn btn-light btn-sm me-3">'; 155 155 echo '<span class="menu-bullet">'; 156 156 echo '<span class="fa fa-arrow-right"></span>'; … … 170 170 { 171 171 // Foreach message 172 foreach ($ opened_item as $item)172 foreach ($dialbunny_opened_item as $dialbunny_item) 173 173 { 174 174 // Check to see if contact exists and make sure the from number does not equal the managed number 175 $ phoneNumberCountryCode;176 $ phoneNumber;177 if ($phone_details[0]->managed_number_code == $ item->from_countrycode && $phone_details[0]->managed_number == $item->from_number) { $phoneNumberCountryCode = $item->to_countrycode; $phoneNumber = $item->to_number; }178 else { $ phoneNumberCountryCode = $item->from_countrycode; $phoneNumber = $item->from_number; }175 $dialbunny_phoneNumberCountryCode; 176 $dialbunny_phoneNumber; 177 if ($phone_details[0]->managed_number_code == $dialbunny_item->from_countrycode && $phone_details[0]->managed_number == $dialbunny_item->from_number) { $dialbunny_phoneNumberCountryCode = $dialbunny_item->to_countrycode; $dialbunny_phoneNumber = $dialbunny_item->to_number; } 178 else { $dialbunny_phoneNumberCountryCode = $dialbunny_item->from_countrycode; $dialbunny_phoneNumber = $dialbunny_item->from_number; } 179 179 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 180 $ contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",wp_get_current_user()->ID,$phoneNumberCountryCode,$phoneNumber)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery181 if ($ contact == null)180 $dialbunny_contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",wp_get_current_user()->ID,$dialbunny_phoneNumberCountryCode,$dialbunny_phoneNumber)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 181 if ($dialbunny_contact == null) 182 182 { 183 $di splayName = dialbunny_formatNumber($phoneNumber);184 if ($ item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $displayName = 'You'; }183 $dialbunny_displayName = dialbunny_formatNumber($dialbunny_phoneNumber); 184 if ($dialbunny_item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $dialbunny_displayName = 'You'; } 185 185 echo '<div class="col-md-6 col-xxl-4"><div class="card"><div class="card-body d-flex flex-center flex-column pt-12 p-9">'; 186 186 echo '<div class="symbol symbol-65px symbol-circle mb-5"><span class="symbol-label fs-2x fw-semibold text-secondary bg-secondary"></span></div>'; 187 echo '<a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">'.esc_html($displayName).'</a><div class="fw-semibold text-gray-400 mb-6">Not in contacts</div>';188 if ($ item->reading == 0) { echo '<span class="badge badge-light-primary fw-bold px-4 py-3 mb-2">Unread</span>'; }187 echo '<a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">'.esc_html($dialbunny_displayName).'</a><div class="fw-semibold text-gray-400 mb-6">Not in contacts</div>'; 188 if ($dialbunny_item->reading == 0) { echo '<span class="badge badge-light-primary fw-bold px-4 py-3 mb-2">Unread</span>'; } 189 189 else { echo '<span class="badge badge-light-success fw-bold px-4 py-3 mb-2">Read</span>'; } 190 echo '<div class="p-5 badge badge-light-secondary text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html(mb_strimwidth($ item->message, 0, 25, "...")).'</div>';190 echo '<div class="p-5 badge badge-light-secondary text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html(mb_strimwidth($dialbunny_item->message, 0, 25, "...")).'</div>'; 191 191 echo '</div></div></div>'; 192 192 } 193 193 else 194 194 { 195 $di splayName = $contact[0]->name;196 if ($ item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $displayName = 'You'; }197 $ bgicon = "light-primary";198 $ texticon = "primary";199 if ($ contact[0]->icon == 2) { $bgicon = "light-success"; $texticon = "success"; }200 if ($ contact[0]->icon == 3) { $bgicon = "light-info"; $texticon = "info"; }201 if ($ contact[0]->icon == 4) { $bgicon = "light-danger"; $texticon = "danger"; }202 if ($ contact[0]->icon == 5) { $bgicon = "light-warning"; $texticon = "warning"; }203 if ($ contact[0]->icon == 6) { $bgicon = "secondary"; $texticon = "dark"; }195 $dialbunny_displayName = $dialbunny_contact[0]->name; 196 if ($dialbunny_item->from_number == $phone_details[0]->managed_number && strlen($search) > 2) { $dialbunny_displayName = 'You'; } 197 $dialbunny_bgicon = "light-primary"; 198 $dialbunny_texticon = "primary"; 199 if ($dialbunny_contact[0]->icon == 2) { $dialbunny_bgicon = "light-success"; $dialbunny_texticon = "success"; } 200 if ($dialbunny_contact[0]->icon == 3) { $dialbunny_bgicon = "light-info"; $dialbunny_texticon = "info"; } 201 if ($dialbunny_contact[0]->icon == 4) { $dialbunny_bgicon = "light-danger"; $dialbunny_texticon = "danger"; } 202 if ($dialbunny_contact[0]->icon == 5) { $dialbunny_bgicon = "light-warning"; $dialbunny_texticon = "warning"; } 203 if ($dialbunny_contact[0]->icon == 6) { $dialbunny_bgicon = "secondary"; $dialbunny_texticon = "dark"; } 204 204 echo '<div class="col-md-6 col-xxl-4"><div class="card"><div class="card-body d-flex flex-center flex-column pt-12 p-9">'; 205 echo '<div class="symbol symbol-65px symbol-circle mb-5"><span class="symbol-label fs-2x fw-semibold text-'.esc_html($ texticon).' bg-'.esc_html($bgicon).'">'.esc_html(ucfirst(substr($contact[0]->name, 0, 1))).'</span></div>';206 echo '<a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($ phoneNumber).'&countrycode='.esc_html($phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">'.esc_html($displayName).'</a><div class="fw-semibold text-gray-400 mb-6">'.esc_html(dialbunny_formatNumber($phoneNumber)).'</div>';207 if ($ item->reading == 0) { echo '<span class="badge badge-light-primary fw-bold px-4 py-3 mb-2">Unread</span>'; }205 echo '<div class="symbol symbol-65px symbol-circle mb-5"><span class="symbol-label fs-2x fw-semibold text-'.esc_html($dialbunny_texticon).' bg-'.esc_html($dialbunny_bgicon).'">'.esc_html(ucfirst(substr($dialbunny_contact[0]->name, 0, 1))).'</span></div>'; 206 echo '<a href="'.esc_url(wp_nonce_url($dialbunnyDashboardUrl.'&dashboardpage=messages&phone='.esc_html($dialbunny_phoneNumber).'&countrycode='.esc_html($dialbunny_phoneNumberCountryCode), 'DialBunny', 'user_nonce')).'" class="fs-4 text-gray-800 text-hover-primary fw-bold mb-0">'.esc_html($dialbunny_displayName).'</a><div class="fw-semibold text-gray-400 mb-6">'.esc_html(dialbunny_formatNumber($dialbunny_phoneNumber)).'</div>'; 207 if ($dialbunny_item->reading == 0) { echo '<span class="badge badge-light-primary fw-bold px-4 py-3 mb-2">Unread</span>'; } 208 208 else { echo '<span class="badge badge-light-success fw-bold px-4 py-3 mb-2">Read</span>'; } 209 echo '<div class="p-5 badge badge-light-secondary text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html(mb_strimwidth($ item->message, 0, 25, "...")).'</div>';209 echo '<div class="p-5 badge badge-light-secondary text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html(mb_strimwidth($dialbunny_item->message, 0, 25, "...")).'</div>'; 210 210 echo '</div></div></div>'; 211 211 } 212 212 } 213 if ($ opened_item == null)213 if ($dialbunny_opened_item == null) 214 214 { 215 215 echo '<div class="col-md-6 col-xxl-4"><div class="card"><div class="card-body d-flex flex-center flex-column pt-12 p-9">'; … … 227 227 </div> 228 228 <div class="d-flex align-items-center justify-content-center justify-content-md-end pt-10"> 229 <?php if ($ resultsPage > 1 && strlen($search) <= 2)230 { 231 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($ resultsPage - 1), 'DialBunny', 'user_nonce')) .'&block" class="btn btn-secondary btn-sm me-3">';229 <?php if ($dialbunny_resultsPage > 1 && strlen($search) <= 2) 230 { 231 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($dialbunny_resultsPage - 1), 'DialBunny', 'user_nonce')) .'&block" class="btn btn-secondary btn-sm me-3">'; 232 232 echo '<span class="menu-bullet">'; 233 233 echo '<span class="fa fa-arrow-left"></span>'; … … 236 236 } 237 237 ?> 238 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($ resultsPage); ?></span>239 <?php if (isset($ opened_item) && ($resultsPage * 12) < $numberOfMessages && strlen($search) <= 2)240 { 241 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($ resultsPage + 1), 'DialBunny', 'user_nonce')) .'&block" class="btn btn-secondary btn-sm me-3">';238 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($dialbunny_resultsPage); ?></span> 239 <?php if (isset($dialbunny_opened_item) && ($dialbunny_resultsPage * 12) < $numberOfMessages && strlen($search) <= 2) 240 { 241 echo '<a href="' . esc_url(wp_nonce_url($dialbunnyDashboardUrl . '&dashboardpage=messages&resultsPage=' . esc_html($dialbunny_resultsPage + 1), 'DialBunny', 'user_nonce')) .'&block" class="btn btn-secondary btn-sm me-3">'; 242 242 echo '<span class="menu-bullet">'; 243 243 echo '<span class="fa fa-arrow-right"></span>'; -
dialbunny/trunk/lib/views/dashboard/messages/messages.php
r3328438 r3406310 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 $d etails = $wpdb->prefix . 'dialbunny_phone_details';7 $ messages = $wpdb->prefix . 'dialbunny_messages';8 $ contacts = $wpdb->prefix . 'dialbunny_contacts';9 $ current_user_id = wp_get_current_user()->ID;6 $dialbunny_details = $wpdb->prefix . 'dialbunny_phone_details'; 7 $dialbunny_messages = $wpdb->prefix . 'dialbunny_messages'; 8 $dialbunny_contacts = $wpdb->prefix . 'dialbunny_contacts'; 9 $dialbunny_current_user_id = wp_get_current_user()->ID; 10 10 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 11 $ phone_details = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $current_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery12 $ numberOfMessages = 0;13 $ numberOfUnread = 0;14 if (!empty($ phone_details[0]->managed_number)) {15 $ managed_number = $phone_details[0]->managed_number;11 $dialbunny_phone_details = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $dialbunny_current_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 12 $dialbunny_numberOfMessages = 0; 13 $dialbunny_numberOfUnread = 0; 14 if (!empty($dialbunny_phone_details[0]->managed_number)) { 15 $dialbunny_managed_number = $dialbunny_phone_details[0]->managed_number; 16 16 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 17 $ numberOfMessages = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT LEAST(from_number, to_number), GREATEST(from_number, to_number)) FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s)",$current_user_id,$managed_number,$managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery17 $dialbunny_numberOfMessages = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT LEAST(from_number, to_number), GREATEST(from_number, to_number)) FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s)",$dialbunny_current_user_id,$dialbunny_managed_number,$dialbunny_managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 18 18 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 19 $ numberOfUnread = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT LEAST(from_number, to_number), GREATEST(from_number, to_number)) FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s) AND reading = '0'",$current_user_id,$managed_number,$managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery19 $dialbunny_numberOfUnread = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT LEAST(from_number, to_number), GREATEST(from_number, to_number)) FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (from_number = %s OR to_number = %s) AND reading = '0'",$dialbunny_current_user_id,$dialbunny_managed_number,$dialbunny_managed_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 20 20 } 21 $ resultsPage = 1;22 $ limit = '12';23 $ limit_offset = 0;24 $ limit_count = 12;21 $dialbunny_resultsPage = 1; 22 $dialbunny_limit = '12'; 23 $dialbunny_limit_offset = 0; 24 $dialbunny_limit_count = 12; 25 25 // Handle pagination 26 26 if (isset($_GET['resultsPage']) && is_numeric($_GET['resultsPage']) && intval($_GET['resultsPage']) > 1) { 27 $ resultsPage = intval($_GET['resultsPage']);28 $ limit_offset = ($resultsPage - 1) * $limit_count;27 $dialbunny_resultsPage = intval($_GET['resultsPage']); 28 $dialbunny_limit_offset = ($dialbunny_resultsPage - 1) * $dialbunny_limit_count; 29 29 } 30 30 ?> … … 59 59 <span class="fas fa-comments"></span> 60 60 </i> 61 <div class="fs-4 fw-bold"><?php echo esc_html($ numberOfMessages); ?></div>61 <div class="fs-4 fw-bold"><?php echo esc_html($dialbunny_numberOfMessages); ?></div> 62 62 </div> 63 <div class="fw-semibold fs-6 text-gray-400"><?php if ($ numberOfMessages < 2) { echo 'Conversation'; } else { echo 'Conversations'; } ?></div>63 <div class="fw-semibold fs-6 text-gray-400"><?php if ($dialbunny_numberOfMessages < 2) { echo 'Conversation'; } else { echo 'Conversations'; } ?></div> 64 64 </div> 65 65 <div class="border border-gray-300 border-dashed rounded min-w-125px py-3 px-4 me-6 mb-3"> … … 68 68 <span class="fas fa-commenting"></span> 69 69 </i> 70 <div class="fs-4 fw-bold counted"><?php echo esc_html($ numberOfUnread); ?></div>70 <div class="fs-4 fw-bold counted"><?php echo esc_html($dialbunny_numberOfUnread); ?></div> 71 71 </div> 72 72 <div class="fw-semibold fs-6 text-gray-400">Unread</div> … … 97 97 if (isset($_GET['phone']) && isset($_GET['countrycode'])) 98 98 { 99 $ current_user_id = get_current_user_id();100 $ phone = sanitize_text_field(wp_unslash($_GET['phone'] ?? ''));101 $ countrycode = '+' . preg_replace('/[^0-9]/', '', sanitize_text_field(wp_unslash($_GET['countrycode'] ?? '')));102 $ managed_number = $phone_details[0]->managed_number ?? '';99 $dialbunny_current_user_id = get_current_user_id(); 100 $dialbunny_phone = sanitize_text_field(wp_unslash($_GET['phone'] ?? '')); 101 $dialbunny_countrycode = '+' . preg_replace('/[^0-9]/', '', sanitize_text_field(wp_unslash($_GET['countrycode'] ?? ''))); 102 $dialbunny_managed_number = $dialbunny_phone_details[0]->managed_number ?? ''; 103 103 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 104 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (to_number = %s OR to_number = %s) AND (from_number = %s OR from_number = %s) ORDER BY created_at DESC LIMIT 40",$current_user_id,$phone,$managed_number,$managed_number,$phone)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery104 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_messages WHERE user = %d AND (to_number = %s OR to_number = %s) AND (from_number = %s OR from_number = %s) ORDER BY created_at DESC LIMIT 40",$dialbunny_current_user_id,$dialbunny_phone,$dialbunny_managed_number,$dialbunny_managed_number,$dialbunny_phone)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 105 105 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 106 $ contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",$current_user_id,$countrycode,$phone)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery107 if ($ opened_item != null) { include('view.php'); }106 $dialbunny_contact = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1",$dialbunny_current_user_id,$dialbunny_countrycode,$dialbunny_phone)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 107 if ($dialbunny_opened_item != null) { include('view.php'); } 108 108 else { include('default.php'); } 109 109 } -
dialbunny/trunk/lib/views/dashboard/messages/view.php
r3328438 r3406310 30 30 <div class="card-body pt-5"> 31 31 <div style="overflow: auto; display: flex; flex-direction: column-reverse;" class="scroll-y me-n5 pe-5 h-500px" style="max-height: 496px;"> 32 <?php foreach ($opened_item as $ item)32 <?php foreach ($opened_item as $dialbunny_item) 33 33 { 34 34 // Set messages to read 35 $d ata = array();36 $d ata['reading'] = 1;35 $dialbunny_data = array(); 36 $dialbunny_data['reading'] = 1; 37 37 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 38 $wpdb->update($messages,$d ata,array('user' => wp_get_current_user()->ID,'id' => sanitize_text_field($item->id)), null, array('%d', '%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery38 $wpdb->update($messages,$dialbunny_data,array('user' => wp_get_current_user()->ID,'id' => sanitize_text_field($dialbunny_item->id)), null, array('%d', '%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 39 39 // check if it's the client or user talking 40 if ($ item->from_number == sanitize_text_field(wp_unslash($_GET['phone'])))40 if ($dialbunny_item->from_number == sanitize_text_field(wp_unslash($_GET['phone']))) 41 41 { 42 42 // user … … 47 47 if ($contact != null) { echo '<a class="fs-5 fw-bold text-gray-900 me-1">'.esc_html($contact[0]->name).'</a>'; } 48 48 else { echo '<a class="fs-5 fw-bold text-gray-900 me-1">'.esc_html(dialbunny_formatNumber(sanitize_text_field(wp_unslash($_GET['phone'] ?? '')))).'</a>'; } 49 echo '<span class="text-muted fs-7 mb-1">'.esc_html(dialbunny_timeElapsed($ item->created_at)).'</span>';49 echo '<span class="text-muted fs-7 mb-1">'.esc_html(dialbunny_timeElapsed($dialbunny_item->created_at)).'</span>'; 50 50 echo '</div>'; 51 51 echo '</div>'; 52 echo '<div class="p-5 rounded bg-light-info text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html($ item->message).'</div>';52 echo '<div class="p-5 rounded bg-light-info text-gray-900 fw-semibold mw-lg-400px text-start" data-element="message-text">'.esc_html($dialbunny_item->message).'</div>'; 53 53 echo '</div>'; 54 54 echo '</div>'; … … 61 61 echo '<div class="d-flex align-items-center mb-2">'; 62 62 echo '<div class="me-3">'; 63 echo '<span class="text-muted fs-7 mb-1">'.esc_html(dialbunny_timeElapsed($ item->created_at)).'</span>';64 if (substr($ item->id, -3) == 'you' && strlen($item->id) > 13) { echo '<a class="fs-5 fw-bold text-gray-900 ms-1">You</a>'; }63 echo '<span class="text-muted fs-7 mb-1">'.esc_html(dialbunny_timeElapsed($dialbunny_item->created_at)).'</span>'; 64 if (substr($dialbunny_item->id, -3) == 'you' && strlen($dialbunny_item->id) > 13) { echo '<a class="fs-5 fw-bold text-gray-900 ms-1">You</a>'; } 65 65 else { echo '<a class="fs-5 fw-bold text-gray-900 ms-1">You</a>'; } 66 66 echo '</div>'; 67 67 echo '</div>'; 68 echo '<div class="p-5 rounded bg-light-primary text-gray-900 fw-semibold mw-lg-400px text-end" data-element="message-text">'.esc_html($ item->message).'</div>';68 echo '<div class="p-5 rounded bg-light-primary text-gray-900 fw-semibold mw-lg-400px text-end" data-element="message-text">'.esc_html($dialbunny_item->message).'</div>'; 69 69 echo '</div>'; 70 70 echo '</div>'; -
dialbunny/trunk/lib/views/dashboard/recents.php
r3396401 r3406310 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 $user_id = wp_get_current_user()->ID;7 6 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 8 $saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 9 $opened_details = $wpdb->get_results($wpdb->prepare("SELECT managed_number_code, managed_number FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 10 $table = $wpdb->prefix . 'dialbunny_recents'; 11 $opened_item = array(); 12 $recents_page = 1; 13 $limit = 10; 14 $offset = 0; 7 $dialbunny_saveData = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 8 $dialbunny_opened_details = $wpdb->get_results($wpdb->prepare("SELECT managed_number_code, managed_number FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 9 $dialbunny_opened_item = array(); 10 $dialbunny_recents_page = 1; 11 $dialbunny_limit = 10; 12 $dialbunny_offset = 0; 15 13 if (isset($_GET['recentspage']) && is_numeric($_GET['recentspage']) && $_GET['recentspage'] > 1) { 16 $ recents_page = (int) $_GET['recentspage'];17 $ offset = ($recents_page - 1) * $limit;14 $dialbunny_recents_page = (int) $_GET['recentspage']; 15 $dialbunny_offset = ($dialbunny_recents_page - 1) * $dialbunny_limit; 18 16 } 19 if (!empty($ opened_details[0]->managed_number)) {17 if (!empty($dialbunny_opened_details[0]->managed_number)) { 20 18 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 21 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_recents WHERE to_number = %s OR from_number = %s ORDER BY created_at DESC LIMIT %d OFFSET %d",$opened_details[0]->managed_number,$opened_details[0]->managed_number,$limit,$offset)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery19 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_recents WHERE to_number = %s OR from_number = %s ORDER BY created_at DESC LIMIT %d OFFSET %d",$dialbunny_opened_details[0]->managed_number,$dialbunny_opened_details[0]->managed_number,$dialbunny_limit,$dialbunny_offset)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 22 20 } 23 21 ?> … … 27 25 <h3 class="card-title">Recents</h3> 28 26 <div class="card-toolbar"> 29 <?php if ($ recents_page > 1)27 <?php if ($dialbunny_recents_page > 1) 30 28 { 31 echo '<a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=recents&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&recentspage=' . esc_html($ recents_page - 1) .'" class="btn btn-light btn-sm me-3">';29 echo '<a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=recents&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&recentspage=' . esc_html($dialbunny_recents_page - 1) .'" class="btn btn-light btn-sm me-3">'; 32 30 echo '<span class="menu-bullet">'; 33 31 echo '<span class="fa fa-arrow-left"></span>'; … … 36 34 } 37 35 ?> 38 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($ recents_page); ?></span>39 <?php if (isset($ opened_item) && count($opened_item) == 10)36 <span class="btn btn-bg-primary btn-sm me-3 text-white"><?php echo esc_html($dialbunny_recents_page); ?></span> 37 <?php if (isset($dialbunny_opened_item) && count($dialbunny_opened_item) == 10) 40 38 { 41 echo '<a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=recents&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&recentspage=' . esc_html($ recents_page + 1) .'" class="btn btn-light btn-sm me-3">';39 echo '<a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=recents&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&recentspage=' . esc_html($dialbunny_recents_page + 1) .'" class="btn btn-light btn-sm me-3">'; 42 40 echo '<span class="menu-bullet">'; 43 41 echo '<span class="fa fa-arrow-right"></span>'; … … 50 48 <div class="card-body"> 51 49 <div class="table-responsive"> <?php 52 if (isset($ opened_item) && $opened_item != null)50 if (isset($dialbunny_opened_item) && $dialbunny_opened_item != null) 53 51 { 54 52 echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">'; 55 53 echo '<tbody>'; 56 foreach ($ opened_item as $record)54 foreach ($dialbunny_opened_item as $dialbunny_record) 57 55 { 58 $table_contacts = $wpdb->prefix . 'dialbunny_contacts';59 56 echo '<tr class="align-middle">'; 60 57 // if recent number is outbound or inbound 61 if($ record->to_countrycode.$record->to_number == $saveData[0]->managed_number_code.$saveData[0]->managed_number)58 if($dialbunny_record->to_countrycode.$dialbunny_record->to_number == $dialbunny_saveData[0]->managed_number_code.$dialbunny_saveData[0]->managed_number) 62 59 { 63 60 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 64 $ opened_contact = $wpdb->get_results($wpdb->prepare("SELECT name,id FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1", $user_id, $record->from_countrycode, $record->from_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery65 echo '<td class="col-6">' . esc_html( !empty($ opened_contact[0]->name) ? $opened_contact[0]->name : $record->from_countrycode.' '.dialbunny_formatNumber($record->from_number) ) . '<br><span class="phone-inbound"></span><span class="px-3">' . esc_html(dialbunny_timeElapsed($record->created_at)) . '</span></td>';66 if ($ opened_contact == null) { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&contact=new&newnumbercountrycode='. esc_html($record->from_countrycode) .'&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&newnumber='. esc_html($record->from_number) .'" class="btn border btn-sm btn-active-light-primary">Create Contact</a></div></td>'; }67 else { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&contact='. esc_html($ opened_contact[0]->id) .'" class="btn border btn-sm btn-active-light-primary">View Contact</a></div></td>'; }61 $dialbunny_opened_contact = $wpdb->get_results($wpdb->prepare("SELECT name,id FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1", wp_get_current_user()->ID, $dialbunny_record->from_countrycode, $dialbunny_record->from_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 62 echo '<td class="col-6">' . esc_html( !empty($dialbunny_opened_contact[0]->name) ? $dialbunny_opened_contact[0]->name : $dialbunny_record->from_countrycode.' '.dialbunny_formatNumber($dialbunny_record->from_number) ) . '<br><span class="phone-inbound"></span><span class="px-3">' . esc_html(dialbunny_timeElapsed($dialbunny_record->created_at)) . '</span></td>'; 63 if ($dialbunny_opened_contact == null) { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&contact=new&newnumbercountrycode='. esc_html($dialbunny_record->from_countrycode) .'&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&newnumber='. esc_html($dialbunny_record->from_number) .'" class="btn border btn-sm btn-active-light-primary">Create Contact</a></div></td>'; } 64 else { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&contact='. esc_html($dialbunny_opened_contact[0]->id) .'" class="btn border btn-sm btn-active-light-primary">View Contact</a></div></td>'; } 68 65 } 69 66 else 70 67 { 71 68 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 72 $ opened_contact = $wpdb->get_results($wpdb->prepare("SELECT name,id FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1", $user_id, $record->to_countrycode, $record->to_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery73 echo '<td class="col-6">' . esc_html( !empty($ opened_contact[0]->name) ? $opened_contact[0]->name : $record->to_countrycode.' '.dialbunny_formatNumber($record->to_number) ) . '<br><span class="phone-outbound"></span><span class="px-3">' . esc_html(dialbunny_timeElapsed($record->created_at)) . '</span></td>';74 if ($ opened_contact == null) { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&contact=new&newnumbercountrycode='. esc_html($record->from_countrycode) .'&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&newnumber='. esc_html($record->to_number) .'" class="btn border btn-sm btn-active-light-primary">Create Contact</a></div></td>'; }75 else { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&contact='. esc_html($ opened_contact[0]->id) .'" class="btn border btn-sm btn-active-light-primary">View Contact</a></div></td>'; }69 $dialbunny_opened_contact = $wpdb->get_results($wpdb->prepare("SELECT name,id FROM {$wpdb->prefix}dialbunny_contacts WHERE user = %d AND countrycode = %s AND phone = %s LIMIT 1", wp_get_current_user()->ID, $dialbunny_record->to_countrycode, $dialbunny_record->to_number)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 70 echo '<td class="col-6">' . esc_html( !empty($dialbunny_opened_contact[0]->name) ? $dialbunny_opened_contact[0]->name : $dialbunny_record->to_countrycode.' '.dialbunny_formatNumber($dialbunny_record->to_number) ) . '<br><span class="phone-outbound"></span><span class="px-3">' . esc_html(dialbunny_timeElapsed($dialbunny_record->created_at)) . '</span></td>'; 71 if ($dialbunny_opened_contact == null) { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&contact=new&newnumbercountrycode='. esc_html($dialbunny_record->from_countrycode) .'&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&newnumber='. esc_html($dialbunny_record->to_number) .'" class="btn border btn-sm btn-active-light-primary">Create Contact</a></div></td>'; } 72 else { echo '<td class="col-6"><div class="d-flex justify-content-end"><a href="' . esc_url(admin_url('admin.php?page=dialbunny_dashboard')) . '&dashboardpage=contacts&user_nonce='.esc_attr(sanitize_text_field(wp_unslash($_GET['user_nonce']))).'&contact='. esc_html($dialbunny_opened_contact[0]->id) .'" class="btn border btn-sm btn-active-light-primary">View Contact</a></div></td>'; } 76 73 } 77 74 echo '</tr>'; -
dialbunny/trunk/lib/views/dashboard/released.php
r3325864 r3406310 4 4 <div class="container-xxl" id="content_container"> 5 5 <?php 6 $table = $wpdb->prefix . 'dialbunny_released_numbers';7 $current_user_id = wp_get_current_user()->ID;8 6 // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection. 9 $ opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_released_numbers WHERE user = %d LIMIT 50", $current_user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery7 $dialbunny_opened_item = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}dialbunny_released_numbers WHERE user = %d LIMIT 50", wp_get_current_user()->ID)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 10 8 ?> 11 9 <?php if (isset($_GET['erroraddingnumber'])) { echo wp_kses_post(dialbunny_main_danger("Phone Number Could Not Be Added", "An error has occurred and we could not process your request.")); } ?> … … 30 28 <div class="card-body"> 31 29 <div class="table-responsive"> <?php 32 if ($ opened_item != null)30 if ($dialbunny_opened_item != null) 33 31 { 34 32 echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">'; … … 42 40 echo '</thead>'; 43 41 echo '<tbody>'; 44 foreach ($ opened_item as $record)42 foreach ($dialbunny_opened_item as $dialbunny_record) 45 43 { 46 44 echo '<tr class="align-middle">'; 47 echo '<td class="col-3">' . esc_html(dialbunny_formatNumber($ record->phone)) . '</td>';48 echo '<td class="col-2">' . esc_html(dialbunny_timeElapsed($ record->created_at)) . '</td>';45 echo '<td class="col-3">' . esc_html(dialbunny_formatNumber($dialbunny_record->phone)) . '</td>'; 46 echo '<td class="col-2">' . esc_html(dialbunny_timeElapsed($dialbunny_record->created_at)) . '</td>'; 49 47 echo '<td class="col-2"><span class="badge badge-success">None</span></td>'; 50 echo '<td class="col-2"><button type="submit" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($ record->phone) . '\'; document.getElementById(\'countrycode\').value = \'' . esc_html($record->countrycode) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($record->countrycode) . ' ' . esc_html($record->phone) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Re-Request</button></td>';48 echo '<td class="col-2"><button type="submit" onclick="document.getElementById(\'requestedNumber\').value = \'' . esc_html($dialbunny_record->phone) . '\'; document.getElementById(\'countrycode\').value = \'' . esc_html($dialbunny_record->countrycode) . '\'; document.getElementById(\'requestedNumberUI\').innerHTML = \'' . esc_html($dialbunny_record->countrycode) . ' ' . esc_html($dialbunny_record->phone) . '\';" class="btn border btn-sm btn-active-light-primary" data-bs-toggle="modal" data-bs-target="#modal_1">Re-Request</button></td>'; 51 49 echo '</tr>'; 52 50 } -
dialbunny/trunk/readme.txt
r3396401 r3406310 3 3 Requires at least: 6.2 4 4 Tested up to: 6.8 5 Stable tag: 1.1. 55 Stable tag: 1.1.6 6 6 License: GPLv2 or later 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.