include("cookiejar/config.php");
include("cookiejar/functions.php");
/*
* Check if id cookie exists.
*/
if (!$$cookie_name) {
/*
* If this is the first time running this cookie script,
* check to see if the counter file exists.
*
* If the counter file does not exist...
*/
if (!file_exists($counter_file)) {
$current_user_count = 1; /* initialize user count */
/*
* Create initial counter file and write initial
* count to it.
*/
$count_fh = fopen($counter_file, "w");
fputs($count_fh, $current_user_count);
fclose($count_fh);
/*
* If the counter file doesn't exist, that means it's
* the first time this cookie script is used... so wipe
* out the cookie data file and start from an empty
* file.
*/
$cookie_fh = fopen($cookie_file, "w");
fputs($cookie_fh, "KeyID"."$delimiter"."Visited_Number"."$delimiter"."Last_Visited_Month"."$delimiter"."Last_Visited_Day"."$delimiter"."Last_Visited_Year"."$delimiter"."Last_Visited_IP"."$delimiter"."First_Name"."$delimiter"."Last_Name"."$delimiter"."Email_Address\r\n");
fclose($cookie_fh);
/*
* If the counter file exists...
*/
} else {
/*
* Get the current user counter. String buffer
* is set to be so many digits long. If a site can
* have this many digits number of visitors...
* whatever...
*/
$count_fh = fopen($counter_file, "r");
$current_user_count = fgets($count_fh, 20);
fclose($count_fh);
/*
* Increment the current counter and write it
* back to the counter file.
*/
$current_user_count++;
$count_fh = fopen($counter_file, "w");
fputs($count_fh, $current_user_count);
fclose($count_fh);
}
/* end if (!count file) */
/*
* Set cookie and write data to the cookie data file.
*/
setcookie($cookie_name, $current_user_count, $cookie_time_length);
insert_cookie("$current_user_count"."$delimiter"."2"."$delimiter".date("n")."$delimiter".date("j")."$delimiter".date("Y")."$delimiter".getenv(REMOTE_ADDR)."$delimiter"."$delimiter"."$delimiter"."\r\n");
$cookie_key_id = $current_user_count;
$number_visited = 1;
$visited_month = date("n");
$visited_day = date("j");
$visited_year = date("Y");
$visited_ip = getenv(REMOTE_ADDR);
/*
* If cookie does exist.
*/
} else {
/*
* Get cookie value first and find everything in the cookie
* data file about this cookie value.
*/
$cookie_key_id = $$cookie_name;
$cookie_fields = find_cookie($cookie_key_id);
/*
* Get the cookie fields to display.
*/
$number_visited = $cookie_fields[1];
$visited_month = $cookie_fields[2];
$visited_day = $cookie_fields[3];
$visited_year = $cookie_fields[4];
$visited_ip = $cookie_fields[5];
$c_firstname = $cookie_fields[6];
$c_lastname = $cookie_fields[7];
$c_email = $cookie_fields[8];
/*
* Update cookie fields since this is a new visit.
*/
update_cookie($cookie_key_id, 1, $cookie_fields[1] + 1);
update_cookie($cookie_key_id, 2, date("n"));
update_cookie($cookie_key_id, 3, date("j"));
update_cookie($cookie_key_id, 4, date("Y"));
update_cookie($cookie_key_id, 5, getenv(REMOTE_ADDR));
}
?>
YellowZone, Inc.
 |
| |
Here is a sample of YZID.
This code can be cut and pasted anywhere on your website
To
view the admin section of YZID please click
here
|
---------------------------------------------------------------------
| include("cookiejar/cookie_output.php"); ?> |
---------------------------------------------------------------------
|
|
|
| |
|
|
|
|