Пример #1
1
function DreamCMS_bbs($vars, &$DreamCMS)
{
    if ($DreamCMS->config["bbs"]["call"]) {
        $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
        $bbsurl = $DreamCMS->config["bbs"]["url"];
        $dbpre = $DreamCMS->config["bbs"]["dbpre"];
        $dbname = $DreamCMS->config["bbs"]["dbname"];
        $charset = $DreamCMS->config["bbs"]["charset"];
        if (empty($DreamCMS->config["bbs"]["dbuser"]) && empty($DreamCMS->config["bbs"]["dbpw"]) && $DreamCMS->config["bbs"]["dbhost"] == "localhost") {
            $DB = $DreamCMS->db;
        } else {
            $DB = new DreamCMS_DB($DreamCMS->config["bbs"]["dbuser"], $DreamCMS->config["bbs"]["dbpw"], $dbname, $DreamCMS->config["bbs"]["dbhost"]);
            $DB->hide_errors();
        }
        if (strtolower($charset) != DB_CHARSET && !empty($charset)) {
            $DB->query("SET NAMES '{$charset}'");
        }
        $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
        if ($DreamCMS->config["bbs"]["type"] == "PHPWind") {
            empty($dbpre) && ($dbpre = 'pw_');
            $dbname = $dbname != DB_NAME ? $dbname . '.' . $dbpre : $dbpre;
            $threads = $dbname . 'threads t';
            $forums = $dbname . 'forums f';
            $vars['fid!'] && ($whereSQL .= GetIDSQL($vars['fid!'], 't.fid', 'not'));
            $vars['fid'] && ($whereSQL .= GetIDSQL($vars['fid'], 't.fid'));
            if ($vars['call'] == "forum") {
            } else {
                switch ($vars['orderby']) {
                    case "view":
                        $orderSQL = " ORDER BY t.hits {$by}";
                        break;
                    case "hot":
                        $orderSQL = " ORDER BY t.replies {$by}";
                        break;
                    case "lastpost":
                        $orderSQL = " ORDER BY t.lastpost {$by}";
                        break;
                    case "new":
                        $orderSQL = " ORDER BY t.postdate {$by}";
                        break;
                    case "rand":
                        $orderSQL = " ORDER BY rand() {$by}";
                        break;
                    default:
                        $orderSQL = " ORDER BY t.tid {$by}";
                }
                $whereSQL = "f.fid=t.fid ";
                $vars['tid'] && ($whereSQL .= GetIDSQL($vars['tid'], 't.tid'));
                $vars['tid!'] && ($whereSQL .= GetIDSQL($vars['tid!'], 't.tid', 'not'));
                if ($vars['page']) {
                    $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
                    $total = $DB->get_var("SELECT count(*) FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL}");
                    $DreamCMS->assign("total", $total);
                    $DreamCMS->multi($total, $maxperpage, $DreamCMS->language('page:list'), $DreamCMS->url, $pagenav);
                    $firstcount = $DreamCMS->firstcount;
                } else {
                    $firstcount = 0;
                }
                $rs = $DB->get_results("SELECT t.*, f.name FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL} LIMIT {$firstcount},{$maxperpage}");
                $_count = count($rs);
                for ($i = 0; $i < $_count; $i++) {
                    $rs[$i]['forumname'] = $rs[$i]['name'];
                    $rs[$i]["url"] = $bbsurl . "/read.php?tid={$rs[$i]['tid']}";
                    $rs[$i]["forumurl"] = $bbsurl . "/thread.php?fid={$rs[$i]['fid']}";
                    if ($DreamCMS->config["bbs"]["htmifopen"]) {
                        $db_dir = $DreamCMS->config["bbs"]["htmdir"];
                        $db_ext = $DreamCMS->config["bbs"]["htmext"];
                        $rs[$i]["url"] = PHPWind_BBS_Htm_cv($rs[$i]["url"], $db_dir, $db_ext);
                        $rs[$i]["forumurl"] = PHPWind_BBS_Htm_cv($rs[$i]["forumurl"], $db_dir, $db_ext);
                    }
                }
            }
        } elseif ($DreamCMS->config["bbs"]["type"] == "Discuz") {
            empty($dbpre) && ($dbpre = 'cdb_');
            $dbname = $dbname != DB_NAME ? $dbname . '.' . $dbpre : $dbpre;
            $threads = $dbname . 'threads t';
            $forums = $dbname . 'forums f';
            $vars['fid!'] && ($whereSQL .= GetIDSQL($vars['fid!'], 't.fid', 'not'));
            $vars['fid'] && ($whereSQL .= GetIDSQL($vars['fid'], 't.fid'));
            if ($vars['call'] == "forum") {
            } else {
                switch ($vars['orderby']) {
                    case "view":
                        $orderSQL = " ORDER BY t.views {$by}";
                        break;
                    case "hot":
                        $orderSQL = " ORDER BY t.replies {$by}";
                        break;
                    case "lastpost":
                        $orderSQL = " ORDER BY t.lastpost {$by}";
                        break;
                    case "new":
                        $orderSQL = " ORDER BY t.dateline {$by}";
                        break;
                    case "rand":
                        $orderSQL = " ORDER BY rand() {$by}";
                        break;
                    default:
                        $orderSQL = " ORDER BY t.tid {$by}";
                }
                $whereSQL = "f.fid=t.fid";
                $vars['reply'] && ($whereSQL .= " AND t.closed NOT LIKE 'moved|%' AND t.replies !=0");
                $vars['tid'] && ($whereSQL .= GetIDSQL($vars['tid'], 't.tid'));
                $vars['tid!'] && ($whereSQL .= GetIDSQL($vars['tid!'], 't.tid', 'not'));
                if ($vars['page']) {
                    $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
                    $total = $DB->get_var("SELECT count(*) FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL}");
                    $DreamCMS->assign("total", $total);
                    $DreamCMS->multi($total, $maxperpage, $DreamCMS->language('page:list'), $DreamCMS->url, $pagenav);
                    $firstcount = $DreamCMS->firstcount;
                } else {
                    $firstcount = 0;
                }
                $rs = $DB->get_results("SELECT t.*, f.name FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL} LIMIT {$firstcount},{$maxperpage}");
                $_count = count($rs);
                for ($i = 0; $i < $_count; $i++) {
                    $rs[$i]['forumname'] = $rs[$i]['name'];
                    if ($rs[$i]['highlight']) {
                        $string = sprintf('%02d', $rs[$i]['highlight']);
                        $stylestr = sprintf('%03b', $string[0]);
                        $rs[$i]['highlight'] = 'style="';
                        $rs[$i]['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                        $rs[$i]['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                        $rs[$i]['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                        $rs[$i]['highlight'] .= $string[1] ? 'color: ' . $colorarray[$string[1]] : '';
                        $rs[$i]['highlight'] .= '"';
                    } else {
                        $rs[$i]['highlight'] = '';
                    }
                    if ($DreamCMS->config["bbs"]["htmifopen"]) {
                        $rs[$i]["url"] = $bbsurl . "/thread-{$rs[$i]['tid']}-1-1.html";
                        $rs[$i]["forumurl"] = $bbsurl . "/forum-{$rs[$i]['fid']}-1.html";
                    } else {
                        $rs[$i]["url"] = $bbsurl . "/viewthread.php?tid={$rs[$i]['tid']}";
                        $rs[$i]["forumurl"] = $bbsurl . "/forumdisplay.php?fid={$rs[$i]['fid']}";
                    }
                }
            }
        }
    }
    return $rs;
}
Пример #2
0
        if (!$this->show_errors) {
            return false;
        }
        header('Content-Type: text/html; charset=utf-8');
        $admin_dir = strpos($_SERVER['PHP_SELF'], 'admin') !== false ? '' : 'admin/';
        ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>MySQL Error</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Language" content="utf-8" />
</head>
<body>
	<!--<h1 id="logo"><img alt="DreamArticle" src="templates/system/style/dreamarticle.gif" /></h1>-->
	<p><?php 
        echo $message;
        ?>
</p>
</body>
</html>
<?php 
        die;
    }
}
if (!isset($db)) {
    $db = new DreamCMS_DB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    //	$db->prefix=DB_PREFIX;
    $db->hide_errors();
}