function blocks($side)
{
    global $blocks;
    //switch(strtolower(substr($side,0,1)))
    switch (strtolower(substr($side, 0, 1))) {
        case 'l':
        case 'r':
        case 'c':
            $side = strtolower(substr($side, 0, 1));
            break;
        default:
            echo "<h1>something wierd</h1>";
    }
    for ($i = 0; $i < count($blocks); $i++) {
        if ($side == $blocks[$i]['position']) {
            $bid = $i;
            $bkey = $blocks[$i]['bkey'];
            $title = $blocks[$i]['title'];
            $content = $blocks[$i]['content'];
            $url = $blocks[$i]['url'];
            $blockfile = $blocks[$i]['blockfile'];
            $view = $blocks[$i]['view'];
            if ($bkey == 'admin') {
                adminblock();
            } elseif ($bkey == 'userbox') {
                userblock();
            } elseif ($bkey == '') {
                if ($view == 0) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 1 && is_user()) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 2 && is_admin()) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 3 && !is_user()) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                }
            }
        }
    }
}
Exemplo n.º 2
0
function blocks($side)
{
    global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user;
    if ($multilingual == 1) {
        $querylang = "AND (blanguage='{$currentlang}' OR blanguage='')";
    } else {
        $querylang = "";
    }
    if (strtolower($side[0]) == "l") {
        $pos = "l";
    } elseif (strtolower($side[0]) == "r") {
        $pos = "r";
    } elseif (strtolower($side[0]) == "c") {
        $pos = "c";
    } elseif (strtolower($side[0]) == "d") {
        $pos = "d";
    }
    $side = $pos;
    $sql = "SELECT bid, bkey, title, content, url, blockfile, view, expire, action, subscription FROM " . $prefix . "_blocks WHERE bposition='{$pos}' AND active='1' {$querylang} ORDER BY weight ASC";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $bid = intval($row['bid']);
        $title = filter($row['title'], "nohtml");
        $content = stripslashes($row['content']);
        $url = filter($row['url'], "nohtml");
        $blockfile = filter($row['blockfile'], "nohtml");
        $view = intval($row['view']);
        $expire = intval($row['expire']);
        $action = filter($row['action'], "nohtml");
        $action = substr($action, 0, 1);
        $now = time();
        $sub = intval($row['subscription']);
        if ($sub == 0 or $sub == 1 and !paid()) {
            if ($expire != 0 and $expire <= $now) {
                if ($action == "d") {
                    $db->sql_query("UPDATE " . $prefix . "_blocks SET active='0', expire='0' WHERE bid='{$bid}'");
                    return;
                } elseif ($action == "r") {
                    $db->sql_query("DELETE FROM " . $prefix . "_blocks WHERE bid='{$bid}'");
                    return;
                }
            }
            if ($row['bkey'] == "admin") {
                adminblock();
            } elseif ($row['bkey'] == "userbox") {
                userblock();
            } elseif (empty($row['bkey'])) {
                if ($view == 0) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 1 and is_user($user) || is_admin($admin)) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 2 and is_admin($admin)) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                } elseif ($view == 3 and !is_user($user) || is_admin($admin)) {
                    render_blocks($side, $blockfile, $title, $content, $bid, $url);
                }
            }
        }
    }
    $db->sql_freeresult($result);
}
Exemplo n.º 3
0
function show_blocks($position)
{
    global $CURUSER, $use_blocks, $already_used, $orbital_blocks;
    static $showed_show_hide;
    if ($use_blocks) {
        if (!$already_used) {
            $blocks_res = sql_query("SELECT * FROM orbital_blocks WHERE active = 1 ORDER BY weight ASC") or sqlerr(__FILE__, __LINE__);
            while ($blocks_row = mysql_fetch_array($blocks_res)) {
                $orbital_blocks[] = $blocks_row;
            }
            if (!$orbital_blocks) {
                $orbital_blocks = array();
            }
            $already_used = true;
        }
        foreach ($orbital_blocks as $block) {
            if (!$showed_show_hide) {
                echo '<script language="javascript" type="text/javascript" src="js/show_hide.js"></script>';
            }
            $showed_show_hide = true;
            $bid = $block["bid"];
            $content = $block["content"];
            $title = $block["title"];
            $blockfile = $block["blockfile"];
            $bposition = $block["bposition"];
            $allow_hide = $block["allow_hide"] == 'yes';
            if ($position != $bposition) {
                continue;
            }
            $view = $block["view"];
            $which = explode(",", $block["which"]);
            $module_name = str_replace(".php", "", basename($_SERVER["PHP_SELF"]));
            if (!(in_array($module_name, $which) || in_array("all", $which) || in_array("ihome", $which) && $module_name == "index")) {
                continue;
            }
            if ($view == 0) {
                render_blocks($blockfile, $title, $content, $bid, $bposition, $allow_hide);
            } elseif ($view == 1 && $CURUSER) {
                render_blocks($blockfile, $title, $content, $bid, $bposition, $allow_hide);
            } elseif ($view == 2 && get_user_class() >= UC_MODERATOR) {
                render_blocks($blockfile, $title, $content, $bid, $bposition, $allow_hide);
            } elseif ($view == 3 && (!$CURUSER || get_user_class() >= UC_MODERATOR)) {
                render_blocks($blockfile, $title, $content, $bid, $bposition, $allow_hide);
            }
        }
    }
}
Exemplo n.º 4
0
function BlocksShow($bid)
{
    global $prefix, $db, $admin_file;
    BlocksNavi();
    list($bid, $bkey, $title, $content, $bposition, $blockfile) = mysql_fetch_row(sql_query("SELECT bid, bkey, title, content, bposition, blockfile FROM " . $prefix . "_blocks WHERE bid='{$bid}'"));
    $bid = intval($bid);
    echo "<p />";
    render_blocks($blockfile, $title, $content, $bid, 'c', 'no');
    echo "<h4>[ <a href=\"" . $admin_file . ".php?op=BlocksChange&bid={$bid}\">Включить</a> | <a href=\"" . $admin_file . ".php?op=BlocksEdit&bid={$bid}\">Редактировать</a>";
    if ($bkey == "") {
        echo " | <a href=\"" . $admin_file . ".php?op=BlocksDelete&bid={$bid}\" OnClick=\"return DelCheck(this, 'Удалить &quot;{$title}&quot;?');\">Удалить</a>";
    }
    echo " | <a href=\"" . $admin_file . ".php?op=BlocksAdmin\">Главная</a> ]</h4>";
}