Beispiel #1
0
 Include
 v0.36b
 
 Created: 	04.03.04
 Updated:	04.11.16
 
 By:		Shaun Inman
 			http://www.shauninman.com/
 ******************************************************************************
 This page should be included in all pages that you would like to track activity
 on, from homepages to secret gardens. It will record information like referrer,
 ip address, the resource being accessed as well as browser and platform.
 ******************************************************************************/
include_once "configuration.php";
include_once "functions.php";
if ($shortstat) {
    SI_pconnect();
    $ip = $_SERVER['REMOTE_ADDR'];
    $cntry = SI_determineCountry($ip);
    $lang = SI_determineLanguage();
    $ref = $_SERVER['HTTP_REFERER'];
    $url = parse_url($ref);
    $domain = eregi_replace("^www.", "", $url['host']);
    $res = $_SERVER['REQUEST_URI'];
    $ua = $_SERVER['HTTP_USER_AGENT'];
    $br = SI_parseUserAgent($ua);
    $dt = time();
    SI_sniffKeywords($url);
    $query = "INSERT INTO {$SI_tables['stats']} (remote_ip,country,language,domain,referer,resource,user_agent,platform,browser,version,dt) \n\t\t\t  VALUES ('{$ip}','{$cntry}','{$lang}','{$domain}','{$ref}','{$res}','{$ua}','{$br['platform']}','{$br['browser']}','{$br['version']}',{$dt})";
    @mysql_query($query);
}
Beispiel #2
0
                for ($line = 0; $line < count($file); $line++) {
                    list($ipfrom, $ipto, $countrycode2, $countrycode3, $country) = explode(',', addslashes(eregi_replace('"', '', trim($file[$line]))));
                    $query = "INSERT INTO {$SI_tables['countries']}\n\t\t\t\t\t\t\t  (ip_from,ip_to,country_code2,country_code3,country_name) VALUES\n\t\t\t\t\t\t\t  ({$ipfrom},{$ipto},'{$countrycode2}','{$countrycode3}','{$country}')";
                    mysql_query($query);
                }
                echo "<p>Country data load complete.</p>";
                echo "<p>IP-to-Country plug-in was installed successfully.</p>\n\t\t\t\t\t  <p>This file and \"_ip-to-country.txt\" should be removed from your \n\t\t\t\t\t  server UNLESS you have been running a previous or current version of ShortStat prior to installation\n\t\t\t\t\t  of this plug-in and would like to map existing IPs to the appropriate country.</p>\n\t\t\t\t\t  <p>NOTE: This process took more than an hour to complete on an existing ShortStat database of 50k+ hits so it's best to open the\n\t\t\t\t\t  link below in a browser that won't timeout on the script. If your browser does time out, don't fret. Just reload the\n\t\t\t\t\t  page and the script should pick up where it left off.</p>\n\t\t\t\t\t  <p><a href=\"{$PHP_SELF}?match_existing=true\">Proceed.</a></p>";
            } else {
                echo "<p>Could not access _ip-to-country.txt. Please make sure that it has been uploaded into the /shortstat/ directory.</p>";
            }
        } else {
            echo "<p>The IP-to-Country table could not be created.</p>";
        }
    }
} else {
    if (@mysql_query("SELECT * FROM {$SI_tables['countries']}")) {
        echo "<p>Mapping existing IPs to countries.</p>";
        // Match existing ips to countries
        $query = "SELECT id,remote_ip FROM {$SI_tables['stats']} WHERE country=''";
        if ($result = mysql_query($query)) {
            while ($r = mysql_fetch_array($result)) {
                $country = SI_determineCountry($r['remote_ip']);
                $query = "UPDATE {$SI_tables['stats']} SET country='{$country}' WHERE id={$r['id']}";
                mysql_query($query);
            }
        }
        echo "<p>Existing IPs mapped to appropriate country. This file and \"_ip-to-country.txt\" should be removed from your server.</p>";
    } else {
        echo "<p>The IP-to-Country table does not exist. <a href=\"{$PHP_SELF}\">Install the IP-to-Country plug-in.</a></p>";
    }
}