コード例 #1
0
require_once Config::ABS_PATH . '/lib/logging.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/logging.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Check permission and write message to log file.
    if (!is_admin()) {
        // Cleanup.
        DataExchange::releaseResources();
        display_error_page($smarty, new NotAdminError());
        exit(1);
    }
    call_user_func(Logging::$f['EDIT_USER_GROUPS_USE']);
    $groups = groups_get_all();
    $users = users_get_all();
コード例 #2
0
ファイル: index.php プロジェクト: jellycucmber/kotoba-ib
require_once Config::ABS_PATH . '/lib/misc.php';
require_once Config::ABS_PATH . '/lib/db.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Generate main page html-code and display it.
    $smarty->assign('ib_name', Config::IB_NAME);
    $smarty->display('index.tpl');
    // Cleanup.
    DataExchange::releaseResources();
    exit(0);
} catch (KotobaException $e) {
    // Cleanup.
    DataExchange::releaseResources();
    if (!isset($smarty)) {
コード例 #3
0
ファイル: wrappers.php プロジェクト: jellycucmber/kotoba-ib
/**
 * Get attachments of post.
 * @param SmartyKotobaSetup $smarty Template engine.
 * @param array $board Board.
 * @param array $post Post.
 * @param array $posts_attachments Posts attachemnts relations.
 * @param array $attachments Attachemnts.
 * @return array
 * attachments.
 */
function wrappers_attachments_get_by_post($smarty, $board, &$post, $posts_attachments, $attachments)
{
    $desired_attachments = array();
    $post['with_attachments'] = false;
    foreach ($posts_attachments as $pa) {
        if ($pa['post'] == $post['id']) {
            foreach ($attachments as $a) {
                if ($a['attachment_type'] == $pa['attachment_type']) {
                    switch ($a['attachment_type']) {
                        case Config::ATTACHMENT_TYPE_FILE:
                            if ($a['id'] == $pa['file']) {
                                $a['file_link'] = Config::DIR_PATH . "/{$board['name']}/other/{$a['name']}";
                                $a['thumbnail_link'] = Config::DIR_PATH . "/img/{$a['thumbnail']}";
                                $a['deleted'] = $pa['deleted'];
                                $post['with_attachments'] = true;
                                array_push($desired_attachments, $a);
                            }
                            break;
                        case Config::ATTACHMENT_TYPE_IMAGE:
                            if ($a['id'] == $pa['image']) {
                                $a['image_link'] = Config::DIR_PATH . "/{$board['name']}/img/{$a['name']}";
                                $a['thumbnail_link'] = Config::DIR_PATH . "/{$board['name']}/thumb/{$a['thumbnail']}";
                                $a['deleted'] = $pa['deleted'];
                                $post['with_attachments'] = true;
                                array_push($desired_attachments, $a);
                            }
                            break;
                        case Config::ATTACHMENT_TYPE_LINK:
                            if ($a['id'] == $pa['link']) {
                                $a['deleted'] = $pa['deleted'];
                                $post['with_attachments'] = true;
                                array_push($desired_attachments, $a);
                            }
                            break;
                        case Config::ATTACHMENT_TYPE_VIDEO:
                            if ($a['id'] == $pa['video']) {
                                $a['deleted'] = $pa['deleted'];
                                $smarty->assign('code', $a['code']);
                                $a['video_link'] = $smarty->fetch('youtube.tpl');
                                $post['with_attachments'] = true;
                                array_push($desired_attachments, $a);
                            }
                            break;
                        default:
                            throw new Exception('Not supported.');
                            break;
                    }
                }
            }
        }
    }
    return $desired_attachments;
}
コード例 #4
0
ファイル: menu.php プロジェクト: jellycucmber/kotoba-ib
require_once Config::ABS_PATH . '/lib/misc.php';
require_once Config::ABS_PATH . '/lib/db.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Get boards and categories and make tree for navbar.
    $categories = categories_get_all();
    $boards = boards_get_visible($_SESSION['user']);
    make_category_boards_tree($categories, $boards);
    // Конгломерат. Разкомментируйте и отредактируйте.
    //array_push(
    //    $categories,
    //    array('id' => 'Conglomerate',
    //          'name' => 'Conglomerate',
    //          'boards' => array(array('url' => 'http://wakachan.org/unyl/',
コード例 #5
0
ファイル: news.php プロジェクト: jellycucmber/kotoba-ib
require_once Config::ABS_PATH . '/lib/db.php';
require_once Config::ABS_PATH . '/lib/wrappers.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Get boards and categories and make tree for navbar.
    $categories = categories_get_all();
    $boards = boards_get_visible($_SESSION['user']);
    make_category_boards_tree($categories, $boards);
    // Generate news html-code.
    $news_html = '';
    foreach ($boards as $board) {
        if ($board['name'] == Config::NEWS_BOARD) {
            // Requied for simple and original post templates =\
            $smarty->assign('is_board_view', TRUE);
コード例 #6
0
ファイル: my_id.php プロジェクト: jellycucmber/kotoba-ib
require_once Config::ABS_PATH . '/lib/misc.php';
require_once Config::ABS_PATH . '/lib/db.php';
require_once Config::ABS_PATH . '/lib/exceptions.php';
try {
    // Initialization.
    kotoba_session_start();
    if (Config::LANGUAGE != $_SESSION['language']) {
        require Config::ABS_PATH . "/locale/{$_SESSION['language']}/messages.php";
    }
    locale_setup();
    $smarty = new SmartyKotobaSetup();
    // Check if client banned.
    if (($ban = bans_check(get_remote_addr())) !== FALSE) {
        // Cleanup.
        DataExchange::releaseResources();
        $smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
        $smarty->assign('reason', $ban['reason']);
        $smarty->display('banned.tpl');
        session_destroy();
        exit(1);
    }
    // Generate my id page html-code and display it.
    $smarty->assign('show_control', is_admin() || is_mod());
    $smarty->assign('boards', boards_get_visible($_SESSION['user']));
    $smarty->assign('id', $_SESSION['user']);
    $smarty->assign('groups', $_SESSION['groups']);
    $smarty->display('my_id.tpl');
    if (isset($_REQUEST['kuga'])) {
        echo take_it_easy();
    }
    // Cleanup.