Categories
Code How To Linux PHP Web Development

PHP script to fingerprint visitors

Here is a simple script you can implement into your sites to collect and store unique fingerprint data for visitors.

For browser recognition we will use the PHP function get_browser() this requires the browscap directive to be set in the php.ini file.

If you have shared hosting you will need to reach out to your hosting provider to set the browscap.ini file location in php.ini otherwise you may do it via SSH.

For IP geolocation we will use the free API at IPinfo.

The data collected and stored:

‘name’, ‘browser’, ‘browserVer’, ‘opSystem’, ‘ref’, ‘browserAgent’, browserLang’, ‘ip’, ‘platform’, ‘javascript’, ‘city’, ‘region’, ‘country’, ‘loc’, ‘postal’, ‘timezone’, ‘timestamp’

First thing you may want to do is setup your database to store this valuable information. Below you will find the SQL used to create the table:

CREATE TABLE `swepsl_leads`.`sweepslinks` ( `name` TEXT NOT NULL , `browser` TEXT NOT NULL , `browserVer` TEXT NOT NULL , `opSystem` TEXT NOT NULL , `ref` TEXT NOT NULL , `browserAgent` TEXT NOT NULL , `browserLang` TEXT NOT NULL , `ip` TEXT NOT NULL , `platform` TEXT NOT NULL , `javascript` TEXT NOT NULL , `city` TEXT NOT NULL , `region` TEXT NOT NULL , `country` VARCHAR(2) NOT NULL , `loc` TEXT NOT NULL , `postal` TEXT NOT NULL , `timezone` TEXT NOT NULL , `timestamp` TEXT NOT NULL ) ENGINE = InnoDB;

ALTER TABLE `sweepslinks` ADD `id` INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);

We will need a database connection file so here it is:

<?php 
class DB
{
    protected $conn = null;
    public function Connect()
    {
        try {

            $dsn = "mysql:dbname=swepsl_leads; host=localhost";
            $user = "YOUR_USER";
            $password = "YOUR_PASS";

            $options  = array(PDO::ATTR_ERRMODE =>      PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            );


            $this->conn = new PDO($dsn, $user, $password, $options);
            return $this->conn;

        } catch (PDOException $e) {
            echo 'Connection error: ' . $e->getMessage();
        }
    }

    public function Close()
    {
        $this->conn = null;
    }
}
?>

And now the part you have all been waiting for the final code to collect and store the data:

<?php 
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);

include 'db.php';

function getBrowser() 
{ 
    $u_agent = $_SERVER['HTTP_USER_AGENT']; 
    $bname = 'Unknown';
    $platform = 'Unknown';
    $version= "";
 

    if (preg_match('/linux/i', $u_agent)) {
        $platform = 'linux';
    }
    elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
        $platform = 'mac';
    }
    elseif (preg_match('/windows|win32/i', $u_agent)) {
        $platform = 'windows';
    }
    

    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Internet Explorer'; 
        $ub = "MSIE"; 
    } 
    elseif(preg_match('/Firefox/i',$u_agent)) 
    { 
        $bname = 'Mozilla Firefox'; 
        $ub = "Firefox"; 
    } 
    elseif(preg_match('/Chrome/i',$u_agent)) 
    { 
        $bname = 'Google Chrome'; 
        $ub = "Chrome"; 
    } 
    elseif(preg_match('/Safari/i',$u_agent)) 
    { 
        $bname = 'Apple Safari'; 
        $ub = "Safari"; 
    } 
    elseif(preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Opera'; 
        $ub = "Opera"; 
    } 
    elseif(preg_match('/Netscape/i',$u_agent)) 
    { 
        $bname = 'Netscape'; 
        $ub = "Netscape"; 
    } 
    

    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
		//
    }
    

    $i = count($matches['browser']);
    if ($i != 1) {

        if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
            $version= $matches['version'][0];
        }
        else {
            $version= $matches['version'][1];
        }
    }
    else {
        $version= $matches['version'][0];
    }
    
    if ($version==null || $version=="") {$version="?";}
    
    return array(
        'userAgent' => $u_agent,
        'name'      => $bname,
        'version'   => $version,
        'platform'  => $platform,
        'pattern'    => $pattern
    );
} 
 
function getUserIP()
{
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];
 
    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }
 
    return $ip;
}
 
function getGeoLocation($freeApikey)
{
    $PublicIP = getUserIP();
    //echo $PublicIP;

    $json = file_get_contents("http://ipinfo.io/$PublicIP/geo" . "?token=" . $freeApikey);
    //echo $json;
    return json_decode($json, true);
}

function main(){

    $GeoLocation = getGeoLocation("YOUR_FREE_API_KEY");
    $BrowserPHP = get_browser(null, true);
    echo $BrowserPHP;
    $Browser=getBrowser(); 
    $RefInfo = Array();
    $timestamp = time();

    try{
        $ref = $_SERVER['HTTP_REFERER'];
    }catch(Exception $ex){
        $ref = "Direct";
    }

    $RefInfo['Name'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $RefInfo['Browser'] = $Browser['name'];
    $RefInfo['BrowserVer'] = $Browser['version'];
    $RefInfo['OpSystem'] = $Browser['platform'];
    $RefInfo['Ref'] = $ref;
    $RefInfo['BrowserAgent'] = $_SERVER['HTTP_USER_AGENT'];
    $RefInfo['BrowserLang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    $RefInfo['IP'] = getUserIP();
    $RefInfo['Platform'] = $BrowserPHP['platform'];
    $RefInfo['Javascript'] = $BrowserPHP['javascript'];
    $RefInfo['City'] = $GeoLocation['city'];
    $RefInfo['Region'] = $GeoLocation['region'];
    $RefInfo['Country'] = $GeoLocation['country'];
    $RefInfo['Loc'] = $GeoLocation['loc'];
    $RefInfo['Postal'] = $GeoLocation['postal'];
    $RefInfo['Timezone'] = $GeoLocation['timezone'];
    $RefInfo['Time'] = $timestamp;
    
    return $RefInfo;
}

$row = main();
//echo json_encode($data);

try{
    $db = new DB();
    $conn = $db->Connect();
    if($conn){
        $query =   "INSERT INTO sweepslinks (
                        name,
                        browser, 
                        browserVer, 
                        opSystem,
                        ref, 
                        browserAgent, 
                        browserLang, 
                        ip, 
                        platform, 
                        javascript,  
                        city, 
                        region, 
                        country, 
                        loc, 
                        postal,
                        timezone, 
                        timestamp) 
                    VALUES (
                        '".$row["Name"]."',
                        '".$row["Browser"]."',
                        '".$row["BrowserVer"]."',
                        '".$row["OpSystem"]."',
                        '".$row["Ref"]."',
                        '".$row["BrowserAgent"]."',
                        '".$row["BrowserLang"]."',
                        '".$row["IP"]."',
                        '".$row["Platform"]."',
                        '".$row["Javascript"]."',
                        '".$row["City"]."',
                        '".$row["Region"]."',
                        '".$row["Country"]."',
                        '".$row["Loc"]."',
                        '".$row["Postal"]."',
                        '".$row["Timezone"]."',
                        '".$row["Time"]."'
                    )";
        $conn->query($query);
    }
    else{
        //log connection error / report
        //echo $conn;
    }
}
catch(PDOException $ex){
    echo $ex->getMessage();
}

?>

The above code is self explanatory please edit and utilize in your own projects, I use the above code on my sweepstakes and push ad traffic campaigns.

Everything here may also be found on github: code repo

Categories
ASX Bitcoin Crypto Decentraland Ethereum Financial How To Stock Market Tools Trading

Social Edge Trading

Forget about the fundamentals and the technical analysis the new way to beat the market is with using social edge trading. This is when the trader gains a edge on the market threw simply analyzing social chatter and search characteristics then compares them to known bench marks and opens a trade position.

“What does this mean” I hear you ask, well put simply you monitor social networks for the latest trend/craze analyses the sentiment and then invest in a stock that is part of that craze/trends Industry.

Social Sentiment Analysis
Social Sentiment Analysis , is the crowd happy sad or angry about this news?

Let me give you some example to help you understand:

The Tiktok home made slime craze
A long trade in the company that produces “Elmore” glue would of seen amazing profits !

Covid immunization
Any bull position in travel and tourism, airline’s, cruise ships have and will still more see amazing gains.

TikTok makeup craze
Take a look at the ticker ELF notice when the TikTok craze started it shot threw the roof ? That is no coincidence.

ELF ticker
ELF ticker, shot threw the moon during the TikTok makeup craze

Tools

Below is a list of tools and sites I use to trade this strategy so far it has been very good. Please leave a comment with any tools I missed and I will add them to this list.

The god father of social edge trading the one and only *drumroll* Mr Chris Camillo from, dumb money.
Categories
Crypto Decentraland How To

Register Decentraland name on blockchain! (and profit)

At the time of writing this will cost about 10$ in transaction fee’s and you can profit over $100 if done correctly.

Decentraland has come a long way last time I was invested in MANA and LAND packages they barley had a working prototype of the level editor online, now its a full blown world and let me tell you its bloody amazing !!

You can do anything, make anything, be anything but this post is not about how dam awesome Decentraland is, this post is about how you can cash in once more by registering a name (avatar) then selling the token on a marketplace like opensea.io.

Of course all the good names are taken and they are already being sold for hundreds some thousands of dollars on the marketplaces, but if you use your imagination you will still find some real gems.

Decentraland custom name

Before we head on over to avatars.decentraland.org lets take a look at something I found interesting while researching a valuable name and this is the DOA (decentralized autonomous organization) behind Decentraland and some of the proposals put up for vote, yep you guessed it people are trying to ban such great names like “NiggerLover“, “Faggot” and “Coon“, needless to say the smart people holding the DOA tokens all voted NO! (imagine what kind of self righteous asshole would even propose name bans….. ).

What kind of self righteous asshole would even propose name bans

Now we know what names are valuable lets go get one, head over to avatars.decentraland.org and of course all the good names will be taken, but keep trying until you find something nice pay your 15$ or whatnot in transaction fees and bobs your uncle, done !

Now head over to your favorite market place and profit….
If anyone wants to purchase the name “gook” from me, it is for sale💰

Decentraland names for sale.
Categories
How To Linux Server

🐳 How to install docker on any Ubuntu ….

…lets talk about a different kind of docking, If you spend any time at all around developing software or on Linux systems you will inevitably need to install docker (a real life saver indeed), thanks to Ubuntu installing is a breeze.

This was tested on Ubuntu 18.04 but will work on all versions due to the nerdy magic use of ✨$(lsb_release -cs)✨ !

Lets start with a quick update:
sudo apt update
sudo apt upgrade

Now we can get the system ready by installing the required packages:
sudo apt-get install curl apt-transport-https ca-certificates software-properties-common

Now that we are all ready we can add the Docker repositories, start by adding the GPG key, like so:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Now time to add the actual repository and do a final update (I know your attention span is short we are almost done…):
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update

Finally hey! Now we can Install with the following command !!
sudo apt install docker-ce

And to check all is ok….
sudo systemctl status docker

Congratulations Now all is ok .
But one final task to insure it works as intended (without sudo) and that is add your current user to the docker user group otherwise you will get errors like “Permission Denied when not sudo docker“, to fix this run the commands:
sudo group add docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

A container based software distribution utility
A container based software distribution utility

🐋 🐳Do not look up docking on urban dictionary….🐳 🐋

Categories
How To Tools

How to add a new site in Google Analytics

Yep google love to make things hard it seems, and luckily we are not alone on this one many people in discord chat and all over the interwebz are complaining that they can not work out how to add a new website to google analytics and if you are like us you would be doing this many times over and over, here this remains for future prosperity.

From random email:

I am not stupid, all google applications are easy to use but I can not for the life of me work out how to add a new website to google analytics, please help me !

Random email to a marketing SEO Guru from The Youtubes!


Discord Kid:
How do I add a new website in Google Analytics.

No random email guy and discord kid you are not stupid, lets show you how so you can do it next time like a big boy!

Simply, Head on over to analytics.google.com, login then click on the admin button on your dashboard to the bottom left:

Add a website to google analytics

Now once the page loads, click that mouse on “Create Account” and you are away!

Add a website to google analytics

Fill out a couple of questions and then go ahead and agree to those pesky terms of service, once finished hit done and you will be ready to go.

Now you can import into your favorite word press google analytics add-on or use the scripts in your site as you would normally.

How to add a new website to google analytics