Plugin Directory

Changeset 3406310


Ignore:
Timestamp:
11/30/2025 08:54:43 PM (3 months ago)
Author:
cameron434
Message:

update trunk 1.1.6

Location:
dialbunny/trunk
Files:
3 added
24 edited

Legend:

Unmodified
Added
Removed
  • dialbunny/trunk/app.php

    r3396401 r3406310  
    132132                                </div>
    133133                                <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>
    135135                                    <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>
    136136                                </div>
     
    185185                    echo 'Recent Phone Calls';
    186186                                    break;
     187                                    case 'profile':
     188                    echo 'Settings → Profile';
     189                                    break;
    187190
    188191                    default:
     
    202205                            </div>
    203206                            <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>   
    204210                                <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">
    205211                                    <svg x="0px" y="0px" width="100" height="100" viewBox="0 0 26 26">
     
    212218              <?php
    213219                            // 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.DirectDatabaseQuery
    215                             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>'; }
    216222              switch ($page)
    217223              {
    218                                 case 'keypad':
     224                case 'keypad':
    219225                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/keypad.php');
    220226                break;
    221                                 case 'howitworks':
     227                case 'howitworks':
    222228                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/howitworks.php');
    223229                break;
    224                                 case 'choose':
     230                case 'choose':
    225231                if (get_option('dialbunny_user_can_request_number') == true || current_user_can('administrator')) { include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/choose.php'); }
    226232                break;
    227                                 case 'released':
     233                case 'released':
    228234                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/released.php');
    229235                break;
    230                                 case 'inbound':
     236                case 'inbound':
    231237                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/inbound.php');
    232238                break;
    233                                 case 'aiassistant':
     239                case 'aiassistant':
    234240                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/ai_assistant.php');
    235241                break;
    236                                 case 'calendar':
     242                case 'calendar':
    237243                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/calendar.php');
    238244                break;
    239                                 case 'messages':
     245                case 'messages':
    240246                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/messages/messages.php');
    241247                break;
    242                                 case 'contacts':
     248                case 'contacts':
    243249                include(plugin_dir_path(__FILE__) . 'lib/views/dashboard/contacts/contacts.php');
    244250                break;
    245                                 case 'recents':
     251                case 'recents':
    246252                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');
    247256                break;
    248257
  • dialbunny/trunk/dialbunny.php

    r3396401 r3406310  
    44 Plugin URI: https://dialbunny.com/
    55 Description: Easily manage inbound and outbound phone calls and text messages
    6  Version: 1.1.5
     6 Version: 1.1.6
    77 Author:DialBunny
    88 Author URI: https://dialbunny.com
     
    4040   {
    4141     // 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);
    4343
    4444     // Only apply the Bootstrap "light" theme on the DialBunny dashboard page
     
    9292   }
    9393
    94    function load_custom_blank_page_styles($hook)
     94   function dialbunny_load_custom_blank_page_styles($hook)
    9595   {
    9696     // This only applies to DialBunny dashboard for a clean interface
    9797     if ($hook == 'toplevel_page_dialbunny_dashboard')
    9898     {
     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' );
    99106       // Dequeue
    100107       wp_dequeue_style( 'dashicons' );
     
    143150         include(plugin_dir_path(__FILE__) . 'lib/components/alerts.php' );
    144151         include(plugin_dir_path(__FILE__) . 'lib/components/countrycode.php' );
     152         include(plugin_dir_path(__FILE__) . 'lib/components/countries.php' );
    145153         include(plugin_dir_path(__FILE__) . 'lib/components/timezone.php' );
    146154         include(plugin_dir_path(__FILE__) . 'lib/components/formatnumber.php' );
     
    159167        'manage_options',
    160168        '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' ); },
    162170         null
    163171       );
     
    168176        'manage_options',
    169177        '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' ); },
    171179         null
    172180       );
     
    177185        'manage_options',
    178186        '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' ); },
    180188         null
    181189       );
     
    186194        'manage_options',
    187195        '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' ); },
    189197         null
    190198       );
     
    195203        'manage_options',
    196204        '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' ); },
    198206         null
    199207       );
     
    204212        'manage_options',
    205213        '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' ); },
    207215         null
    208216       );
     
    213221        'manage_options',
    214222        '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' ); },
    216224         null
    217225       );
     
    222230        'manage_options',
    223231        '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' ); },
    225233         null
    226234       );
  • dialbunny/trunk/lib/config/initiate_tables.php

    r3396401 r3406310  
    140140    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    141141    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);
    142167  }
    143168}
  • dialbunny/trunk/lib/controllers/admin.php

    r3384851 r3406310  
    123123    if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; }
    124124    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; }
    126126
    127127    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']));
    130130
    131131    $table = $wpdb->prefix . 'dialbunny_released_numbers';
    132132    // 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.DirectDatabaseQuery
     133    $deleted = $wpdb->delete($table, array('id' => $id), array('%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    134134
    135135    echo $deleted ? esc_html("$phone removed successfully!") : esc_html__("Failed to remove released number!", 'dialbunny');
  • dialbunny/trunk/lib/controllers/dashboard.php

    r3336718 r3406310  
    151151    $contains    = sanitize_text_field(wp_unslash($_POST['contains'] ?? ''));
    152152    $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']));
    154156
    155157    // Build redirect URL safely
     
    161163        'contains'    => $contains,
    162164        'type'        => $type,
    163         'user_nonce'    => $user_nonce, // carry it forward
     165        'requirements'=> $requirements,
     166        'beta'        => $beta,
     167        'user_nonce'  => $user_nonce, // carry it forward
    164168    ], admin_url('admin.php'));
    165169
     
    173177    if ( !isset($_POST['user_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['user_nonce'])), 'DialBunny') ) { return; }
    174178    global $wpdb;
     179    $user_id = get_current_user_id();
    175180    $number_raw = sanitize_text_field(wp_unslash($_POST['number'] ?? ''));
    176181    $country_code = '';
     
    179184    // Define known country codes and lengths
    180185    $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
    189313    ];
    190314
     
    211335      $keys = new DialBunnyKeysClass();
    212336      $client = new Client($keys->TWILIO_SID(), $keys->TWILIO_TOKEN());
     337      $incoming_phone_number;
    213338
    214339      // 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([
    216343        "friendlyName" => wp_get_current_user()->user_login,
    217344        "emergencyStatus" => "Inactive",
     
    221348        "voiceMethod" => "POST",
    222349        "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) {
    226367        $table = $wpdb->prefix . 'dialbunny_phone_details';
    227368        // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection.
    228         $existing = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}dialbunny_phone_details WHERE user = %d LIMIT 1", $user_id)); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
     369        $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
    229370
    230371        $now = current_time('mysql', 1);
     
    246387        } else {
    247388          // 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          ]);
    249406        }
    250407
     
    255412      }
    256413    } 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']))));
    258415    }
    259416    exit;
     
    587744  }
    588745
     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  }*/
    589879}
    590880 ?>
  • dialbunny/trunk/lib/controllers/webcalling.php

    r3396401 r3406310  
    7878    if (isset($_POST['BrowserOutgoing']) && $_POST['BrowserOutgoing'] === 'true')
    7979    {
    80       if (!isset($_POST['To'])) { exit; }
     80      if (!isset($_POST['To_number'])) { exit; }
     81      if (!isset($_POST['To_code'])) { exit; }
    8182      $response = new VoiceResponse();
    8283      $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  
    1010    <div class="dialbunny-card">
    1111        <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 users account:</p>
     12        <p class="dialbunny-description">Follow these steps to manually add a phone number to a user's account:</p>
    1313        <ol class="dialbunny-list">
    1414            <li>Go to your Twilio account.</li>
  • dialbunny/trunk/lib/views/admin/header.php

    r3396401 r3406310  
    11<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
    2 <?php
    3 
    4 // Define the page slug (adjust to your plugin's admin page slug)
    5 $page_slug = 'dialbunny_';
    6 
    7 // Define current page
    8 $current_page = isset($_GET['page']) ? wp_unslash(sanitize_text_field($_GET['page'])) : '';
    9 
    10 // Base URL for tabs
    11 $base_url = admin_url('admin.php?page=' . $page_slug);
    12 ?>
    132
    143<div class="wrap modern-admin-header">
     
    165        <h1 class="header-title">DialBunny Admin Settings</h1>
    176        <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>
    209        </div>
    2110    </div>
    2211    <div class="tab-container">
    2312        <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>
    3625        </div>
    3726    </div>
    3827
    3928    <?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') : ?>
    4130        <div class="subtab-container">
    4231            <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>
    4736            </div>
    4837        </div>
    4938    <?php endif; ?>
    5039    <?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') : ?>
    5241        <div class="subtab-container">
    5342            <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>
    5847            </div>
    5948        </div>
  • dialbunny/trunk/lib/views/admin/license.php

    r3384851 r3406310  
    33global $wpdb;
    44// 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.DirectDatabaseQuery
     5$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
    66?>
    77
     
    99    <?php
    1010    // 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) {
    1212        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>';
    1313    } else {
     
    3030                <label for="license_key" class="dialbunny-label">License Key</label>
    3131                <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); } ?>"
    3333                       class="dialbunny-input">
    3434            </div>
  • dialbunny/trunk/lib/views/admin/released.php

    r3384851 r3406310  
    22<?php
    33global $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.DirectDatabaseQuery
     4$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
    66?>
    77
     
    2727    <div class="dialbunny-card">
    2828        <h2 class="dialbunny-title">Released Numbers</h2>
    29         <?php if (!empty($records)) : ?>
     29        <?php if (!empty($dialbunny_records)) : ?>
    3030            <div class="dialbunny-table-container">
    3131                <table class="dialbunny-table">
     
    3737                    </thead>
    3838                    <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;
    4444                        ?>
    4545                            <tr>
    46                                 <td><?php echo esc_html($fullNumber); ?></td>
     46                                <td><?php echo esc_html($dialbunny_fullNumber); ?></td>
    4747                                <td>
    4848                                    <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post" class="dialbunny-form-inline">
     
    5050                                        <input type="hidden" name="action" value="dialbunny_remove_released">
    5151                                        <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); ?>">
    5353                                        <button type="submit" class="dialbunny-button dialbunny-button-delete">Remove Permanently</button>
    5454                                    </form>
  • dialbunny/trunk/lib/views/admin/setup.php

    r3384851 r3406310  
    22<?php
    33global $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.DirectDatabaseQuery
    6 $decrypt = 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();
    77?>
    88
     
    2626                <label for="twilio_sid" class="dialbunny-label">Twilio SID</label>
    2727                <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)); } ?>"
    2929                       placeholder="Enter Twilio SID" class="dialbunny-input">
    3030            </div>
     
    3232                <label for="twilio_token" class="dialbunny-label">Twilio Auth Token</label>
    3333                <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)); } ?>"
    3535                       placeholder="Enter Twilio Auth Token" class="dialbunny-input">
    3636            </div>
     
    4949                <label for="twiml_app_sid" class="dialbunny-label">TwiML App SID</label>
    5050                <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)); } ?>"
    5252                       placeholder="Enter TwiML App SID" class="dialbunny-input">
    5353            </div>
     
    6161                <label for="api_key" class="dialbunny-label">API SID Key</label>
    6262                <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)); } ?>"
    6464                       placeholder="Enter API SID Key" class="dialbunny-input">
    6565            </div>
     
    6767                <label for="api_secret" class="dialbunny-label">API Secret</label>
    6868                <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)); } ?>"
    7070                       placeholder="Enter API Secret" class="dialbunny-input">
    7171            </div>
  • dialbunny/trunk/lib/views/dashboard/ai_assistant.php

    r3384851 r3406310  
    44  <div class="container-xxl" id="content_container">
    55    <?php
    6     $table = $wpdb->prefix . 'dialbunny_phone_details';
     6    $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details';
    77    // 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.DirectDatabaseQuery
    9     $decodedData = 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);
    1010    ?>
    1111    <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your AI assistant settings.")); }  ?>
     
    109109                                                   <label class="col-12 col-form-label fw-semibold fs-6">SID:</label>
    110110                                                   <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($decodedData['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']); } ?>" />
    112112                                                   </div>
    113113                                                </div>
     
    135135                                                   <label class="col-12 col-form-label fw-semibold fs-6">Inbound SIP Url:</label>
    136136                                                   <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($decodedData['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']); } ?>" />
    138138                                                   </div>
    139139                                                </div>
     
    199199                                              <div class="mb-10 cursor-pointer">
    200200                                                  <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($decodedData['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"'; } ?>>
    202202                                                      <label class="fs-5 text-gray-900 fw-semibold cursor-pointer" for="flexCheckDefault1">Twilio</label>
    203203                                                  </div>
     
    205205                                              <div class="cursor-pointer">
    206206                                                  <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($decodedData['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"'; } ?>>
    208208                                                      <label class="fs-5 text-gray-900 fw-semibold cursor-pointer" for="flexCheckDefault2">Vapi</label>
    209209                                                  </div>
     
    236236                                                                            <div class="col-sm-6">
    237237                                              <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($decodedData['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"/>
    239239                                              </div>
    240240                                                                            </div>
     
    248248                                                                            <div class="col-sm-6">
    249249                                              <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($decodedData['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" />
    251251                                              </div>
    252252                                                                            </div>
     
    260260                                                                            <div class="col-sm-6">
    261261                                              <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($decodedData['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"/>
    263263                                              </div>
    264264                                                                            </div>
     
    287287                                              <label class="col-12 col-form-label fw-semibold fs-6">Greeting Message:</label>
    288288                                              <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($decodedData['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!'; } ?>" />
    290290                                              </div>
    291291                                          </div>
     
    293293                                              <label class="col-12 col-form-label fw-semibold fs-6">Voice:</label>
    294294                                              <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($decodedData['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'; } ?>" />
    296296                                              </div>
    297297                                          </div>
     
    364364                                                                            <div class="col-sm-6">
    365365                                              <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($decodedData['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"/>
    367367                                              </div>
    368368                                                                            </div>
  • dialbunny/trunk/lib/views/dashboard/calendar.php

    r3325864 r3406310  
    6262
    6363    <?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();
    6666    // 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.DirectDatabaseQuery
    68     $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); }
    7070    ?>
    7171    <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your timetable settings.")); }  ?>
     
    9090                    <div class="row mb-6">
    9191                      <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)
    9393                      {
    9494                        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>';
    9595                        echo '<input id="sunday_status" type="hidden" name="sunday_status" value="1"></input>';
    9696                      }
    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)
    9898                      {
    9999                        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>';
     
    108108                        <div class="row">
    109109                          <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); } ?>" />
    114114                          </div>
    115115                        </div>
     
    119119                    <div class="row mb-6">
    120120                      <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)
    122122                      {
    123123                        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>';
    124124                        echo '<input id="monday_status" type="hidden" name="monday_status" value="1"></input>';
    125125                      }
    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)
    127127                      {
    128128                        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>';
     
    137137                        <div class="row">
    138138                          <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); } ?>" />
    143143                          </div>
    144144                        </div>
     
    147147                    <div class="row mb-6">
    148148                      <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)
    150150                      {
    151151                        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>';
    152152                        echo '<input id="tuesday_status" type="hidden" name="tuesday_status" value="1"></input>';
    153153                      }
    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)
    155155                      {
    156156                        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>';
     
    165165                        <div class="row">
    166166                          <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); } ?>" />
    171171                          </div>
    172172                        </div>
     
    175175                    <div class="row mb-6">
    176176                      <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)
    178178                      {
    179179                        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>';
    180180                        echo '<input id="wednesday_status" type="hidden" name="wednesday_status" value="1"></input>';
    181181                      }
    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)
    183183                      {
    184184                        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>';
     
    193193                        <div class="row">
    194194                          <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); } ?>" />
    199199                          </div>
    200200                        </div>
     
    203203                    <div class="row mb-6">
    204204                      <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)
    206206                      {
    207207                        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>';
    208208                        echo '<input id="thursday_status" type="hidden" name="thursday_status" value="1"></input>';
    209209                      }
    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)
    211211                      {
    212212                        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>';
     
    221221                        <div class="row">
    222222                          <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); } ?>" />
    227227                          </div>
    228228                        </div>
     
    231231                    <div class="row mb-6">
    232232                      <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)
    234234                      {
    235235                        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>';
    236236                        echo '<input id="friday_status" type="hidden" name="friday_status" value="1"></input>';
    237237                      }
    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)
    239239                      {
    240240                        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>';
     
    249249                        <div class="row">
    250250                          <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); } ?>" />
    255255                          </div>
    256256                        </div>
     
    260260                    <div class="row">
    261261                      <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)
    263263                      {
    264264                        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>';
    265265                        echo '<input id="saturday_status" type="hidden" name="saturday_status" value="1"></input>';
    266266                      }
    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)
    268268                      {
    269269                        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>';
     
    278278                        <div class="row">
    279279                          <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); } ?>" />
    284284                          </div>
    285285                        </div>
     
    309309                            <?php
    310310                            // 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 ?>
    312312                          </div>
    313313                        </div>
  • dialbunny/trunk/lib/views/dashboard/choose.php

    r3325864 r3406310  
    11<?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 couldnt 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; } ?>
    33<div class="content d-flex flex-column flex-column-fluid" id="content">
    44  <div class="container-xxl" id="content_container">
    55    <?php
    66    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);
    1516    }
    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}
     44if ( isset( $_GET['beta'] ) && sanitize_text_field( wp_unslash( $_GET['beta'] ) ) === 'none' ) {
     45    $dialbunny_searchData['beta'] = false; // Exclude beta numbers
     46}
    2147    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']));
    2349    }
    2450
    2551    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']));
    2753    }
    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']));
    3056        $type = sanitize_text_field(wp_unslash($_GET['type']));
    31 
    3257        try {
    3358            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;
    3464                case 'local':
    35                     $data = $client->availablePhoneNumbers($countryCode)->local->read($searchData, 15);
     65                    $dialbunny_local_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->local->read($dialbunny_searchData, 15);
    3666                    break;
    3767                case 'TollFree':
    38                     $data = $client->availablePhoneNumbers($countryCode)->tollFree->read($searchData, 15);
     68                    $dialbunny_tollFree_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->tollFree->read($dialbunny_searchData, 15);
    3969                    break;
    4070                case 'mobile':
    41                     $data = $client->availablePhoneNumbers($countryCode)->mobile->read($searchData, 15);
     71                    $dialbunny_mobile_data = $dialbunny_client->availablePhoneNumbers($dialbunny_countryCode)->mobile->read($dialbunny_searchData, 15);
    4272                    break;
    4373            }
    4474        } catch (Exception $e) {
    45             $errorMessage = true;
     75            $dialbunny_errorMessage = true;
    4676        }
    4777    }
    4878    ?>
     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.")); }  ?>
    4980    <?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.")); }  ?>
    5182    <form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post" class="form">
    5283      <?php wp_nonce_field( 'DialBunny', 'user_nonce' ); ?>
     
    5687          <div class="d-flex align-items-center">
    5788            <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                ?>
    6197              </select>
    6298            </div>
    6399            <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=&quot;spinner-border spinner-border-sm&quot;></span> Searching...'; this.disabled=true; this.form.submit();" class="btn btn-primary me-5">Search</button>
    65101            </div>
    66102          </div>
     
    68104            <div class="separator separator-dashed mt-9 mb-6"></div>
    69105            <div class="row g-8" data-select2-id="select2-data-123-mnoi">
    70               <div class="col-lg-4">
     106              <div class="col-lg-3">
    71107                <label class="fs-6 form-label fw-bold text-gray-900">
    72108                  <span class="">Area Code</span>
     
    77113                  </span>
    78114                </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">
    82118                <label class="fs-6 form-label fw-bold text-gray-900">
    83119                  <span class="">Contains</span>
     
    88124                  </span>
    89125                </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">
    93129                <label class="fs-6 form-label fw-bold text-gray-900">
    94130                  <span class="">Type</span>
     
    101137                <div class="nav-group nav-group-fluid">
    102138                  <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"'; } ?>>
    104144                    <span class="btn btn-sm btn-color-muted btn-active btn-active-primary fw-bold px-4">Local</span>
    105145                  </label>
     
    115155              </div>
    116156            </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>
    117204          </div>
    118205        </div>
     
    127214
    128215          <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)))
    130217                {
    131218                  echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">';
     
    135222                    echo '<th>Capabilities</th>';
    136223                    echo '<th>Type</th>';
    137                     echo '<th>Address Requirements</th>';
     224                    echo '<th>Local Regulatory Requirements</th>';
    138225                    echo '<th></th>';
    139226                  echo '</tr>';
    140227                  echo '</thead>';
    141228                  echo '<tbody>';
    142                   foreach ($data as $record)
     229                  foreach ($dialbunny_local_data as $dialbunny_record)
    143230                  {
    144231                    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>';
    146233
    147234                      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>';
    156278                    echo '</tr>';
    157279                  }
     
    159281                  echo '</table>';
    160282                }
    161                 else if (isset($_GET['countrycode']) && empty($data))
     283                else if (isset($_GET['countrycode']))
    162284                {
    163285                  echo '<div class="card border border-gray-300 border-dashed rounded p-6">
     
    171293                                            </div>';
    172294                }
    173                 else if (!isset($_GET['countrycode']) && empty($data))
     295                else if (!isset($_GET['countrycode']))
    174296                {
    175297                  echo '<div class="card border border-gray-300 border-dashed rounded p-6">
     
    189311  </div>
    190312</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>
    218346                  </div>
    219347                </div>
     
    221349            </div>
    222350          </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>
    235398      </div>
    236399    </div>
    237400  </div>
    238 </div>
     401</form>
  • dialbunny/trunk/lib/views/dashboard/contacts/contacts.php

    r3328438 r3406310  
    11<?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 couldnt 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; } ?>
    33<div class="content d-flex flex-column flex-column-fluid" id="content">
    44    <div class="container-xxl" id="content_container">
    55
    66      <?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';
    99      // 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.DirectDatabaseQuery
     10      $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
    1111      // 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.DirectDatabaseQuery
     12      $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
    1313      // 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; }
    1616      // 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;
    2121      // Handle pagination
    2222      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;
    2525      }
    2626      ?>
     
    5454                            <span class="fas fa-user"></span>
    5555                          </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>
    5757                                                </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>
    5959                                            </div>
    6060                                            <div class="border border-gray-300 border-dashed rounded min-w-125px py-3 px-4 me-6 mb-3">
     
    6363                            <span class="fas fa-user"></span>
    6464                          </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>
    6666                                                </div>
    6767                                                <div class="fw-semibold fs-6 text-gray-400">Blocked</div>
     
    9797            include('new.php');
    9898        } 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';
    101101            // 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.DirectDatabaseQuery
     102            $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
    103103            if (!empty($opened_item)) {
    104104                include('view.php');
  • dialbunny/trunk/lib/views/dashboard/contacts/default.php

    r3328438 r3406310  
    5050                <tbody class="fs-6">
    5151                  <?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();
    5454                    $search = isset($_GET['search']) ? '%' . $wpdb->esc_like(sanitize_text_field(wp_unslash($_GET['search']))) . '%' : '';
    5555
     
    5757                    if (strlen($search) > 2) {
    5858                        // 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.DirectDatabaseQuery
     59                        $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
    6060                    } else {
    6161                      // 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.DirectDatabaseQuery
     62                      $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
    6363                    }
    6464                  ?>
    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): ?>
    6767                    <?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;
    7676                      }
    7777
    78                       $contactUrl = esc_url(add_query_arg([
     78                      $dialbunny_contactUrl = esc_url(add_query_arg([
    7979                        'dashboardpage' => 'contacts',
    80                         'contact' => $item->id,
     80                        'contact' => $dialbunny_item->id,
    8181                        'user_nonce'    => sanitize_text_field(wp_unslash($_GET['user_nonce']))
    8282                      ], $dialbunnyDashboardUrl));
     
    8686                        <div class="d-flex align-items-center">
    8787                          <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))); ?>
    9090                            </span>
    9191                          </div>
    9292                          <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); ?>
    9595                            </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>
    9797                          </div>
    9898                        </div>
    9999                      </td>
    100                       <td><?php echo esc_html($item->company); ?></td>
     100                      <td><?php echo esc_html($dialbunny_item->company); ?></td>
    101101                      <td>
    102                         <?php if ($item->blocked == 1): ?>
     102                        <?php if ($dialbunny_item->blocked == 1): ?>
    103103                          <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); ?>
    107107                          </span>
    108108                        <?php else: ?>
     
    111111                      </td>
    112112                      <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>
    114114                      </td>
    115115                    </tr>
     
    137137      <div class="separator mb-6"></div>
    138138      <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): ?>
    140140        <?php
    141           $prevUrl = esc_url(add_query_arg([
     141          $dialbunny_prevUrl = esc_url(add_query_arg([
    142142            'dashboardpage' => 'contacts',
    143             'resultsPage'   => $resultsPage - 1,
     143            'resultsPage'   => $dialbunny_resultsPage - 1,
    144144            'list'          => '',
    145145            'user_nonce'    => sanitize_text_field(wp_unslash($_GET['user_nonce']))
    146146          ], $dialbunnyDashboardUrl));
    147147        ?>
    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">
    149149          <span class="menu-bullet">
    150150            <span class="fa fa-arrow-left"></span>
     
    153153      <?php endif; ?>
    154154
    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): ?>
    158158        <?php
    159           $nextUrl = add_query_arg([
     159          $dialbunny_nextUrl = add_query_arg([
    160160            'dashboardpage' => 'contacts',
    161             'resultsPage'   => $resultsPage + 1,
     161            'resultsPage'   => $dialbunny_resultsPage + 1,
    162162            'list'          => '',
    163163            'user_nonce'    => sanitize_text_field(wp_unslash($_GET['user_nonce']))
    164164          ], $dialbunnyDashboardUrl);
    165165        ?>
    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">
    167167          <span class="menu-bullet">
    168168            <span class="fa fa-arrow-right"></span>
     
    177177      <div class="row g-6 g-xl-9">
    178178        <?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;
    190190                  }
    191191
    192192                  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) {
    198198                      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>';
    202202                  } else {
    203203                      echo '<span class="badge badge-light-success fw-bold px-4 py-3">Normal</span>';
     
    214214      </div>
    215215        <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): ?>
    217217            <a href="<?php echo esc_url(add_query_arg([
    218218                'dashboardpage' => 'contacts',
    219                 'resultsPage' => $resultsPage - 1,
     219                'resultsPage' => $dialbunny_resultsPage - 1,
    220220                'block' => '',
    221221                'user_nonce'    => sanitize_text_field(wp_unslash($_GET['user_nonce']))
     
    226226            </a>
    227227          <?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): ?>
    230230            <a href="<?php echo esc_url(add_query_arg([
    231231                'dashboardpage' => 'contacts',
    232                 'resultsPage' => $resultsPage + 1,
     232                'resultsPage' => $dialbunny_resultsPage + 1,
    233233                'block' => '',
    234234                'user_nonce'    => sanitize_text_field(wp_unslash($_GET['user_nonce']))
  • dialbunny/trunk/lib/views/dashboard/inbound.php

    r3326827 r3406310  
    44  <div class="container-xxl" id="content_container">
    55    <?php
    6     $table = $wpdb->prefix . 'dialbunny_phone_details';
     6    $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details';
    77    // 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
     8    $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
    99    ?>
    1010    <?php if (isset($_GET['updated'])) { echo wp_kses_post(dialbunny_main_success("Saved Successfuly", "You have successfully updated your inbound call settings.")); }  ?>
     
    3535                          <div class="col-lg-4 fv-row">
    3636                            <?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))
    3939                            {
    4040                              // Escaped inside the dialbunny_country_code() function
    41                               echo dialbunny_country_code($mainNumber1[0], "countrycode1"); // phpcs:ignore WordPress.Security.EscapeOutput
     41                              echo dialbunny_country_code($dialbunny_mainNumber1[0], "countrycode1"); // phpcs:ignore WordPress.Security.EscapeOutput
    4242                            }
    4343                            else { echo dialbunny_country_code("none", "countrycode1"); } // phpcs:ignore WordPress.Security.EscapeOutput  ?>
    4444                          </div>
    4545                          <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]); } ?>" />
    4747                          </div>
    4848                          <?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) {
    5050                            echo '
    5151                                                        <div class="fv-row mt-6">
     
    7373                          <div class="col-lg-4 fv-row">
    7474                            <?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))
    7777                            {
    7878                              // Escaped inside the dialbunny_country_code() function
    79                               echo dialbunny_country_code($mainNumber2[0], "countrycode2"); // phpcs:ignore WordPress.Security.EscapeOutput
     79                              echo dialbunny_country_code($dialbunny_mainNumber2[0], "countrycode2"); // phpcs:ignore WordPress.Security.EscapeOutput
    8080                            }
    8181                            else { echo dialbunny_country_code("none", "countrycode2"); } // phpcs:ignore WordPress.Security.EscapeOutput  ?>
    8282                          </div>
    8383                          <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]); } ?>" />
    8585                          </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) {
    8787                            echo '
    8888                                                            <div class="fv-row mt-6">
     
    110110                          <div class="col-lg-4 fv-row">
    111111                            <?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))
    114114                            {
    115115                              // Escaped inside the dialbunny_country_code() function
    116                               echo dialbunny_country_code($mainNumber3[0], "countrycode3"); // phpcs:ignore WordPress.Security.EscapeOutput
     116                              echo dialbunny_country_code($dialbunny_mainNumber3[0], "countrycode3"); // phpcs:ignore WordPress.Security.EscapeOutput
    117117                            }
    118118                            else { echo dialbunny_country_code("none", "countrycode3"); } // phpcs:ignore WordPress.Security.EscapeOutput  ?>
    119119                          </div>
    120120                          <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]); } ?>" />
    122122                          </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) {
    124124                            echo '
    125125                                                                <div class="fv-row mt-6">
     
    198198                        <div class="row mb-6">
    199199                          <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>
    201201                          </div>
    202202                        </div>
     
    229229                        <div class="row">
    230230                          <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>
    232232                          </div>
    233233                        </div>
     
    260260                        <div class="row">
    261261                          <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>
    263263                          </div>
    264264                        </div>
     
    292292          <h1 class="d-flex justify-content-center align-items-center mb-6">Call the number below</h1>
    293293          <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)); }
    296296                  else { echo 'You don\'t have a number setup yet'; }
    297297                  ?> </h3>
  • dialbunny/trunk/lib/views/dashboard/index.php

    r3396401 r3406310  
    33  <div class="container-xxl" id="content_container">
    44    <?php
    5     $table = $wpdb->prefix . 'dialbunny_phone_details';
     5    $dialbunny_table = $wpdb->prefix . 'dialbunny_phone_details';
    66    // 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.DirectDatabaseQuery
     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
    88    $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)) {
    1313      // 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.DirectDatabaseQuery
    15       $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.DirectDatabaseQuery
    16       $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.DirectDatabaseQuery
     14      $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
    1717    }
    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);
    2121    }
    2222?>
     
    3939              <div class="d-flex flex-stack">
    4040                <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>
    4242                  <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 24 Hours </span>
    4343                </div>
     
    4646              <div class="d-flex flex-stack">
    4747                <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>
    4949                  <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 7 Days </span>
    5050                </div>
     
    5353              <div class="d-flex flex-stack">
    5454                <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>
    5656                  <span class="text-gray-500 fw-semibold fs-6">Calls <br>Last 30 Days </span>
    5757                </div>
     
    8787            <h3 class="card-title">Your Number</h3>
    8888            <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>'; } ?>
    9090            </div>
    9191          </div>
     
    9393            <div class="d-flex flex-column flex-grow-1 py-2 py-lg-13 me-2">
    9494              <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)
    9696                {
    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));
    9898                }
    9999                else { echo 'You don\'t have a number setup yet'; }
     
    181181          <input type="hidden" name="action" value="dialbunny_release_managed_number_user"></input>
    182182          <?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))
    184184          {
    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>';
    188188          }
    189189          ?>
  • dialbunny/trunk/lib/views/dashboard/messages/default.php

    r3328438 r3406310  
    5151                <?php
    5252                // 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;
    5555                $search = isset($_GET['search']) ? '%' . $wpdb->esc_like(sanitize_text_field(wp_unslash($_GET['search']))) . '%' : '';
    5656                if (strlen($search) > 2) {
    5757                  // 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.DirectDatabaseQuery
     58                  $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
    5959                } else {
    6060                  // 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.DirectDatabaseQuery
     61                  $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
    6262                }
    6363                  // check to see if the user has a managed number
    6464                  if (isset($phone_details[0]->managed_number) && isset($phone_details[0]->managed_number_code))
    6565                  {
    66                     foreach ($opened_item as $item)
     66                    foreach ($dialbunny_opened_item as $dialbunny_item)
    6767                    {
    6868                      // 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; }
    7373                      // 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.DirectDatabaseQuery
    75                       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)
    7676                      {
    77                         $displayName = 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'; }
    7979                        echo '<tr>';
    8080                        echo '<td><div class="d-flex align-items-center">';
     
    8282                        echo      '<span class="symbol-label bg-secondary text-secondary fs-6 fw-bolder"></span>';
    8383                        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>'; }
    8787                        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>';
    8989                        echo '</tr>';
    9090                      }
    9191                      else
    9292                      {
    93                         $displayName = $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"; }
    102102                        echo '<tr>';
    103103                        echo '<td><div class="d-flex align-items-center">';
    104104                        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>';
    106106                        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>'; }
    110110                        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>';
    112112                        echo '</tr>';
    113113                      }
    114114                    }
    115                     if ($opened_item == null)
     115                    if ($dialbunny_opened_item == null)
    116116                    {
    117117                      echo '<tr>';
     
    140140      <div class="separator mb-6"></div>
    141141      <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">';
    145145          echo '<span class="menu-bullet">';
    146146          echo '<span class="fa fa-arrow-left"></span>';
     
    149149        }
    150150        ?>
    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">';
    155155          echo '<span class="menu-bullet">';
    156156          echo '<span class="fa fa-arrow-right"></span>';
     
    170170      {
    171171          // Foreach message
    172           foreach ($opened_item as $item)
     172          foreach ($dialbunny_opened_item as $dialbunny_item)
    173173          {
    174174            // 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; }
    179179            // 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.DirectDatabaseQuery
    181             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)
    182182            {
    183               $displayName = 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'; }
    185185              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">';
    186186              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>'; }
    189189              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>';
    191191              echo '</div></div></div>';
    192192            }
    193193            else
    194194            {
    195               $displayName = $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"; }
    204204              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>'; }
    208208              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>';
    210210              echo '</div></div></div>';
    211211            }
    212212          }
    213           if ($opened_item == null)
     213          if ($dialbunny_opened_item == null)
    214214          {
    215215            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">';
     
    227227    </div>
    228228      <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">';
    232232          echo '<span class="menu-bullet">';
    233233          echo '<span class="fa fa-arrow-left"></span>';
     
    236236        }
    237237        ?>
    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">';
    242242          echo '<span class="menu-bullet">';
    243243          echo '<span class="fa fa-arrow-right"></span>';
  • dialbunny/trunk/lib/views/dashboard/messages/messages.php

    r3328438 r3406310  
    44    <div class="container-xxl" id="content_container">
    55      <?php
    6       $details   = $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;
    1010      // 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.DirectDatabaseQuery
    12       $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;
    1616          // 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.DirectDatabaseQuery
     17          $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
    1818          // 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.DirectDatabaseQuery
     19          $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
    2020      }
    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;
    2525      // Handle pagination
    2626      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;
    2929      }
    3030      ?>
     
    5959                            <span class="fas fa-comments"></span>
    6060                          </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>
    6262                                                </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>
    6464                                            </div>
    6565                                            <div class="border border-gray-300 border-dashed rounded min-w-125px py-3 px-4 me-6 mb-3">
     
    6868                            <span class="fas fa-commenting"></span>
    6969                          </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>
    7171                                                </div>
    7272                                                <div class="fw-semibold fs-6 text-gray-400">Unread</div>
     
    9797        if (isset($_GET['phone']) && isset($_GET['countrycode']))
    9898        {
    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 ?? '';
    103103          // 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.DirectDatabaseQuery
     104          $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
    105105          // 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.DirectDatabaseQuery
    107           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'); }
    108108          else { include('default.php'); }
    109109        }
  • dialbunny/trunk/lib/views/dashboard/messages/view.php

    r3328438 r3406310  
    3030    <div class="card-body pt-5">
    3131      <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)
    3333            {
    3434              // Set messages to read
    35               $data = array();
    36               $data['reading'] = 1;
     35              $dialbunny_data = array();
     36              $dialbunny_data['reading'] = 1;
    3737              // Direct database query used below – $wpdb->prepare() is always used to prevent SQL injection.
    38               $wpdb->update($messages,$data,array('user' => wp_get_current_user()->ID,'id' => sanitize_text_field($item->id)), null, array('%d', '%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
     38              $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
    3939                            // 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'])))
    4141                            {
    4242                                // user
     
    4747                  if ($contact != null) { echo '<a class="fs-5 fw-bold text-gray-900 me-1">'.esc_html($contact[0]->name).'</a>'; }
    4848                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>';
    5050                  echo '</div>';
    5151                  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>';
    5353                  echo '</div>';
    5454                  echo '</div>';
     
    6161                                echo '<div class="d-flex align-items-center mb-2">';
    6262                                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>'; }
    6565                                else { echo '<a class="fs-5 fw-bold text-gray-900 ms-1">You</a>'; }
    6666                                echo '</div>';
    6767                                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>';
    6969                                echo '</div>';
    7070                                echo '</div>';
  • dialbunny/trunk/lib/views/dashboard/recents.php

    r3396401 r3406310  
    44  <div class="container-xxl" id="content_container">
    55    <?php
    6     $user_id = wp_get_current_user()->ID;
    76    // 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;
    1513    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;
    1816    }
    19     if (!empty($opened_details[0]->managed_number)) {
     17    if (!empty($dialbunny_opened_details[0]->managed_number)) {
    2018      // 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.DirectDatabaseQuery
     19      $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
    2220    }
    2321    ?>
     
    2725          <h3 class="card-title">Recents</h3>
    2826          <div class="card-toolbar">
    29           <?php if ($recents_page > 1)
     27          <?php if ($dialbunny_recents_page > 1)
    3028          {
    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">';
    3230                        echo '<span class="menu-bullet">';
    3331                        echo '<span class="fa fa-arrow-left"></span>';
     
    3634          }
    3735          ?>
    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)
    4038          {
    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">';
    4240                        echo '<span class="menu-bullet">';
    4341                        echo '<span class="fa fa-arrow-right"></span>';
     
    5048        <div class="card-body">
    5149          <div class="table-responsive"> <?php
    52             if (isset($opened_item) && $opened_item != null)
     50            if (isset($dialbunny_opened_item) && $dialbunny_opened_item != null)
    5351            {
    5452              echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">';
    5553              echo '<tbody>';
    56               foreach ($opened_item as $record)
     54              foreach ($dialbunny_opened_item as $dialbunny_record)
    5755              {
    58                 $table_contacts = $wpdb->prefix . 'dialbunny_contacts';
    5956                echo '<tr class="align-middle">';
    6057                // 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)
    6259                {
    6360                  // 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.DirectDatabaseQuery
    65                   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>'; }
    6865                }
    6966                else
    7067                {
    7168                  // 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.DirectDatabaseQuery
    73                   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>'; }
    7673                }
    7774                echo '</tr>';
  • dialbunny/trunk/lib/views/dashboard/released.php

    r3325864 r3406310  
    44  <div class="container-xxl" id="content_container">
    55    <?php
    6     $table = $wpdb->prefix . 'dialbunny_released_numbers';
    7     $current_user_id = wp_get_current_user()->ID;
    86    // 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.DirectDatabaseQuery
     7    $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
    108    ?>
    119<?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.")); }  ?>
     
    3028        <div class="card-body">
    3129          <div class="table-responsive"> <?php
    32             if ($opened_item != null)
     30            if ($dialbunny_opened_item != null)
    3331            {
    3432              echo '<table class="table table-hover table-rounded table-striped border border-gray-300 border-dashed gy-7 gs-7">';
     
    4240              echo '</thead>';
    4341              echo '<tbody>';
    44               foreach ($opened_item as $record)
     42              foreach ($dialbunny_opened_item as $dialbunny_record)
    4543              {
    4644                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>';
    4947                  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>';
    5149                echo '</tr>';
    5250              }
  • dialbunny/trunk/readme.txt

    r3396401 r3406310  
    33Requires at least: 6.2
    44Tested up to: 6.8
    5 Stable tag: 1.1.5
     5Stable tag: 1.1.6
    66License: GPLv2 or later
    77License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.