Exemple #1
0
 public static function Create($Key = 0, $Company = false)
 {
     $Return = false;
     if ($Key !== 0) {
         if (\Session::exists("refKey")) {
             if (\Session::get("refKey") != $Key) {
                 //This computer has multiple Keys? I'm not sure how or why this would happen.
                 //It is a possibility so I guess I should probably plan for it
                 $SavedKey = new Key(\Session::get("refKey"));
                 if ($SavedKey->validKey()) {
                     //Has two valid keys? What on earth? I will have to account for this later
                 } else {
                     \Session::put("refKey", $Key);
                     $Return = true;
                 }
             }
         } else {
             \Session::put("refKey", $Key);
             $Return = true;
         }
         if (\Cookie::exists("refKey")) {
             if (\Cookie::get("refKey") != $Key) {
                 $SavedKey = new Key(\Cookie::get("refKey"));
                 if ($SavedKey->validKey()) {
                     //Has two valid keys? What on earth? I will have to account for this later
                 } else {
                     \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
                     $Return = true;
                 }
             }
         } else {
             \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
             $Return = true;
         }
         if ($Company != false) {
             if (count(\DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->where("Company", $Company->ID())) == 0) {
                 \DB::getInstance()->table("companyip")->insert(array("IP" => \Connection::IP(), "Company" => $Company->ID(), "LastScene" => \Time::get(), "Hits" => 1));
             } else {
                 \DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->increment("Hits");
             }
         }
         //IP Based Search will go here
         return $Return;
     }
     return false;
 }
Exemple #2
0
 public function __construct()
 {
     $this->IP = \Connection::IP();
     //Allows for spoofing IP
     $refKey = $this->getKey();
     if ($refKey != false) {
         $Key = new Key($refKey);
         if ($Key->validKey($refKey)) {
             $Company = $this->getCompany($Key);
             Tracker::Create($refKey, $Company);
             $this->Valid = true;
         } else {
             Tracker::Clear();
             throw new \Exception("Key is Invalid");
         }
     } else {
         throw new \Exception("No Key");
     }
 }