+define('DIRECT_ST_READ', 1);
+define('DIRECT_ST_WRITE', 2);
+
+declare(ticks = 1);
+
+/* this list is created with bin/get_globals.sh */
+$_globals_list = array(
+'G_admin_mail', 'G_alarm_passwd', 'G_all_points', 'G_ban_list', 'G_base',
+'G_black_list', 'G_brisk_version', 'G_btrace_pref_sub', 'G_cloud_smasher',
+'G_crypt_key', 'G_dbasetype', 'G_dbauth', 'G_dbpfx', 'G_doc_path',
+'G_proto', 'G_domain', 'G_donors_all', 'G_donors_cur', 'G_is_local', 'G_lang', 'G_lng',
+'G_mail_seed', 'G_notguar_code', 'G_PG_cons', 'G_PG_cons_n', 'G_PG_vow',
+'G_PG_vow_n', 'G_poll_entries', 'G_poll_name', 'G_poll_title',
+'G_provider_proxy', 'G_proxy_white_list', 'G_room_about', 'G_room_help',
+'G_room_passwdhowto', 'G_room_roadmap',
+'G_selfreg_mask', 'G_selfreg_tout', 'G_shutdown', 'G_profile', 'G_sidebanner',
+'G_sidebanner_idx', 'G_splash_content', 'G_splash_contents',
+'G_splash_cont_idx', 'G_splash_h', 'G_splash_idx', 'G_splash_interval',
+'G_splash_timeout', 'G_splash_w', 'G_topbanner', 'G_tos_dthard',
+'G_tos_dtsoft', 'G_tos_fname', 'G_tos_idx', 'G_tos_vers', 'G_webbase');
+
+function global_dump()
+{
+ GLOBAL $G_alarm_passwd, $G_ban_list, $G_black_list, $G_btrace_pref_sub, $G_dbauth;
+ GLOBAL $G_dbpfx, $G_donors_all, $G_donors_cur, $G_is_local, $G_lang;
+ GLOBAL $G_poll_entries, $G_poll_name, $G_poll_title, $G_proxy_white_list;
+ GLOBAL $G_room_roadmap, $G_shutdown, $G_profile;
+ GLOBAL $G_splash_content, $G_splash_contents, $G_splash_cont_idx;
+ GLOBAL $G_splash_h, $G_splash_idx, $G_splash_interval, $G_splash_timeout;
+ GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll;
+ GLOBAL $G_with_splash, $G_sidebanner, $G_sidebanner_idx;
+ GLOBAL $G_with_topbanner, $G_selfreg_tout, $G_selfreg_mask;
+
+ fprintf(STDERR, "G_alarm_passwd = [%s]\n", print_r($G_alarm_passwd, TRUE));
+ fprintf(STDERR, "G_ban_list = [%s]\n", print_r($G_ban_list, TRUE));
+ fprintf(STDERR, "G_black_list = [%s]\n", print_r($G_black_list, TRUE));
+ fprintf(STDERR, "G_btrace_pref_sub = [%s]\n", print_r($G_btrace_pref_sub, TRUE));
+ fprintf(STDERR, "G_dbauth = [%s]\n", print_r($G_dbauth, TRUE));
+ fprintf(STDERR, "G_dbpfx = [%s]\n", print_r($G_dbpfx, TRUE));
+ fprintf(STDERR, "G_donors_all = [%s]\n", print_r($G_donors_all, TRUE));
+ fprintf(STDERR, "G_donors_cur = [%s]\n", print_r($G_donors_cur, TRUE));
+ fprintf(STDERR, "G_is_local = [%s]\n", print_r($G_is_local, TRUE));
+ fprintf(STDERR, "G_lang = [%s]\n", print_r($G_lang, TRUE));
+ fprintf(STDERR, "G_poll_entries = [%s]\n", print_r($G_poll_entries, TRUE));
+ fprintf(STDERR, "G_poll_name = [%s]\n", print_r($G_poll_name, TRUE));
+ fprintf(STDERR, "G_poll_title = [%s]\n", print_r($G_poll_title, TRUE));
+ fprintf(STDERR, "G_proxy_white_list = [%s]\n", print_r($G_proxy_white_list, TRUE));
+ fprintf(STDERR, "G_room_roadmap = [%s]\n", print_r($G_room_roadmap, TRUE));
+ fprintf(STDERR, "G_shutdown = [%s]\n", print_r($G_shutdown, TRUE));
+ fprintf(STDERR, "G_profile = [%s]\n", print_r($G_profile, TRUE));
+ fprintf(STDERR, "G_splash_content = [%s]\n", print_r($G_splash_content, TRUE));
+ fprintf(STDERR, "G_splash_contents = [%s]\n", print_r($G_splash_contents, TRUE));
+ fprintf(STDERR, "G_splash_cont_idx = [%s]\n", print_r($G_splash_cont_idx, TRUE));
+ fprintf(STDERR, "G_splash_h = [%s]\n", print_r($G_splash_h, TRUE));
+ fprintf(STDERR, "G_splash_idx = [%s]\n", print_r($G_splash_idx, TRUE));
+ fprintf(STDERR, "G_splash_interval = [%s]\n", print_r($G_splash_interval, TRUE));
+ fprintf(STDERR, "G_splash_timeout = [%s]\n", print_r($G_splash_timeout, TRUE));
+ fprintf(STDERR, "G_splash_w = [%s]\n", print_r($G_splash_w, TRUE));
+ fprintf(STDERR, "G_topbanner = [%s]\n", print_r($G_topbanner, TRUE));
+ fprintf(STDERR, "G_with_donors = [%s]\n", print_r($G_with_donors, TRUE));
+ fprintf(STDERR, "G_with_poll = [%s]\n", print_r($G_with_poll, TRUE));
+ fprintf(STDERR, "G_sidebanner = [%s]\n", print_r($G_sidebanner, TRUE));
+ fprintf(STDERR, "G_sidebanner_idx = [%s]\n", print_r($G_sidebanner_idx, TRUE));
+ fprintf(STDERR, "G_with_splash = [%s]\n", print_r($G_with_splash, TRUE));
+ fprintf(STDERR, "G_with_topbanner = [%s]\n", print_r($G_with_topbanner, TRUE));
+ fprintf(STDERR, "G_selfreg_mask = [%x]\n", print_r($G_selfreg_mask, TRUE));
+
+ fprintf(STDERR, "G_selfreg_tout = [%s]\n", print_r($G_selfreg_tout, TRUE));
+
+}
+
+function pid_save()
+{
+ $pid = getmypid();
+ $fname = LEGAL_PATH."/brisk.pid";
+
+ if (file_exists($fname)) {
+ log_crit("WARN: brisk.pid already exists");
+ }
+ file_put_contents($fname, sprintf("%d\n", $pid));
+}
+
+function pid_remove()
+{
+ $fname = LEGAL_PATH."/brisk.pid";
+
+ if (file_exists($fname)) {
+ unlink($fname);
+ }
+}
+
+function post_manage(&$post, $line)
+{
+ $a = explode('&', $line);
+ for ($i = 0 ; $i < count($a) ; $i++) {
+ $b = explode('=', $a[$i]);
+ if (isset($b[0])) {
+ if (isset($b[1])) {
+ $post[$b[0]] = urldecode($b[1]);
+ }
+ else {
+ $post[$b[0]] = "";
+ }
+ }
+ }
+}
+
+function spu_process_info($stream_info, &$method, &$header, &$get, &$post, &$cookie, &$rest, &$cont)