Esempio n. 1
0
 public static function init()
 {
     global $conf;
     self::$conf =& $conf;
     self::$db = new bwDatabase();
     self::$cateData = self::$cateList = self::$extList = self::$extData = array();
     if (!defined('FORCE_UGLY_URL')) {
         define('FORCE_UGLY_URL', 0);
     }
     if (FORCE_UGLY_URL == 1 || self::$conf['linkPrefixIndex'] == 'index.php' && false !== stripos($_SERVER['SERVER_SOFTWARE'], 'nginx')) {
         self::$conf['linkPrefixIndex'] = 'index.php?go=';
         self::$conf['linkPrefixCategory'] = 'category.php?go=';
         self::$conf['linkPrefixArticle'] = 'read.php?go=';
         self::$conf['linkPrefixTag'] = 'tag.php?go=';
         self::$conf['linkPrefixSend'] = 'send.php?go=';
         self::$conf['linkPrefixAdmin'] = 'admin.php?go=';
         self::$conf['linkPrefixPage'] = 'page.php?go=';
         self::$conf['linkConj'] = '&';
     } elseif (self::$conf['linkPrefixIndex'] == 'index.php') {
         self::$conf['linkPrefixCategory'] = 'category.php';
         self::$conf['linkPrefixArticle'] = 'read.php';
         self::$conf['linkPrefixTag'] = 'tag.php';
         self::$conf['linkPrefixSend'] = 'send.php';
         self::$conf['linkPrefixAdmin'] = 'admin.php';
         self::$conf['linkPrefixPage'] = 'page.php';
         self::$conf['linkConj'] = '?';
     } else {
         self::$conf['linkPrefixCategory'] = 'category';
         self::$conf['linkPrefixArticle'] = 'post';
         self::$conf['linkPrefixTag'] = 'tag';
         self::$conf['linkPrefixSend'] = 'send.php';
         self::$conf['linkPrefixAdmin'] = 'admin.php';
         self::$conf['linkPrefixPage'] = 'page';
         self::$conf['linkConj'] = '?';
     }
 }
Esempio n. 2
0
    }
}
if ($listMode == 'category') {
    $article->getArticleList();
    foreach ($article->articleList as $oneArticle) {
        $cate = $oneArticle['aCateURLName'];
        $groupedArticles[$cate][] = $oneArticle;
        $columnName[$cate] = $oneArticle['aCateDispName'];
        $columnID[$cate] = $oneArticle['aCateURLName'];
        isset($columnCount[$cate]) ? $columnCount[$cate]++ : ($columnCount[$cate] = 1);
    }
    foreach (bw::$cateList as $onecate) {
        if (isset($groupedArticles[$onecate['aCateURLName']])) {
            $returnGroupArticles[$onecate['aCateURLName']] = $groupedArticles[$onecate['aCateURLName']];
        }
    }
    $groupedArticles = $returnGroupArticles;
}
$partOut = '';
foreach ($groupedArticles as $col => $val) {
    $view->setMaster('groupcolumn');
    $view->setPassData(array('groupedArticles' => $val, 'columnName' => $columnName[$col], 'columnID' => $columnID[$col], 'columnCount' => $columnCount[$col]));
    $view->setWorkFlow(array('groupcolumn'));
    $partOut .= $view->getOutput();
    $view->resetPassData();
}
$view->setMaster('page');
$view->setPassData(array('navigation' => bw::$cateList, 'sociallink' => bw::getSocialLinks(), 'externallink' => bw::getExternalLinks(), 'tagClound' => bw::getTagCloud()));
$view->setPassData(array('listContent' => $partOut));
$view->setWorkFlow(array('page'));
$view->finalize();
Esempio n. 3
0
 public function __construct()
 {
     global $conf;
     $this->perPage =& $conf['perPage'];
     if (!defined('M')) {
         define('M', 'index');
     }
     switch (M) {
         case 'index':
             $this->argsPattern = array('pageNum');
             $this->loaderID = 'cate';
             $this->currentScript = $conf['linkPrefixIndex'];
             break;
         case 'cate':
             $this->argsPattern = array('cateID', 'pageNum');
             $this->loaderID = 'cate';
             $this->currentScript = $conf['linkPrefixCategory'];
             break;
         case 'article':
             $this->argsPattern = array('aID');
             $this->loaderID = 'article';
             $this->currentScript = $conf['linkPrefixArticle'];
             break;
         case 'page':
             $this->argsPattern = array('aID');
             $this->loaderID = 'page';
             $this->currentScript = $conf['linkPrefixPage'];
             break;
         case 'tag':
             $this->argsPattern = array('tValue', 'pageNum');
             $this->loaderID = 'tag';
             $this->currentScript = $conf['linkPrefixTag'];
             break;
         case 'admin':
             $this->argsPattern = array('mainAction', 'subAction', 'pageNum');
             $this->loaderID = 'admin';
             $this->currentScript = 'admin.php';
             break;
         case 'send':
             $this->argsPattern = array('mainAction', 'subAction', 'pageNum');
             $this->loaderID = 'send';
             $this->currentScript = 'send.php';
             break;
         case 'list':
             $this->argsPattern = array('pageNum');
             $this->loaderID = 'list';
             $this->currentScript = $conf['linkPrefixIndex'];
             break;
         case 'api':
             $this->argsPattern = array('mainAPI', 'subAPI', 'pref');
             $this->loaderID = 'api';
             $this->currentScript = 'api.php';
             break;
         default:
             $this->loaderID = 'error';
             $this->currentScript = $conf['linkPrefixIndex'];
             hook('setLoader', 'Execute', $this);
             stopError('Requested mode does not exist.');
     }
     $siteURLTmp = parse_url($conf['siteURL'], PHP_URL_PATH) . '/';
     if (isset($_REQUEST['go'])) {
         $requestedURL = explode('/', $_REQUEST['go']);
     } else {
         if ($siteURLTmp == '/') {
             $requestedURL = explode('/', $_SERVER['PHP_SELF']);
             array_shift($requestedURL);
         } else {
             $requestedURL = explode('/', str_replace($siteURLTmp, '', $_SERVER['PHP_SELF']));
         }
     }
     array_shift($requestedURL);
     if (count($requestedURL) > count($this->argsPattern)) {
         $this->currentArgs = array_slice($requestedURL, 0, count($this->argsPattern));
     } else {
         $this->currentArgs = array_pad($requestedURL, count($this->argsPattern), 1);
     }
     $this->currentArgs = array_combine($this->argsPattern, $this->currentArgs);
     if (array_key_exists('pageNum', $this->currentArgs)) {
         $this->currentPage = $this->currentArgs['pageNum'] = max($this->currentArgs['pageNum'], 1);
         $paginableArgs = $this->currentArgs;
         $paginableArgs['pageNum'] = '%d';
     } else {
         $this->currentPage = 1;
         $paginableArgs = $this->currentArgs;
     }
     $this->canonicalURL = $conf['canonicalURL'] = $conf['siteURL'] . '/' . $this->currentScript . '/' . implode('/', $this->currentArgs) . '/';
     $this->paginableURL = $conf['siteURL'] . '/' . $this->currentScript . '/' . implode('/', $paginableArgs) . '/';
     if (isset($_REQUEST['ajax'])) {
         define('ajax', 1);
     }
     $this->cache = false;
     if (bw::$conf['pageCache'] == '1') {
         if (M == 'index' || M == 'article') {
             $plusAjax = defined('ajax') ? 'ajax' : 'page';
             $cacheKey = md5($this->canonicalURL . $plusAjax);
             $cached = bw::$db->getSingleRow('SELECT * FROM cache WHERE caID=? LIMIT 0, 1', array($cacheKey));
             if (isset($cached['caID'])) {
                 $this->cache = $cached['caContent'];
             } else {
                 define('docache', $cacheKey);
             }
         }
     }
     if (!$this->cache) {
         bw::loadLanguage();
         bw::initCategories();
         bw::loadExtensions();
     }
     if (M != 'admin' && M != 'send') {
         bw::pageStat($this->canonicalURL, M == 'article' ? $this->currentArgs['aID'] : false);
     }
     hook('canonicalized', 'Execute', $this);
 }
Esempio n. 4
0
    } elseif ($canonical->currentArgs['subAction'] == 'selecttheme') {
        if (!isset($_REQUEST['themeID'])) {
            stopError($conf['l']['admin:msg:NoData']);
        }
        $themeID = basename($_REQUEST['themeID']);
        if (!file_exists(P . "theme/{$themeID}/info.php")) {
            stopError($conf['l']['admin:msg:NotExist']);
        }
        file_put_contents(P . 'conf/info.php', str_replace("'siteTheme' => '{$conf['siteTheme']}'", "'siteTheme' => '{$themeID}'", file_get_contents(P . 'conf/info.php')));
        clearCache();
        ajaxSuccess($conf['l']['admin:msg:ChangeSaved']);
    } else {
        $admin->checkCSRFCode('navibar');
        $view->setMaster('admin');
        $view->setPassData(array('themeList' => $view->scanForThemes(), 'extList' => bw::getAllExtensions(), 'newCSRFCode' => $admin->getCSRFCode('newext'), 'extCSRFCode' => $admin->getCSRFCode('extensions')));
        $view->setPassData(array('wgtListHtmlhead' => bw::getWidgets('wghtmlhead'), 'wgtListHeader' => bw::getWidgets('wgheader'), 'wgtListSiderbar' => bw::getWidgets('wgsidebar'), 'wgtListFooter' => bw::getWidgets('wgfooter')));
        foreach ($allOpenHooks as $openHook) {
            $allHooks['insert_' . $openHook] = @file_get_contents(P . 'conf/insert_' . $openHook . '.htm');
        }
        $view->setPassData($allHooks);
        $view->setWorkFlow(array('adminextensions', 'admin'));
        $view->finalize();
    }
}
if ($canonical->currentArgs['mainAction'] == 'comments') {
    $comment = new bwComment();
    if ($canonical->currentArgs['subAction'] == 'blockitem') {
        if (!$_REQUEST['comID'] || !$_REQUEST['aID']) {
            stopError($conf['l']['admin:msg:NotExist']);
        }
        $comment->blockItem($_REQUEST['comID'], $_REQUEST['aID']);
Esempio n. 5
0
 public function getCategories()
 {
     bw::initCategories();
 }
Esempio n. 6
0
define('bwUpdate', 'https://bo-blog.github.io/bw-update/');
if (!defined('P')) {
    die('Access Denied.');
}
if (!file_exists(P . 'conf/info.php')) {
    header('Location: ' . P . 'install/index.php');
    exit;
}
include_once P . 'conf/info.php';
date_default_timezone_set($conf['timeZone']);
spl_autoload_register(function ($class) {
    $classFile = P . 'inc/' . strtolower(substr($class, 2) . '.inc.php');
    file_exists($classFile) && (require_once $classFile);
});
include_once P . 'inc/bw.inc.php';
bw::init();
function stopError($errMsg)
{
    global $view;
    if (!is_object($view)) {
        $view = new bwView();
    }
    $view->haltWithError($errMsg);
}
function ajaxSuccess($successMsg)
{
    global $view;
    if (!is_object($view)) {
        $view = new bwView();
    }
    $view->haltWithSuccess($successMsg);