} return; } // write to lockfile if (($al = bbc_begin_write($BBC_LOCK, "1")) !== false) { foreach (array($BBC_LOG_PROCESSOR, $BBC_LIB_PATH . "new_connect.php", $BBC_LIB_PATH . "timecalc.php", $BBC_LIB_PATH . "referrer.php", $BBC_LIB_PATH . "charconv.php") as $i) { require_once $i; } require $BBC_ACCESS_FILE; require $BBC_LAST_FILE; // global and time stats if (bbc_add_new_connections_to_old()) { $af = bbc_begin_write($BBC_ACCESS_FILE, "<?php\nglobal \$access;\n\$access =\n" . bbc_array_to_str($access) . ";\n?>"); bbc_end_write($af); !empty($BBC_DEBUG) ? print bbc_msg(basename($BBC_ACCESS_FILE), "o") : ""; bbc_update_last_access(); $af = bbc_begin_write($BBC_LAST_FILE, "<?php\nglobal \$last;\n\$last =\n" . bbc_array_to_str($last) . ";\n?>"); bbc_end_write($af); !empty($BBC_DEBUG) ? print bbc_msg(basename($BBC_LAST_FILE), "o") : ""; } } else { !empty($BBC_DEBUG) ? print bbc_msg("", "l") : ""; } // once we've finished we unlock and truncate the lock file bbc_end_write($al); fclose(fopen($BBC_LOCK, "wb")); ignore_user_abort(0); // Exit if debug mode is turned on. if (!empty($BBC_DEBUG)) { exit; }
function bbc_array_to_str(&$tab) { // This function return a string description of an array. // Format (_ == space): // |_array( // |__key1 => scal1, key2 => scal2, ... // |__key3 => // |___array( // |____key1 => scal1, ... // |___), // |__key4 => scal4, ... // |_) static $indent = ""; $oldindent = $indent; $indent .= " "; $sep = ""; $str = $indent . "array(\n"; $last_is_array = false; $k = 0; reset($tab); while (list($key, $val) = each($tab)) { // The separator treatment if ($last_is_array || is_array($val) && $k !== 0) { $str .= $sep . "\n"; } else { $str .= $sep; } // The key treatment if (preg_match(":^[0-9]+\$:", $key)) { if ($key !== $k) { $str .= (is_array($val) || $k === 0 || $last_is_array ? "{$indent} " : "") . "{$key} =>" . (is_array($val) ? "\n" : " "); } else { $str .= $k === 0 ? is_array($val) ? "" : "{$indent} " : ""; } } else { $str .= (is_array($val) || $k === 0 || $last_is_array ? "{$indent} " : "") . "\"{$key}\" =>" . (is_array($val) ? "\n" : " "); } // The value treatment $last_is_array = false; if (is_array($val)) { $str .= bbc_array_to_str($val); $last_is_array = true; $sep = ","; } else { $str .= preg_match(":^[0-9]+\$:", $val) ? $val : "\"{$val}\""; $sep = ", "; } $k++; } $str .= "\n{$indent})"; $indent = $oldindent; return $str; }