print_body_top();
print_header($g_page_title);
print_spacer();
$f_note_id = gpc_get_int('f_note_id');
$f_page_id = gpc_get_int('f_page_id');
$f_email = gpc_get_string('f_email');
$f_note = gpc_get_string('f_note');
$t_page_info = page_get_info(page_where_id_equals($f_page_id));
if (false === $t_page_info) {
    echo "page not found";
    exit;
}
$t_note['id'] = '0';
$t_note['email'] = string_prepare_note_for_viewing($f_email);
$t_note['date'] = time();
$t_note['note'] = string_prepare_note_for_viewing($f_note);
$t_page_data = array();
$t_page_data['id'] = 0;
$t_page_data['page'] = page_get_name($f_page_id);
$t_page_data['url'] = $t_page_info['url'];
$t_page_data['preview'] = true;
$t_page_data['prev_page'] = '';
$t_page_data['prev_url'] = '';
$t_page_data['next_page'] = '';
$t_page_data['next_url'] = '';
$t_page_data['notes'] = array($t_note);
theme_body($t_page_data);
$f_email = string_to_form($f_email);
$f_note = string_to_form($f_note);
echo <<<EOT
\t<div class="spacer"></div>
function note_get_all_visible($p_page_id)
{
    $notes = array();
    $t_page_info = page_get_info(page_where_id_equals($p_page_id));
    if (false === $t_page_info) {
        return false;
    }
    $c_page_id = db_prepare_int($p_page_id);
    $query = "SELECT *, UNIX_TIMESTAMP(date_submitted) as date_submitted\r\n\t\t\t\tFROM " . config_get('phpWN_note_table') . "\r\n\t\t\t\tWHERE page_id={$c_page_id}\r\n\t\t\t\tORDER BY date_submitted " . config_get('note_order');
    $result = db_query($query);
    while ($row = db_fetch_array($result)) {
        extract($row, EXTR_PREFIX_ALL, 'v');
        if (NOTE_VISIBLE_PENDING == $v_visible && access_check_action(ACTION_NOTES_VIEW_PENDING) === false) {
            continue;
        }
        if (NOTE_VISIBLE_ACCEPTED == $v_visible && access_check_action(ACTION_NOTES_VIEW_ACCEPTED) === false) {
            continue;
        }
        if (NOTE_VISIBLE_DECLINED == $v_visible && access_check_action(ACTION_NOTES_VIEW_DECLINED) === false) {
            continue;
        }
        if (NOTE_VISIBLE_ARCHIVED == $v_visible && access_check_action(ACTION_NOTES_VIEW_ARCHIVED) === false) {
            continue;
        }
        if (NOTE_VISIBLE_DELETED == $v_visible && access_check_action(ACTION_NOTES_VIEW_DELETED) === false) {
            continue;
        }
        $info['visible'] = $v_visible;
        $info['id'] = $v_id;
        $info['email'] = string_prepare_note_for_viewing($v_email, $t_page_info['url']);
        $info['note'] = string_prepare_note_for_viewing($v_note, $t_page_info['url']);
        $info['date'] = $v_date_submitted;
        $notes[] = $info;
    }
    return $notes;
}