osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> Des champs vides dans Whos Online, Les champs Pays, Ville et Région sont vides
mihelicjm
posté 14 Mar 2014, 23:49
Message #1


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 53
Inscrit : 9-November 04
Lieu : Charleroi
Membre no 3721



Je viens d'installer Who's Online Enhancement 3.7.1 mais les champs Pays, Ville et Région restent vide. Quelqu'un aurait il eu et résolu la même anomalie malgré avoir bien renseigné les api suivantes:

protected $apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; de ipinfodb.classe.php

$ipinfodb->setKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); de admin/whos_online.php

... et de la map Google dans l'admin?

Pour info j'ai repéré 2 lignes à mettre à jour dans admin/whos_online.php

il faut remplacer
CODE
echo '<b>' . TABLE_HEADING_IP_ADDRESS . ':</b> ' . "<a href='http://www.ipinfodb.com/ip_locator.php?ip=$whos_online[ip_address]' target='_new'>" . $whos_online['ip_address'] . "</a>";

par
CODE
echo '<b>' . TABLE_HEADING_IP_ADDRESS . ':</b> ' . "<a href='http://api.ipinfodb.com/v3/ip-city/?key=VOTRE_CLE&ip=$whos_online[ip_address]' target='_new'>" . $whos_online['ip_address'] . "</a>";

et un peu plus bas remplacer
CODE
echo '<a href="http://www.ipinfodb.com/ip_locator.php?ip=' . $whos_online['ip_address'] . '" target="_blank">';

par
CODE
echo '<a href="http://api.ipinfodb.com/v3/ip-city/?key=VOTRE_CLE&ip=' . $whos_online['ip_address'] . '" target="_blank">';




--------------------
OsCommerce Bootstrap 2.3.4 visible ici >> Account_Balance_V4 >> Admin Notes with french v2.4_1 >> cronemul >> Extra Info to customer page in admin V1 >> extra_fields_v2_1 >> extra_images_v1-61 >> heardabout_1_25 >> mail-manager >> Menu deroulant date naissance Mini_Images_v2.0 >> Minimum_Order_Amount_1_4 >> Master Password 1_4 >> ordercheck >> Product Serial 1_0 >> PDF_Customer_Invoice_v1.0 >> points_rewardsV2.2beta >> RecoverCartSales 230 >> RMA_Returns_2-6 >> Suivi_colissimo >>
Go to the top of the page
 
mihelicjm
posté 31 Mar 2014, 13:24
Message #2


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 53
Inscrit : 9-November 04
Lieu : Charleroi
Membre no 3721



Pour celui comme moi qui déprime de voir ces trois champs vides... smile.gif

pour bien afficher les drapeaux + les commentaires du survol de la souris:
prendre les fichiers Geoip.inc & GeoIP.dat et les placer dans admin/includes

1/ dans admin/whos_online.php faire les modifs:
après require('includes/application_top.php'); ajouter
CODE
require(DIR_WS_INCLUDES . 'geoip.inc');
$gi = geoip_open(DIR_WS_INCLUDES . 'GeoIP.dat',GEOIP_STANDARD);

pour un meilleur résultat j'ai placé le geoip.inc fourni dans la contrib Visitor Web Stats 3.2...
après <?php $isp_icon = get_isp_icon($hostname); ?>
CODE
<?php if (file_exists(DIR_WS_IMAGES . 'flags/' . strtolower(geoip_country_code_by_addr($gi, $whos_online['ip_address'])) . strtolower(geoip_country_name_by_addr($gi, $whos_online['ip_address'])) . '.png')){
$flag_img = '<img src="' . DIR_WS_IMAGES . 'flags/' . strtolower(geoip_country_code_by_addr($gi, $whos_online['ip_address'])) . strtolower(geoip_country_name_by_addr($gi, $whos_online['ip_address'])) . '.png" border=0 />'; ?>
<td class="dataTableContent" valign="top">
<?php
if ( $is_admin ) {
} elseif ( $hostname == 'unknown' ) {
echo '<span title="header=[Info] body=[<b> ' . TEXT_COUNTRY . ':</b> ' . stripslashes($whos_online['country_name']) . '<br><b>' . TEXT_REGION . ':</b> ' . stripslashes($whos_online['country_region']) . ' <br><b> ' . TEXT_CITY . ':</b> ' . stripslashes($whos_online['country_city']) . '<br><b>' . TEXT_USER_AGENT . ':</b> ' . stripslashes($whos_online['user_agent']). ']">' . $flag_img . '</span>' . '&nbsp;';
} else {
echo '<span title="header=[Info] body=[<b> ' . TEXT_COUNTRY . ':</b> ' . stripslashes($whos_online['country_name']) . '<br><b>' . TEXT_REGION . ':</b> ' . stripslashes($whos_online['country_region']) . ' <br><b> ' . TEXT_CITY . ':</b> ' . stripslashes($whos_online['country_city']) . '<br><b>' . TEXT_USER_AGENT . ':</b> ' . stripslashes($whos_online['user_agent']). ']">' . $flag_img . '</span>' . '&nbsp;'; } ?>

2/ télécharger les fichiers geoipcity.inc & GeoLiteCity.dat et les placer dans catalog/includes
3/ transférer dans includes/functions/general.php les fonctions originales inscrites d'origines dans includes/functions/whos_online.php. Dans includes/functions/general.php ajouter avant la dernière balise ?>:
CODE
function tep_update_whos_online() {
// WOL 1.6 - Need access to spider_flag and user_agent and moved some assignments up here from below
global $customer_id, $spider_flag, $user_agent;

$wo_ip_address = tep_get_ip_address();
$wo_last_page_url = request_uri();

$current_time = time();
$xx_mins_ago = ($current_time - 900);
$wo_session_id = tep_session_id();
$user_agent = getenv("HTTP_USER_AGENT");
$wo_user_agent = $user_agent;

// WOL 1.6 EOF



if ( $customer_id > 0 ) {
//if (tep_session_is_registered('customer_id')) {
//$wo_session_id = tep_session_id();
$wo_customer_id = $customer_id;

$customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$customer = tep_db_fetch_array($customer_query);

$wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
} else {
if (( $spider_flag ) or (strpos ($user_agent, "Googlebot") > 0 )){
// Bots are customerID = -1
$wo_customer_id = -1;
// The Bots name is extracted from the User Agent in the WOE Admin screen
$wo_full_name = $user_agent;
// Session IDs are the WOE primary key. If a Bot doesn't have a session (normally shouldn't),
// use the IP Address as unique identifier, otherwise, use the session ID
if ( $wo_session_id == "" )
$wo_session_id = $wo_ip_address;
} else {
// Must be a Guest
$wo_full_name = 'Guest';
$wo_customer_id = 0;
}
// WOL 1.6 EOF
}



// remove entries that have expired
tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

$stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
$stored_customer = tep_db_fetch_array($stored_customer_query);

if ($stored_customer['count'] > 0) {
$wo_ip_query = tep_db_query("select ip_address, hostname from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
$wo_ip = tep_db_fetch_array($wo_ip_query);

if ($wo_ip['ip_address'] <> $wo_ip_address) {
$wo_hostname = wo_get_host_from_addr($wo_ip_address);
} else {
$wo_hostname = $wo_ip['hostname'];
}

tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int)$wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', hostname = '" . tep_db_input($wo_hostname) . "', latitude = '" . tep_db_input($lat) . "', longitude = '" . tep_db_input($long) . "', country_code = '" . tep_db_input($country_code) . "', country_name = '" . tep_db_input($country_name) . "', country_region = '" . tep_db_input($region_name) . "', country_city = '" . tep_db_input($city_name) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'");
} else {

$wo_hostname = wo_get_host_from_addr($wo_ip_address);
tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, hostname, latitude, longitude, time_entry, time_last_click, last_page_url, http_referer, user_agent) values ('" . (int)$wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($wo_hostname) . "', '" . tep_db_input($lat) . "', '" . tep_db_input($long) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "', '" . tep_db_input($_SERVER['HTTP_REFERER']) . "', '" . tep_db_input($user_agent) . "')");

}
}
function request_uri() {

if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];

}
else {
if (isset($_SERVER['argv'])) {
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
}
else {
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
}

//return check_url($uri);
return $uri;
}

function wo_get_host_from_addr($ip_address) {
//Get hostname from IP address
if (strstr($ip_address, ',')) {
//if multiple responses, use first one
$ips = explode(',', $ip_address);
$ip_address = $ips[0];
}
if ($ip_address == 'unknown') {
$hostname = $ip_address;
} else {
$hostname = gethostbyaddr($ip_address);
}
return $hostname;

}

4/ dans includes/application_top.php remplacer
CODE
// include the who's online functions
require(DIR_WS_FUNCTIONS . 'whos_online.php');
tep_update_whos_online();

par
CODE
// include the who's online classes
require(DIR_WS_CLASSES . 'whos_online.php');
tep_update_whos_online();
$tracker = new whos_online;
$tracker->update();

... suite à quoi il faut donc créer le fichier whos_online.php ci-dessous à placer dans catalog/includes/classes:
CODE
<?php
/*
$Id: whos_online.php,v3.1 2005/10/22

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

Copyright © 2003 osCommerce

Released under the GNU General Public License
*/

class whos_online {
function whos_online(){

}

function update() {
global $cart, $HTTP_GET_VARS, $customer_id;
//// **** CONFIGURATION SECTION **** ////

//Comma Separate List of IPs which should not be recorded, for instance, your own PCs IP address, or
//that of your server if you are using Cron Jobs, etc
$excluded_ips = '207.255.221.160';

//// **** CONFIGURATION SECTION EOF **** ////
$record_session = true;
$ip_address = $_SERVER['REMOTE_ADDR'];

if ($excluded_ips != '') {
$ex_array = explode(',',$excluded_ips);
foreach ($ex_array as $key => $ex_ip) {
if ($ip_address == $ex_ip) $record_session = false;
}
}

/* EXCLUDE BOTS BEGIN
$agent = $_SERVER['HTTP_USER_AGENT'];
$bot_here = false;
$arr = array("msnbot", "googlebot", "slurp", "abot", "dbot", "ebot", "hbot", "kbot", "mbot", "nbot", "obot", "pbot", "rbot", "sbot", "tbot", "ybot", "bot.", "crawl", "slurp", "spider", "accoona", "acoon", "ah-ha.com", "ahoy", "altavista", "ananzi", "anthill", "appie", "arachnophilia", "arale", "araneo", "aranha", "architext", "aretha", "arks", "aspseek", "asterias", "atlocal", "atn", "atomz", "augurfind", "backrub", "bannana_bot", "big brother", "bjaaland", "blackwidow", "bloodhound", "boitho", "booch", "bradley", "calif", "cassandra", "ccubee", "cfetch", "churl", "cienciaficcion", "cmc", "collective", "combine system", "computingsite", "cusco", "deepindex", "deweb", "die blinde kuh", "digger", "dmoz", "docomo", "download express", "dwcp", "ebiness", "e-collector", "ejupiter", "emacs-w3 search engine", "esther", "evliya celebi", "ezresult", "falcon", "felix ide", "ferret", "fetchrover", "fido", "findlinks", "fireball", "fish search", "fouineur", "funnelweb", "gazz", "gcreep", "getterroboplus", "geturl", "glx", "goforit", "golem", "grabber", "grapnel", "griffon", "gromit", "grub", "gulliver", "hamahakki", "harvest", "havindex", "helix", "heritrix", "hku www octopus", "homerweb", "htdig", "html index", "html_analyzer", "htmlgobble", "hubater", "hyper-decontextualizer", "ia_archiver", "ibm_planetwide", "ichiro", "iconsurf", "iltrovatore", "image.kapsi.net", "imagelock", "incywincy", "indexer", "infobee", "informant", "infoseek", "ingrid", "inktomisearch.com", "inspector web", "intelliagent", "internet shinchakubin", "ip3000", "iron33", "israeli-search", "ivia", "jack", "jakarta", "java/", "javabee", "jetbot", "jumpstation", "katipo", "kdd-explorer", "kilroy", "knowledge", "kototoi", "labelgrabber", "lachesis", "larbin", "legs", "libwww", "linkalarm", "link validator", "linkscan", "linkwalker", "lockon", "lwp", "lycos", "magpie", "mantraagent", "marvin/", "mattie", "mediafox", "mediapartners", "mercator", "merzscope", "miva", "mj12", "mnogosearch", "moget", "monster", "moose", "motor", "multitext", "muncher", "muscatferret", "mwd.search", "myweb", "nameprotect", "nationaldirectory", "nazilla", "ncsa beta", "nec-meshexplorer", "nederland.zoek", "netcarta webmap engine", "netmechanic", "netresearchserver", "netscoop", "newscan-online", "ng/", "nhse", "nomad", "nutch", "nzexplorer", "objectssearch", "occam", "omni", "open text", "openfind", "orb search", "osis-project", "pack rat", "pageboy", "parasite", "partnersite", "patric", "pear.", "pegasus", "peregrinator", "pgp key agent", "phantom", "phpdig", "picosearch", "piltdownman", "pimptrain", "pinpoint", "pioneer", "piranha", "plumtreewebaccessor", "pompos", "poppelsdorf", "poppi", "popular iconoclast", "rambler", "raven search", "roach", "road runner", "roadhouse", "robbie", "robofox", "robozilla", "rules", "salty", "sbider", "scooter", "scrubby", "search.", "searchprocess", "seeker", "semanticdiscovery", "senrigan", "sg-scout", "shai'hulud", "shark", "shopwiki", "sidewinder", "sift", "simmany", "site searcher", "site valet", "sitetech-rover", "skymob.com", "sleek", "smartwit", "sna-", "snooper", "sohu", "speedfind", "spinner", "spyder", "steeler/", "suke", "suntek", "supersnooper", "surfnomore", "sven", "sygol", "szukacz", "tach black widow", "tarantula", "templeton", "/teoma", "t-h-u-n-d-e-r-s-t-o-n-e", "titan", "titin", "tkwww", "toutatis", "t-rex", "tutorgig", "ucsd", "udmsearch", "ultraseek", "url check", "vagabondo", "valkyrie", "verticrawl", "victoria", "vision-search", "volcano", "voyager/", "w3c_validator", "w3m2", "w3mir", "wallpaper", "wanderer", "web core", "web hopper", "web wombat", "webbandit", "webcatcher", "webcopy", "webfoot", "weblayers", "weblinker", "weblog monitor", "webmirror", "webquest", "webreaper", "websitepulse", "websnarf", "webstolperer", "webvac", "webwalk", "webwatch", "webwombat", "webzinger", "wget", "whatuseek", "whizbang", "whowhere", "wild ferret", "wire", "worldlight", "wwwc", "xenu", "xget", "xift", "yandex", "zao/", "zippp", "zyborg");
foreach ($arr as $bot) {
if (preg_match('`'.$bot.'`i', $agent)) {
$bot_here = true;
}
}
if ($bot_here) {
$record_session = false;
}

$host_name = gethostbyaddr($ip_address);
if(preg_match("/search\.msn\.com$/", $host_name) || preg_match("/search\.live\.com$/", $host_name)){
//the hostname does belong to either search.msn.com or search.live.com.
//Remember the User Agent did not say it was a Bot.
//So it's a misbehaving spider.
$record_session = false;
}

// EXCLUDE BOTS END OF SECTION
*/
//Big If statement that stops us doing anything more if this IP is one of the
//ones we have chosen to exclude
if ($record_session) {

$existing_session = false;
$thirty_ago_timestamp = strtotime("now") - (30*60);
$thirty_mins_ago = date('Y-m-d H:i:s', $thirty_ago_timestamp);
$browser_string = addslashes(tep_db_input(urldecode($_SERVER['HTTP_USER_AGENT'])));
$ip_array = explode ('.',$ip_address);
$ip_start = $ip_array[0] . '.' . $ip_array[1];
//Find out if this user already appears in the whos_online db table

//First thing to try is customer_id, if they are signed in

if (isset($customer_id)) {
$query = "select * from whos_online where customer_id ='" . $customer_id . "' and last_click > '" . $thirty_mins_ago . "'";
$result = tep_db_query($query);
if (tep_db_num_rows ($result) > 0) {
$existing_session = true;
}
}

//Next, we try this: compare first 2 parts of the IP address (Class B), and the browser
//Identification String, which give us a good chance of locating the details for a given user. I reckon
//that the chances of having more than 1 user within a 30 minute window with identical values
//is pretty small, so hopefully this will work and should be more reliable than using Session IDs....


if (!$existing_session) {
$query = "select * from whos_online where browser_string ='" . $browser_string . "' and ip_address like '" . $ip_start . "%' and last_click > '" . $thirty_mins_ago . "'";
$result = tep_db_query($query);
if (tep_db_num_rows ($result) > 0) {
$existing_session = true;
}
}

//If that didn't work, and we have something in the cart, we can use that to try and find the
//record instead. Obviously, people with things in their cart don't just appear from nowhere!
if (!$existing_session) {
if ($cart->count_contents()>0) {
$query = "select * from whos_online where cart_total ='" . $cart->show_total() . "' and last_click > '" . $thirty_mins_ago . "'";
$result = tep_db_query($query);
if (tep_db_num_rows ($result) > 0) {
$existing_session = true;
}
}
}


//Having worked out if we have a new or existing user session lets record some details....!
if ($existing_session) {
//Existing tracked session, so just update relevant existing details
$tracking_data = tep_db_fetch_array($result);
$tracking_id = $tracking_data['tracking_id'];
$products_viewed=$tracking_data['products_viewed'];
$added_cart = $tracking_data['added_cart'];
$completed_purchase = $tracking_data['completed_purchase'];
$num_clicks = $tracking_data['num_clicks']+1;
$categories_viewed = unserialize($tracking_data['categories_viewed']);
$cart_contents = unserialize($tracking_data['cart_contents']);
$cart_total = $tracking_data['cart_total'];
$order_id = $tracking_data['order_id'];
if (isset($customer_id)) $cust_id=$customer_id;
else $cust_id=$tracking_data['customer_id'];

$current_page=addslashes(tep_db_input(urldecode($_SERVER['PHP_SELF'])));
$last_click = date('Y-m-d H:i:s');


//Find out if the customer has added something to their cart for the first time
if (($added_cart!='true') && ($cart->count_contents()>0)) $added_cart = 'true';

//Has a purchase just been completed?
if ((strstr($current_page, 'checkout_success.php'))&& ($completed_purchase!='true')) {
$completed_purchase='true';
$order_q = "select orders_id from orders where customers_id = '" . $cust_id . "' ORDER BY date_purchased DESC";
$order_result = tep_db_query($order_q);
if (tep_db_num_rows($order_result) > 0) {
$order_row = tep_db_fetch_array($order_result);
$order_id = $order_row['orders_id'];
}
}

//If customer is looking at a product, add it to the list of products viewed
if (strstr($current_page, 'product_info.php')) {
$current_product_id = (int)$HTTP_GET_VARS['products_id'];
if (!strstr($products_viewed, '*' . $current_product_id . '?')) {
//Product hasn't been previously recorded as viewed
$products_viewed .= '*' . $current_product_id . '?';
}
}

//Store away their cart contents
//But, the cart is dumped at checkout, so we don't want to overwrite the stored cart contents
//In this case
$current_cart_contents = serialize($cart->contents);
if (strlen($current_cart_contents)>6) {
$cart_contents = $current_cart_contents;
$cart_total = $cart->show_total();
}



//If we are on index.php, but looking at category results, make sure we record which category
if (strpos($current_page, 'index.php')) {
if (isset($_GET['cPath'])) {
$cat_id = $_GET['cPath'];
$cat_id_array = explode('_',$cat_id);
$cat_id = $cat_id_array[sizeof($cat_id_array)-1];
$categories_viewed[$cat_id]=1;
}
}

$categories_viewed = serialize($categories_viewed);
$query = "UPDATE whos_online set last_click='" . $last_click . "', exit_page='" . $current_page . "', num_clicks='" . $num_clicks . "', added_cart='" . $added_cart . "', categories_viewed='" . $categories_viewed . "', products_viewed='" . $products_viewed . "', customer_id='" . $cust_id . "', completed_purchase='" . $completed_purchase . "', cart_contents='" . $cart_contents . "', cart_total = '" . $cart_total . "', order_id = '" . $order_id . "' where tracking_id='" . $tracking_id . "'";
tep_db_query($query);

}
else {
//New vistor, so record referrer, etc
//Next line defines pages on which a new visitor should definitely not be recorded
$prohibited_pages = 'login.php,checkout_shipping.php,checkout_payment.php,checkout_process.php,ch
eckout_confirmation.php,checkout_success.php';
$current_page=addslashes(tep_db_input(urldecode($_SERVER['PHP_SELF'])));

if (!strpos($prohibited_pages, $current_page)) {
$refer_data = addslashes(tep_db_input(urldecode($_SERVER['HTTP_REFERER'])));
$refer_data = explode('?', $refer_data);
$referrer=$refer_data[0];
$query_string=$refer_data[1];

$ip = $_SERVER['REMOTE_ADDR'];
$browser_string = addslashes(tep_db_input(urldecode($_SERVER['HTTP_USER_AGENT'])));

function get_browser_($user_agent)
{
$browsers = array(
'Opera' => 'Opera',
'Mozilla Firefox'=> '(Firebird)|(Firefox)',
'Galeon' => 'Galeon',
'Safari'=>'Gecko',
'MyIE'=>'MyIE',
'Lynx' => 'Lynx',
'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror',
'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)',
'Internet Explorer 7' => '(MSIE 7\.[0-9]+)',
'Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)',
'Internet Explorer 4' => '(MSIE 4\.[0-9]+)',
'iPhone' => 'iPhone',

);

foreach($browsers as $browser=>$pattern)
{
if (preg_match('`'.$pattern.'`i', $userAgent))
return $browser;
}
return 'Unknown';
}
$user_agent = $_SERVER['HTTP_USER_AGENT'];

include(DIR_WS_INCLUDES . "geoipcity.inc");
// $gi = geoip_open(DIR_WS_INCLUDES . "GeoIP.dat",GEOIP_STANDARD);
$gi = geoip_open(DIR_WS_INCLUDES . "GeoLiteCity.dat",GEOIP_STANDARD);
//
$record = geoip_record_by_addr($gi,$ip);
$country_name = $record->country_name;
$country_code = strtolower($record->country_code);
$region_name = $GEOIP_REGION_NAME[$record->country_code][$record->region];
$city_name = $record->city;
// Uncomment vars you added columns for in your whos_online table
// $postcode = $record->postal_code;
$lat = $record->latitude;
$long = $record->longitude;
// $metro = $record->metro_code;
// $areacode = $record->area_code;
// -- country only vars below
// $country_name = geoip_country_name_by_addr($gi, $ip);
// $country_code = strtolower(geoip_country_code_by_addr($gi, $ip));
geoip_close($gi);
global $customer_id, $spider_flag, $user_agent;

$wo_ip_address = tep_get_ip_address();
$wo_last_page_url = request_uri();

$current_time = time();
$xx_mins_ago = ($current_time - 900);
$wo_session_id = tep_session_id();
$user_agent = getenv("HTTP_USER_AGENT");
$wo_user_agent = $user_agent;
if ( $customer_id > 0 ) {
//if (tep_session_is_registered('customer_id')) {
//$wo_session_id = tep_session_id();
$wo_customer_id = $customer_id;

$customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$customer = tep_db_fetch_array($customer_query);

$wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
} else {
if (( $spider_flag ) or (strpos ($user_agent, "Googlebot") > 0 )){
// Bots are customerID = -1
$wo_customer_id = -1;
// The Bots name is extracted from the User Agent in the WOE Admin screen
$wo_full_name = $user_agent;
// Session IDs are the WOE primary key. If a Bot doesn't have a session (normally shouldn't),
// use the IP Address as unique identifier, otherwise, use the session ID
if ( $wo_session_id == "" )
$wo_session_id = $wo_ip_address;
} else {
// Must be a Guest
$wo_full_name = 'Guest';
$wo_customer_id = 0;
}
// WOL 1.6 EOF
}
// remove entries that have expired
tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

$stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
$stored_customer = tep_db_fetch_array($stored_customer_query);

if ($stored_customer['count'] > 0) {
$wo_ip_query = tep_db_query("select ip_address, hostname from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
$wo_ip = tep_db_fetch_array($wo_ip_query);

if ($wo_ip['ip_address'] <> $wo_ip_address) {
$wo_hostname = wo_get_host_from_addr($wo_ip_address);
} else {
$wo_hostname = $wo_ip['hostname'];
}

tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int)$wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', hostname = '" . tep_db_input($wo_hostname) . "', latitude = '" . tep_db_input($lat) . "', longitude = '" . tep_db_input($long) . "', country_code = '" . tep_db_input($country_code) . "', country_name = '" . tep_db_input($country_name) . "', country_region = '" . tep_db_input($region_name) . "', country_city = '" . tep_db_input($city_name) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'");
} else {



$time_arrived = date('Y-m-d H:i:s');
$landing_page = addslashes(tep_db_input(urldecode($_SERVER['REQUEST_URI'])));
$query = "INSERT INTO `whos_online` (`ip_address`, `session_id`, `hostname`, `full_name`, `browser_string`, `country_code`, `country_name`, `latitude`, `longitude`, `country_region`, `country_city`, `referrer`,`referrer_query_string`,`landing_page`,`exit_page`,`time_arrived`,`last_click`,`browser`) VALUES ('" . $ip . "','" . $wo_session_id . "','" . $wo_hostname . "','" . $wo_full_name . "','" . $browser_string . "','" . $country_code . "', '" . $country_name . "', '" . $lat . "', '" . $long . "', '" . $region_name . "', '" . $city_name . "', '" . $referrer . "', '" . $query_string . "','" . $landing_page . "','" . $current_page . "','" . $time_arrived . "','" . $time_arrived . "','" . get_browser_($user_agent) . "')";
tep_db_query($query);
}

}//end if for prohibited pages
}//end else
}//End big If statement (Record Exclusion for certain IPs)

}//End function update
}//End Class

?>

enfin avoir une table whos_online qui ressemblerait à ça:
CODE
CREATE TABLE `whos_online` (
`tracking_id` bigint(20) NOT NULL AUTO_INCREMENT,
`ip_address` varchar(15) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`session_id` varchar(128) COLLATE latin1_general_ci NOT NULL,
`hostname` varchar(255) COLLATE latin1_general_ci NOT NULL,
`full_name` varchar(255) COLLATE latin1_general_ci NOT NULL,
`browser_string` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`browser` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`country_code` char(2) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`country_name` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`region_name` varchar(64) COLLATE latin1_general_ci NOT NULL,
`city` varchar(64) COLLATE latin1_general_ci NOT NULL,
`latitude` float NOT NULL,
`longitude` float NOT NULL,
`country_region` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`country_city` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`customer_id` int(11) NOT NULL DEFAULT '0',
`order_id` int(11) NOT NULL DEFAULT '0',
`referrer` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`referrer_query_string` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`landing_page` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`exit_page` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`time_arrived` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`time_entry` varchar(14) COLLATE latin1_general_ci NOT NULL,
`time_last_click` varchar(14) COLLATE latin1_general_ci NOT NULL,
`last_page_url` text COLLATE latin1_general_ci NOT NULL,
`last_click` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`num_clicks` int(11) NOT NULL DEFAULT '1',
`added_cart` varchar(5) COLLATE latin1_general_ci NOT NULL DEFAULT 'false',
`completed_purchase` varchar(5) COLLATE latin1_general_ci NOT NULL DEFAULT 'false',
`categories_viewed` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`products_viewed` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '',
`cart_contents` mediumtext COLLATE latin1_general_ci NOT NULL,
`cart_total` int(11) NOT NULL DEFAULT '0',
`http_referer` varchar(255) COLLATE latin1_general_ci NOT NULL,
`user_agent` varchar(255) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`tracking_id`),
KEY `ip_address` (`ip_address`),
KEY `country_code` (`country_code`)
) ENGINE=MyISAM AUTO_INCREMENT=1014 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;


Tuto élaboré à partir de 3 contributions existantes: Who's online Enhancement 3.7.1, Visitor Web Stats 3.2 et Supertracker 3.5 for OSC 2.2

bon code!! wink.gif


--------------------
OsCommerce Bootstrap 2.3.4 visible ici >> Account_Balance_V4 >> Admin Notes with french v2.4_1 >> cronemul >> Extra Info to customer page in admin V1 >> extra_fields_v2_1 >> extra_images_v1-61 >> heardabout_1_25 >> mail-manager >> Menu deroulant date naissance Mini_Images_v2.0 >> Minimum_Order_Amount_1_4 >> Master Password 1_4 >> ordercheck >> Product Serial 1_0 >> PDF_Customer_Invoice_v1.0 >> points_rewardsV2.2beta >> RecoverCartSales 230 >> RMA_Returns_2-6 >> Suivi_colissimo >>
Go to the top of the page
 
mihelicjm
posté 6 Aug 2014, 11:46
Message #3


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 53
Inscrit : 9-November 04
Lieu : Charleroi
Membre no 3721



Quelqu'un saurait il me dire les modifications à faire sous Google Maps JavaScript API v3 pour que les markers s'affichent sur la carte comme sous la version Google Maps JavaScript API v2? A priori je bûche sur la façon d'appeler le visitors_georss.php qui doit différer ...


--------------------
OsCommerce Bootstrap 2.3.4 visible ici >> Account_Balance_V4 >> Admin Notes with french v2.4_1 >> cronemul >> Extra Info to customer page in admin V1 >> extra_fields_v2_1 >> extra_images_v1-61 >> heardabout_1_25 >> mail-manager >> Menu deroulant date naissance Mini_Images_v2.0 >> Minimum_Order_Amount_1_4 >> Master Password 1_4 >> ordercheck >> Product Serial 1_0 >> PDF_Customer_Invoice_v1.0 >> points_rewardsV2.2beta >> RecoverCartSales 230 >> RMA_Returns_2-6 >> Suivi_colissimo >>
Go to the top of the page
 
mihelicjm
posté 21 Aug 2014, 13:15
Message #4


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 53
Inscrit : 9-November 04
Lieu : Charleroi
Membre no 3721



J'apporte finalement moi-même des éléments d'adaptation...

Après s'être assuré d'avoir activé l'option Google Maps JavaScript API v3 ouvrir visitors_georss.php et remplacer
CODE
while ($data = mysql_fetch_array($ip_query)){

par
CODE
while ($data = tep_db_fetch_array($ip_query)){


pour ma part ayant appliqué les modifs citées précédemment j'ai également remplacé
CODE
$region_name = $data['region_name'];
$city = iconv("UTF-8", "ISO-8859-1", $data['city']);

par
CODE
$country_region = $data['country_region'];
$postal_code = $data['postal_code'];
$country_city = iconv("UTF-8", "ISO-8859-1", $data['country_city']);

puis
CODE
$html = utf8_encode("Country : $country_name $flag $br Region : $region_name $br City : $city");

par
CODE
$html = utf8_encode("Pays : $country_name $flag $br Region : $country_region $br Code Postal : $postal_code $br Ville : $country_city");


Enfin dans le fichier admin/whos_online.php j'ai remplacé
CODE
<?php echo '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . GOOGLE_MAPS_KEY . '" type="text/javascript"></script>'; ?>
<script type="text/javascript">
var map;
var geoXml;
var toggleState = 1;

function initialize() {
if (GBrowserIsCompatible()) {
//Angel - Arreglo para que salgan las burbujas en el Mapa del Mundo
//geoXml = new GGeoXml("<?php //echo HTTP_CATALOG_SERVER . "/visitors_georss.php";?>");
geoXml = new GGeoXml("<?php echo HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "visitors_georss.php";?>");
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(36,2), 1);
map.addControl(new GLargeMapControl());
map.addControl(new GLargeMapControl());
map.addOverlay(geoXml);
}
}
</script>

par
CODE
<?php echo '<script src="http://maps.googleapis.com/maps/api/js?key=' . GOOGLE_MAPS_KEY . '&sensor=true" type="text/javascript"></script>'; ?>

<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(48.5386099,2.6615817),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

var georssLayer = new google.maps.KmlLayer({
url: 'http://MON_SITE.com/visitors_georss.php',
suppressInfoWindows: false,
map: map
});

google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showInContentWindow(text);
});

function showInContentWindow(text) {
var sidediv = document.getElementById('content-window');
sidediv.innerHTML = text;
}
}
</script>

A noter que la modif peut prendre une bonne minute avant d'être prise en compte à coup de rafraîchissements de la page!

Bon code!


--------------------
OsCommerce Bootstrap 2.3.4 visible ici >> Account_Balance_V4 >> Admin Notes with french v2.4_1 >> cronemul >> Extra Info to customer page in admin V1 >> extra_fields_v2_1 >> extra_images_v1-61 >> heardabout_1_25 >> mail-manager >> Menu deroulant date naissance Mini_Images_v2.0 >> Minimum_Order_Amount_1_4 >> Master Password 1_4 >> ordercheck >> Product Serial 1_0 >> PDF_Customer_Invoice_v1.0 >> points_rewardsV2.2beta >> RecoverCartSales 230 >> RMA_Returns_2-6 >> Suivi_colissimo >>
Go to the top of the page
 

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 28th March 2024 - 10:24
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)