Beispiel #1
0
 function listCustomers()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $osC_Currencies = new osC_Currencies_Admin();
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qcustomers = $osC_Database->query('select c.customers_id, c.customers_credits, c.customers_gender, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_status, c.customers_ip_address, c.date_account_created, c.number_of_logons, c.date_last_logon, cgd.customers_groups_name from :table_customers c left join :table_customers_groups_description cgd on (c.customers_groups_id = cgd.customers_groups_id and cgd.language_id = :language_id)');
     $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
     $Qcustomers->bindTable(':table_customers_groups_description', TABLE_CUSTOMERS_GROUPS_DESCRIPTION);
     $Qcustomers->bindInt(':language_id', $osC_Language->getID());
     if (isset($_REQUEST['search']) && !empty($_REQUEST['search'])) {
         $Qcustomers->appendQuery('where c.customers_lastname like :customers_lastname or c.customers_firstname like :customers_firstname and c.customers_email_address like :customers_email_address');
         $Qcustomers->bindValue(':customers_lastname', '%' . $_REQUEST['search'] . '%');
         $Qcustomers->bindValue(':customers_firstname', '%' . $_REQUEST['search'] . '%');
         $Qcustomers->bindValue(':customers_email_address', '%' . $_REQUEST['search'] . '%');
     }
     $Qcustomers->appendQuery('order by c.customers_lastname, c.customers_firstname');
     $Qcustomers->setExtBatchLimit($start, $limit);
     $Qcustomers->execute();
     require_once 'includes/classes/geoip.php';
     $osC_GeoIP = osC_GeoIP_Admin::load();
     if ($osC_GeoIP->isInstalled()) {
         $osC_GeoIP->activate();
     }
     $records = array();
     while ($Qcustomers->next()) {
         $geoip = '';
         $iso_code_2 = $osC_GeoIP->getCountryISOCode2($Qcustomers->value('customers_ip_address'));
         if ($osC_GeoIP->isActive() && $osC_GeoIP->isValid($Qcustomers->value('customers_ip_address')) && !empty($iso_code_2)) {
             $geoip = osc_image('../images/worldflags/' . $iso_code_2 . '.png', $country . ', ' . $Qcustomers->value('customers_ip_address'), 18, 12) . ' ' . $Qcustomers->value('customers_ip_address');
         } else {
             $geoip = $Qcustomers->value('customers_ip_address');
         }
         $customers_info = '<table width="100%" cellspacing="5">' . '<tbody>' . '<tr>
             <td width="150">' . $osC_Language->get('field_gender') . '</td>
             <td>' . ($Qcustomers->value('customers_gender') == 'm' ? $osC_Language->get('gender_male') : $osC_Language->get('gender_female')) . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_email_address') . '</td>
             <td>' . $Qcustomers->value('customers_email_address') . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_customers_group') . '</td>
             <td>' . $Qcustomers->value('customers_groups_name') . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_ip_address') . '</td>
             <td>' . $geoip . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_number_of_logons') . '</td>
             <td>' . $Qcustomers->valueInt('number_of_logons') . '</td>
           </tr>' . '<tr>
             <td>' . $osC_Language->get('field_date_last_logon') . '</td>
             <td>' . osC_DateTime::getShort($Qcustomers->value('date_last_logon')) . '</td>
           </tr>' . '</tbody>' . '</table>';
         $records[] = array('customers_id' => $Qcustomers->valueInt('customers_id'), 'customers_lastname' => $Qcustomers->value('customers_lastname'), 'customers_firstname' => $Qcustomers->value('customers_firstname'), 'customers_credits' => $osC_Currencies->format($Qcustomers->value('customers_credits')), 'date_account_created' => osC_DateTime::getShort($Qcustomers->value('date_account_created')), 'customers_status' => $Qcustomers->valueInt('customers_status'), 'customers_info' => $customers_info);
     }
     $Qcustomers->freeResult();
     $response = array(EXT_JSON_READER_TOTAL => $Qcustomers->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Beispiel #2
0
/*
  $Id: $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2007 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/
$osC_Currencies = new osC_Currencies();
$osC_Tax = new osC_Tax_Admin();
$osC_Weight = new osC_Weight();
$osC_GeoIP = osC_GeoIP_Admin::load();
if ($osC_GeoIP->isInstalled()) {
    $osC_GeoIP->activate();
}
$osC_ObjectInfo = new osC_ObjectInfo(osC_WhosOnline_Admin::getData($_GET['info']));
if (STORE_SESSIONS == 'database') {
    $Qsession = $osC_Database->query('select value from :table_sessions where id = :id');
    $Qsession->bindTable(':table_sessions', TABLE_SESSIONS);
    $Qsession->bindValue(':id', $osC_ObjectInfo->get('session_id'));
    $Qsession->execute();
    $session_data = trim($Qsession->value('value'));
} else {
    if (file_exists($osC_Session->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id')) && filesize($osC_Session->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id')) > 0) {
        $session_data = trim(file_get_contents($osC_Session->getSavePath() . '/sess_' . $osC_ObjectInfo->get('session_id')));
    }
}
 function listOnlineCustomers()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     require_once 'includes/classes/currencies.php';
     $osC_Currencies = new osC_Currencies();
     require_once 'includes/classes/geoip.php';
     $osC_GeoIP = osC_GeoIP_Admin::load();
     if ($osC_GeoIP->isInstalled()) {
         $osC_GeoIP->activate();
     }
     $active_time = 300;
     $track_time = 900;
     osC_WhosOnline_Admin::removeExpiredEntries($track_time);
     $xx_mins_ago_active = time() - $active_time;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $Qwho = $osC_Database->query('select customer_id, full_name, ip_address, time_entry, time_last_click, session_id, referrer_url from :table_whos_online ');
     $Qwho->bindTable(':table_whos_online', TABLE_WHOS_ONLINE);
     if ($_REQUEST['customers_filter'] == 'customers') {
         $Qwho->appendQuery('where customer_id >= 1 ');
     } else {
         if ($_REQUEST['customers_filter'] == 'guests') {
             $Qwho->appendQuery('where customer_id = 0 ');
         } else {
             if ($_REQUEST['customers_filter'] == 'customers_guests') {
                 $Qwho->appendQuery('where customer_id >= 0 ');
             } else {
                 if ($_REQUEST['customers_filter'] == 'bots') {
                     $Qwho->appendQuery('where customer_id = -1 ');
                 }
             }
         }
     }
     $Qwho->appendQuery('order by time_last_click desc');
     $Qwho->setExtBatchLimit($start, $limit);
     $Qwho->execute();
     $record = array();
     while ($Qwho->next()) {
         $session_data = osC_WhosOnline_Admin::getSessionData($Qwho->value('session_id'));
         $navigation = unserialize(osc_get_serialized_variable($session_data, 'osC_NavigationHistory_data', 'array'));
         if (is_array($navigation)) {
             $last_page = end($navigation);
         }
         $currency = unserialize(osc_get_serialized_variable($session_data, 'currency', 'string'));
         $cart = unserialize(osc_get_serialized_variable($session_data, 'osC_ShoppingCart_data', 'array'));
         $status = '';
         if ($Qwho->value('customer_id') < 0) {
             if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                 $status = osc_icon('status_green.png', $osC_Language->get('text_status_inactive_bot'));
             } else {
                 $status = osc_icon('status_red.png', $osC_Language->get('text_status_active_bot'));
             }
         } else {
             if (is_array($cart['contents']) && sizeof($cart['contents']) > 0) {
                 if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                     $status = osc_icon('cart_red.png', $osC_Language->get('text_status_inactive_cart'));
                 } else {
                     $status = osc_icon('cart_green.png', $osC_Language->get('text_status_active_cart'));
                 }
             } else {
                 if ($Qwho->value('time_last_click') < $xx_mins_ago_active) {
                     $status = osc_icon('people_red.png', $osC_Language->get('text_status_inactive_nocart'));
                 } else {
                     $status = osc_icon('people_green.png', $osC_Language->get('text_status_active_nocart'));
                 }
             }
         }
         $geoip = '';
         $iso_code_2 = $osC_GeoIP->getCountryISOCode2($Qwho->value('ip_address'));
         if ($osC_GeoIP->isActive() && $osC_GeoIP->isValid($Qwho->value('ip_address')) && !empty($iso_code_2)) {
             $geoip = osc_image('../images/worldflags/' . $iso_code_2 . '.png', $osC_GeoIP->getCountryName($Qwho->value('ip_address')) . ', ' . $Qwho->value('ip_address'), 18, 12) . '&nbsp;' . $Qwho->value('ip_address');
         } else {
             $geoip = $Qwho->value('ip_address');
         }
         $customers_info = '<table width="100%">';
         $customers_info .= '<tr><td width="120"><b>' . $osC_Language->get('field_session_id') . '</b></td><td>' . $Qwho->value('session_id') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_customer_name') . '</b></td><td>' . $Qwho->value('full_name') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_ip_address') . '</b></td><td>' . $Qwho->value('ip_address') . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_entry_time') . '</b></td><td>' . date('H:i:s', $Qwho->value('time_entry')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_last_click') . '</b></td><td>' . date('H:i:s', $Qwho->value('time_last_click')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_time_online') . '</b></td><td>' . gmdate('H:i:s', time() - $Qwho->value('time_entry')) . '</td></tr>';
         $customers_info .= '<tr><td><b>' . $osC_Language->get('field_referrer_url') . '</b></td><td>' . $Qwho->value('referrer_url') . '</td></tr>';
         $customers_info .= '</table>';
         $products_table = '<table width="100%">';
         foreach ($cart['contents'] as $product) {
             $product_info = $product['quantity'] . '&nbsp;x&nbsp;' . $product['name'];
             if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_name') . ': ' . $product['gc_data']['senders_name'] . '</i></nobr>';
                 if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('senders_email') . ': ' . $product['gc_data']['senders_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['recipients_name'] . '</i></nobr>';
                 if ($product['gift_certificates_type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('recipients_email') . ': ' . $product['gc_data']['recipients_email'] . '</i></nobr>';
                 }
                 $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $osC_Language->get('messages') . ': ' . $product['gc_data']['message'] . '</i></nobr>';
             }
             if (isset($product['variants']) && is_array($product['variants']) && sizeof($product['variants']) > 0) {
                 foreach ($product['variants'] as $variants) {
                     $product_info .= '<br /><nobr>&nbsp;&nbsp;&nbsp;<i>' . $variants['groups_name'] . ': ' . $variants['values_name'] . '</i></nobr>';
                 }
             }
             $products_table .= '<tr><td>' . $product_info . '</td><td width="60" valign="top" align="right">' . $osC_Currencies->displayPriceWithTaxRate($product['final_price'], $product['tax'], 1, $currency) . '</td></tr>';
         }
         $products_table .= '</table>';
         $customers_name = $Qwho->value('full_name') . ' (' . $Qwho->valueInt('customer_id') . ')';
         $customers_name .= ' -- ' . ($geoip === $_SERVER['REMOTE_ADDR'] ? $osC_Language->get('text_administrator') : '');
         $record[] = array('session_id' => $Qwho->value('session_id'), 'status' => $status, 'geoip' => $geoip, 'online_time' => gmdate('H:i:s', time() - $Qwho->value('time_entry')), 'last_url' => $last_page['page'], 'custormers_name' => $customers_name, 'customers_info' => $customers_info, 'products' => $products_table, 'total' => $osC_Currencies->format($cart['total_cost'], true, $currency));
     }
     if ($osC_GeoIP->isActive()) {
         $osC_GeoIP->deactivate();
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qwho->getBatchSize(), EXT_JSON_READER_ROOT => $record);
     echo $toC_Json->encode($response);
 }