function nel_render_staff_panel_edit($dataforce, $auth)
{
    $render = new nel_render();
    array_walk($auth['perms'], create_function('&$item1', '$item1 = is_bool($item1) ? $item1 === TRUE ? "checked" : "" : $item1;'));
    $render->add_multiple_data($auth['perms']);
    nel_render_header($dataforce, $render, array());
    $render->parse('staff_panel_edit.tpl', 'management');
    nel_render_footer($render, FALSE, FALSE, FALSE, FALSE, FALSE);
    $render->output(TRUE);
}
Esempio n. 2
0
function nel_main_nel_thread_generator($dataforce, $dbh)
{
    $gen_data = array();
    $gen_data['insert_hr'] = FALSE;
    $dataforce['dotdot'] = '';
    $result = $dbh->query('SELECT post_number FROM ' . POSTTABLE . ' WHERE response_to=0 AND archive_status=0 ORDER BY sticky desc,last_update desc');
    $front_page_list = $result->fetchALL(PDO::FETCH_COLUMN);
    unset($result);
    $treeline = array(0);
    // Finding the last entry number
    $result = $dbh->query('SELECT COUNT(post_number) FROM ' . POSTTABLE . ' WHERE response_to=0');
    $row = $result->fetch();
    unset($result);
    $counttree = count($front_page_list);
    // Special handling when there's no content
    if ($counttree === 0) {
        $render = new nel_render();
        $render->add_data('header_type', 'NORMAL');
        nel_render_header($dataforce, $render, $treeline);
        nel_render_posting_form($dataforce, $render);
        $render->add_data('prev_nav', '');
        $render->add_data('next_nav', '');
        $render->add_data('page_nav', '');
        nel_render_footer($render, FALSE, TRUE, TRUE, FALSE, TRUE);
        if (empty($_SESSION) || $_SESSION['ignore_login']) {
            nel_write_file(PHP_SELF2 . PHP_EXT, $render->output(FALSE), 0644);
        } else {
            $render->output(TRUE);
        }
        return;
    }
    $thread_counter = 0;
    $page = 1;
    $gen_data['post_counter'] = -1;
    while ($thread_counter < $counttree) {
        $render = new nel_render();
        $dataforce['omitted_done'] = TRUE;
        $render->add_data('header_type', 'NORMAL');
        nel_render_header($dataforce, $render, $treeline);
        nel_render_posting_form($dataforce, $render);
        $end_of_thread = FALSE;
        $sub_page_thread_counter = 0;
        $gen_data['first100'] = FALSE;
        while ($sub_page_thread_counter < BS_THREADS_PER_PAGE) {
            if ($gen_data['post_counter'] === -1) {
                $result = $dbh->query('SELECT * FROM ' . POSTTABLE . ' WHERE post_number=' . $front_page_list[$thread_counter] . '');
                $tree_op = $result->fetchALL(PDO::FETCH_ASSOC);
                unset($result);
                $result = $dbh->query('SELECT * FROM ' . POSTTABLE . ' WHERE response_to=' . $front_page_list[$thread_counter] . ' ORDER BY post_number desc LIMIT ' . (BS_ABBREVIATE_THREAD - 1) . '');
                $tree_replies = $result->fetchALL(PDO::FETCH_ASSOC);
                unset($result);
                $treeline = array_merge($tree_op, array_reverse($tree_replies));
                $gen_data['post_count'] = $treeline[0]['post_count'];
                $gen_data['expand_post'] = $gen_data['post_count'] > BS_ABBREVIATE_THREAD ? TRUE : FALSE;
                $gen_data['first100'] = $gen_data['post_count'] > 100 ? TRUE : FALSE;
            }
            if (!empty($treeline[$gen_data['post_counter']]) && !empty($treeline[$gen_data['post_counter'] + 1])) {
                ++$gen_data['post_counter'];
            } else {
                if ($gen_data['post_counter'] === -1) {
                    $gen_data['post_counter'] = 0;
                } else {
                    $end_of_thread = TRUE;
                    $sub_page_thread_counter = $thread_counter == $counttree - 1 ? BS_THREADS_PER_PAGE : ++$sub_page_thread_counter;
                    ++$thread_counter;
                    $gen_data['insert_hr'] = TRUE;
                    nel_render_post($dataforce, $render, FALSE, FALSE, $gen_data, $treeline, $dbh);
                    $gen_data['insert_hr'] = FALSE;
                }
            }
            if (!$end_of_thread) {
                $gen_data['has_file'] = FALSE;
                if ($treeline[$gen_data['post_counter']]['has_file'] == 1) {
                    $gen_data['has_file'] = TRUE;
                    $result = $dbh->query('SELECT * FROM ' . FILETABLE . ' WHERE post_ref=' . $treeline[$gen_data['post_counter']]['post_number'] . ' ORDER BY file_order asc');
                    $gen_data['files'] = $result->fetchALL(PDO::FETCH_ASSOC);
                    unset($result);
                }
                if ($treeline[$gen_data['post_counter']]['response_to'] > 0) {
                    if (!$treeline[$gen_data['post_counter']]['post_number']) {
                        break;
                    }
                    if ($gen_data['post_count'] > BS_ABBREVIATE_THREAD && $gen_data['post_counter'] === 1) {
                        $dataforce['omitted_done'] = FALSE;
                        nel_render_post($dataforce, $render, TRUE, TRUE, $gen_data, $treeline, $dbh);
                        $dataforce['omitted_done'] = TRUE;
                    } else {
                        nel_render_post($dataforce, $render, TRUE, TRUE, $gen_data, $treeline, $dbh);
                    }
                } else {
                    nel_render_post($dataforce, $render, FALSE, FALSE, $gen_data, $treeline, $dbh);
                }
            } else {
                $end_of_thread = FALSE;
                $gen_data['post_counter'] = -1;
            }
        }
        // if not in res display mode
        $prev = $page - 1;
        $next = $page + 1;
        $render->add_data('page_nav', ' ');
        $page_count = (int) ceil($counttree / BS_THREADS_PER_PAGE);
        $render->add_data('main_page', TRUE);
        if ($page === 1) {
            $render->add_data('prev_nav', 'Previous');
        } else {
            if ($page === 2) {
                $render->add_data('prev_nav', '<a href="' . PHP_SELF2 . PHP_EXT . '">Previous</a> ');
            } else {
                $render->add_data('prev_nav', '<a href="' . PHP_SELF2 . ($page - 2) . PHP_EXT . '">Previous</a>');
            }
        }
        $render->add_data('next_nav', $page === $page_count || $dataforce['max_pages'] === 1 ? 'Next' : '<a href="' . PHP_SELF2 . $page . PHP_EXT . '">Next</a>');
        $i = 0;
        while ($i < $page_count) {
            if ($i === 0) {
                $render->add_data('page_nav', $render->retrieve_data('page_nav') . ($page > 1 ? '[<a href="' . PHP_SELF2 . PHP_EXT . '">0</a>] ' : '[0] '));
            } else {
                if ($i === $page - 1 || $dataforce['max_pages'] === 1) {
                    $render->add_data('page_nav', $render->retrieve_data('page_nav') . '[' . $i . '] ');
                } else {
                    $render->add_data('page_nav', $render->retrieve_data('page_nav') . '[<a href="' . PHP_SELF2 . $i . PHP_EXT . '">' . $i . '</a>] ');
                }
            }
            ++$i;
        }
        nel_render_footer($render, FALSE, TRUE, TRUE, FALSE, TRUE);
        if (!empty($_SESSION) && !$_SESSION['ignore_login']) {
            if ($page >= $dataforce['current_page']) {
                $page = $counttree;
            }
            $render->output(TRUE);
            die;
        } else {
            $logfilename = $page === 1 ? PHP_SELF2 . PHP_EXT : PHP_SELF2 . ($page - 1) . PHP_EXT;
            nel_write_file($logfilename, $render->output(FALSE), 0644);
        }
        ++$page;
        unset($render);
    }
}
Esempio n. 3
0
function nel_thread_generator($dataforce, $dbh)
{
    $render = new nel_render();
    $render_expand = new nel_render();
    $render_collapse = new nel_render();
    $gen_data['insert_hr'] = FALSE;
    $dataforce['dotdot'] = '';
    $write_id = $dataforce['response_to'] === 0 || is_null($dataforce['response_to']) ? $dataforce['response_id'] : $dataforce['response_to'];
    $result = $dbh->query('SELECT * FROM ' . POSTTABLE . ' WHERE post_number=' . $write_id . ' UNION SELECT * FROM ' . POSTTABLE . ' WHERE response_to=' . $write_id . ' ORDER BY post_number asc');
    $treeline = $result->fetchAll(PDO::FETCH_ASSOC);
    unset($result);
    if (empty($treeline)) {
        return;
    }
    if (empty($_SESSION) || $_SESSION['ignore_login']) {
        $dataforce['dotdot'] = '../../';
    }
    $gen_data['post_count'] = $treeline[0]['post_count'];
    $page = 1;
    $gen_data['post_counter'] = 0;
    $gen_data['expand_post'] = FALSE;
    $dataforce['omitted_done'] = TRUE;
    $partlimit = 1;
    $gen_data['first100'] = FALSE;
    while ($gen_data['post_counter'] < $gen_data['post_count']) {
        if ($treeline[$gen_data['post_counter']]['has_file'] == 1) {
            $gen_data['has_file'] = TRUE;
            $result = $dbh->query('SELECT * FROM ' . FILETABLE . ' WHERE post_ref=' . $treeline[$gen_data['post_counter']]['post_number'] . ' ORDER BY file_order asc');
            $gen_data['files'] = $result->fetchALL(PDO::FETCH_ASSOC);
            unset($result);
        } else {
            $gen_data['has_file'] = FALSE;
        }
        if ($gen_data['post_counter'] === 0) {
            $render->add_data('header_type', 'NORMAL');
            nel_render_header($dataforce, $render, $treeline);
            nel_render_posting_form($dataforce, $render);
        }
        if ($partlimit === 100) {
            $render_temp = clone $render;
            $gen_data['insert_hr'] = TRUE;
            nel_render_post($dataforce, $render_temp, FALSE, FALSE, $gen_data, $treeline, $dbh);
            $gen_data['insert_hr'] = FALSE;
            nel_render_footer($render_temp, FALSE, TRUE, TRUE, TRUE, FALSE);
            nel_write_file(PAGE_PATH . $write_id . '/' . $dataforce['response_id'] . '-0-100.html', $render_temp->output(), 0644);
            unset($render_temp);
        }
        if ($treeline[$gen_data['post_counter']]['response_to'] > 0) {
            if (!$treeline[$gen_data['post_counter']]['post_number']) {
                break;
            }
            $resid = $dataforce['response_id'];
            $render_temp = new nel_render();
            $render_temp2 = new nel_render();
            $render_temp3 = new nel_render();
            nel_render_post($dataforce, $render_temp, TRUE, FALSE, $gen_data, $treeline, $dbh);
            // for thread
            $dataforce['response_id'] = 0;
            nel_render_post($dataforce, $render_temp2, TRUE, TRUE, $gen_data, $treeline, $dbh);
            // for collapse
            nel_render_post($dataforce, $render_temp3, TRUE, TRUE, $gen_data, $treeline, $dbh);
            // for expand
            $dataforce['response_id'] = $resid;
            if ($gen_data['post_count'] > BS_ABBREVIATE_THREAD) {
                if ($render_collapse->output() === '') {
                    $dataforce['omitted_done'] = FALSE;
                    nel_render_post($dataforce, $render_temp2, TRUE, TRUE, $gen_data, $treeline, $dbh);
                    // for collapse
                    $dataforce['omitted_done'] = TRUE;
                }
                if ($gen_data['post_counter'] > $gen_data['post_count'] - BS_ABBREVIATE_THREAD) {
                    $render_collapse->input($render_temp2->output());
                }
            }
            $render->input($render_temp->output());
            $render_expand->input($render_temp3->output());
        } else {
            nel_render_post($dataforce, $render, FALSE, FALSE, $gen_data, $treeline, $dbh);
        }
        ++$partlimit;
        ++$gen_data['post_counter'];
        unset($render_temp);
        unset($render_temp2);
        unset($render_temp3);
    }
    nel_render_footer($render, FALSE, TRUE, TRUE, TRUE, FALSE);
    if (!empty($_SESSION) && !$_SESSION['ignore_login']) {
        if ($dataforce['expand']) {
            $render_expand->output(TRUE);
        } else {
            if ($dataforce['collapse']) {
                $render_collapse->output(TRUE);
            } else {
                $render->output(TRUE);
            }
        }
        die;
    } else {
        nel_write_file(PAGE_PATH . $write_id . '/' . $dataforce['response_id'] . '.html', $render->output(FALSE), 0644);
        nel_write_file(PAGE_PATH . $write_id . '/' . $dataforce['response_id'] . '-expand.html', $render_expand->output(FALSE), 0644);
        nel_write_file(PAGE_PATH . $write_id . '/' . $dataforce['response_id'] . '-collapse.html', $render_collapse->output(FALSE), 0644);
    }
}