require "../../config.php"; function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); if($_GET[id]) { $sfcookie = base64_decode($_GET[id]); $snowflake_select = "SELECT sf_contents, sf_id, sf_message FROM snow_flake WHERE sf_cookie = '$sfcookie'"; $snowflake_result = mysql_query($snowflake_select, $db); list($snowflakename, $sf_id, $sf_message) = mysql_fetch_row($snowflake_result); $snowflake_update = "UPDATE snow_flake SET sf_visits = sf_visits+1 WHERE sf_id = '$sf_id'"; $snowflake_result = mysql_query($snowflake_update, $db); setcookie ("sfcookie", base64_encode($sfcookie),time()+(3600*24*365)); /* expire in 1 year */ if (!$sf_message) { $sf_message="Seasons greetings and all the best for 2003"; } } else if($_COOKIE[sfcookie]) { $sfcookie = base64_decode($_COOKIE[sfcookie]); $snowflake_select = "SELECT sf_contents, sf_id, sf_message FROM snow_flake WHERE sf_cookie = '$sfcookie'"; $snowflake_result = mysql_query($snowflake_select, $db); list($snowflakename, $sf_id, $sf_message) = mysql_fetch_row($snowflake_result); $snowflake_update = "UPDATE snow_flake SET sf_visits = sf_visits+1 WHERE sf_id = '$sf_id'"; $snowflake_result = mysql_query($snowflake_update, $db); if (!$sf_message) { $sf_message="Seasons greetings and all the best for 2003"; } } if (!$snowflakename) { $ip = $_SERVER[REMOTE_ADDR]; $datetime = date("H:i:s"); list($ip1,$ip2,$ip3,$ip4) = explode(".",$ip); list($h,$m,$s) = explode(":",$datetime); $snowflakename=($ip1 . $s . $ip3 . $m . $ip2 .$h . $ip4); $sfpin = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9); $sfcookie = crypt($sfpin . $snowflakename); $insert_statement = "INSERT INTO snow_flake (sf_contents, sf_pin, sf_visits, sf_cookie) values ('$snowflakename','$sfpin','1','$sfcookie')"; $insert_result = mysql_query($insert_statement, $db); setcookie ("sfcookie", base64_encode($sfcookie),time()+(3600*24*365)); /* expire in 1 year */ if (!$sf_message) { $sf_message="Thank you for contributing a snowflake to the collection"; } } $count_snowflakes="SELECT count(*) FROM snow_flake"; $count_result = mysql_query($count_snowflakes,$db); list($no_snow_flakes) = mysql_fetch_row($count_result); ?>