public static function Create($Company = 1, $State = 1, $CustomRef = false) { $referenceKey = $CustomRef != false ? $CustomRef : \Hash::salt(6); if (count(\DB::getInstance()->table("keys")->where("key", $referenceKey)) == 0) { $key = \DB::getInstance()->table("keys")->insert(array("key" => $referenceKey, "companyID" => $Company, "state" => $State, "timeSent" => \Time::get())); return $referenceKey; } return -1; }
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; }
protected function shouldTrack() { if (Session::exists(Config::get("session/session_name"))) { //Are they logged in? $this->reason = "Authenticated"; return false; } if (Session::exists("LastVisited")) { /* We don't want to track the user every time they open a page but rather every time they open the site To achieve this we will only record the first page load every ten minutes */ //----------- Currently 1 for testing -----------// if (Time::get() - Session::get("LastVisited") < 1) { $this->reason = "Last Visit"; return false; } } return true; }
public static function Create(array $Data = array()) { $Data["timeSent"] = \Time::get(); $ID = \DB::getInstance()->table("company")->insertGetId($Data); return $ID; }
/** * Tests the setTimezone() method. * * @see \Jyxo\Time\Time::setTimezone() */ public function testSetTimeZone() { $time = Time::get(time(), 'UTC'); $this->assertNotSame('Europe/Prague', $time->getTimeZone()->getName()); $time->setTimeZone('Europe/Prague'); $this->assertSame('Europe/Prague', $time->getTimeZone()->getName()); $timeZone = new \DateTimeZone('America/Santiago'); $time->setTimeZone($timeZone); $this->assertSame('America/Santiago', $time->getTimeZone()->getName()); // Invalid timezone try { $time->setTimeZone('Foo/Bar'); $this->fail('Expected exception \\InvalidArgumentException.'); } catch (\PHPUnit_Framework_AssertionFailedError $e) { throw $e; } catch (\Exception $e) { // Correctly thrown exception $this->assertInstanceOf('\\InvalidArgumentException', $e); } }