class privacy { /* [+++++ PRIVACY OPTIONS ++++++] * * Options and Their Numerical Place in the Binary Stream * Limits and Effect on MySQL * BIGINT (MySQL Datatype) Allows for 64 Options * INT (MySQL DataType) Allows 32 Options */ private static $options = array( 1 => array('cn','profile'), 2 => array('cn','profile'), 4 => array('cn','blog'), 8 => array('cn','portfolio'), 16 => array('cn','friends'), 32 => array('friends','profile'), 64 => array('friends','blog'), 128 => array('friends','portfolio'), 256 => array('friends','friends'), 512 => array('members','profile'), 1024 => array('members','blog'), 2048 => array('members','portfolio'), 4096 => array('members','friends'), 8192 => array('guests','profile'), 16384 => array('guests','blog'), 32768 => array('guests','portfolio'), 65536 => array('guests','friends') ); /* int serialize * * Checks array of keys for whether an option is on or off and create a numerical INT value for them. * * array $input */ function serialize($input) { $sum = 0; while (list($key,$val) = each(self::$options)) { echo 1; if($input[$val[0]][$val[1]] == '1') { $sum += $key; } } return $sum; } /* array unserialize * * Outputs an associative array of options on or off depending on an int * * int $int */ function unserialize($int) { $total = intval($int); while (list($key,$val) = each(self::$options)) { if($key <= $total) { $output[$val[0]][$val[1]] = 1; $total = ($total - $key); } } return $output; } }