Skip to content

Instantly share code, notes, and snippets.

@ariews
Created March 13, 2013 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariews/5153255 to your computer and use it in GitHub Desktop.
Save ariews/5153255 to your computer and use it in GitHub Desktop.
<?php
function MyCounter () {
global $HTTP_COOKIE_VARS;
if (!is_file($this->DataFile)) {
$o = array ("1");
$this->insert($this->DataFile, $o);
}
if (!isset($HTTP_COOKIE_VARS['counter'])) {
if (!session_is_registered("counter")) {
session_register("counter", "webcount");
@setcookie("counter","webcount",time()+300);
$counter = $this->select($this->DataFile, 1);
$counter[1]++;
$this->update($this->DataFile, 1, $counter);
}
} else {
if (!session_is_registered("counter")) {
session_register("counter",
$HTTP_COOKIE_VARS['counter']);
$counter = $this->select($this->DataFile, 1);
$counter[1]++;
$this->update($this->DataFile, 1, $counter);
}
}
$counter = $this->select($this->DataFile, 1);
return $counter[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment