i'm trying to write function that told you the visitor came from which platform

Viewed 23

Hi i'm trying to write the function I write one that work but the problem some platforms don't have

$_SERVER['HTTP_REFERER'] link snapchat

this is the function

function Contains($str, array $allsocial)
    {
        foreach ($allsocial as $item) {
            if (strstr($str, $item)) {
                echo preg_replace("#^[^:/.]*[:/]+#i", "", $str);
            } else {
                echo "Special char not found.";
            }
        }
    }
    function RefeerVisit($ID)
    {
        if (isset($_SERVER['HTTP_REFERER'])) {
            $allsocail = array("titok", "instagram", "twitter", "snapchat");
            $Refeer = $_SERVER['HTTP_REFERER'];

            Contains($Refeer, $allsocail);
        } else {
            echo 'Direct';
        }
    }
    if (isset($_REQUEST['q'])) {
        RefeerVisit(1);
    }

it work on Instagram twitter

0 Answers
Related