Example #1
0
function ajaxSuccess($successMsg)
{
    global $view;
    if (!is_object($view)) {
        $view = new bwView();
    }
    $view->haltWithSuccess($successMsg);
}
Example #2
0
    die('Access Denied.');
}
//This is a hidden mode. It is inteded to be used in Mill project.
if (!isset($_REQUEST['list'])) {
    $listMode = 'archives';
} elseif ($_REQUEST['list'] == 'archives') {
    $listMode = 'archives';
} elseif ($_REQUEST['list'] == 'tags') {
    $listMode = 'tags';
} elseif ($_REQUEST['list'] == 'category') {
    $listMode = 'category';
} else {
    exit;
}
$article = new bwArticle();
$view = new bwView();
$article->alterPerPage(50000);
$view->setActiveNav($listMode);
$groupedArticles = array();
if ($listMode == 'archives') {
    $article->getArticleList();
    $allStatURL = array();
    foreach ($article->articleList as $oneArticle) {
        $YYYY = substr($oneArticle['aTime'], 0, 4);
        $groupedArticles[$YYYY][] = $oneArticle;
        $columnName[$YYYY] = $YYYY;
        $columnID[$YYYY] = $YYYY;
        isset($columnCount[$YYYY]) ? $columnCount[$YYYY]++ : ($columnCount[$YYYY] = 1);
        $allStatURL[$oneArticle['aID']] = "{$conf['siteURL']}/{$conf['linkPrefixArticle']}/{$oneArticle['aID']}/";
    }
    file_put_contents(P . 'conf/allAIDs.php', "<?php\r\n\$lf=" . var_export($allStatURL, true) . ";");
Example #3
0
 private function get_articles()
 {
     $this->check();
     if ($this->subAPI == 1) {
         //Get articles list
         $howmany = isset($this->partial['num']) ? max(1, floor($this->partial['num'])) : 5;
         $startTime = isset($this->partial['since']) ? strtotime($this->partial['since']) : false;
         $pageNum = isset($this->partial['p']) ? max(1, floor($this->partial['p'])) : 1;
         $article = new bwArticle();
         if ($startTime) {
             //Get articles later than this time
             $article->setSinceTime($startTime);
         }
         $article->alterPageNum($pageNum);
         $article->alterPerPage($howmany);
         $article->getArticleList();
         $outputs = array();
         $i = 0;
         $totalPages = ceil($article->totalArticles / $howmany);
         if ($pageNum > $totalPages) {
             $this->throwError(404, 'Page number does not exist.');
         }
         $extraHeader = "Link: <" . bw::$conf['siteURL'] . "/api.php/articles?num={$howmany}&p=1>; rel=\"first\", ";
         $extraHeader .= "<" . bw::$conf['siteURL'] . "/api.php/articles?num={$howmany}&p={$totalPages}>; rel=\"last\"";
         if ($pageNum + 1 <= $totalPages) {
             $extraHeader .= ",  <" . bw::$conf['siteURL'] . "/api.php/articles?num={$howmany}&p=" . ($pageNum + 1) . ">; rel=\"next\"";
         }
         if ($pageNum > 1) {
             $extraHeader .= ",  <" . bw::$conf['siteURL'] . "/api.php/articles?num={$howmany}&p=" . ($pageNum - 1) . ">; rel=\"prev\"";
         }
         foreach ($article->articleList as $item) {
             $outputs[$i]['ID'] = $item['aID'];
             $outputs[$i]['title'] = $item['aTitle'];
             $outputs[$i]['date'] = $item['aTime'];
             $outputs[$i]['content'] = bwView::textFormatter(str_replace('+++', '', $item['aContent']));
             $outputs[$i]['category'] = $item['aCateDispName'];
             $item['aTags'] && ($outputs[$i]['tags'] = @explode(',', $item['aTags']));
             $outputs[$i]['permal-link'] = bw::$conf['siteURL'] . '/' . bw::$conf['linkPrefixArticle'] . "/{$item['aID']}/";
             $outputs[$i]['author'] = bw::$conf['authorName'];
             $outputs[$i]['about'] = bw::$conf['authorIntro'];
             $outputs[$i]['homepage'] = bw::$conf['siteURL'];
             $i++;
         }
         $this->done(200, array("articles" => $outputs), $extraHeader);
     } else {
         $article = new bwArticle();
         $article->fetchArticle($this->subAPI);
         $item = $article->articleList[$this->subAPI];
         $outputs = array();
         $i = 0;
         $outputs[$i]['title'] = $item['aTitle'];
         $outputs[$i]['date'] = $item['aTime'];
         $outputs[$i]['content'] = bwView::textFormatter(str_replace('+++', '', $item['aContent']));
         $outputs[$i]['category'] = $item['aCateDispName'];
         $item['aTags'] && ($outputs[$i]['tags'] = @explode(',', $item['aTags']));
         $outputs[$i]['permal-link'] = bw::$conf['siteURL'] . '/' . bw::$conf['linkPrefixArticle'] . "/{$item['aID']}/";
         $outputs[$i]['author'] = bw::$conf['authorName'];
         $outputs[$i]['about'] = bw::$conf['authorIntro'];
         $outputs[$i]['homepage'] = bw::$conf['siteURL'];
         $this->done(200, array("articles" => $outputs));
     }
 }
Example #4
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
$article = new bwArticle();
$view = new bwView();
if (isset($canonical->currentArgs['cateID'])) {
    $article->alterCate($canonical->currentArgs['cateID']);
    $view->setPageTitle(bw::$cateData[$canonical->currentArgs['cateID']]);
    $view->setActiveNav($canonical->currentArgs['cateID']);
    if (bw::$cateList[$canonical->currentArgs['cateID']]['aCateTheme']) {
        $view->setTheme(bw::$cateList[$canonical->currentArgs['cateID']]['aCateTheme']);
    }
} else {
    $view->setActiveNav('index');
}
$view->setMetaData(bw::$conf['siteName']);
$article->getArticleList();
// Pagination
$canonical->calTotalPages($article->totalArticles);
$view->doPagination();
// Pass Values
$view->setPassData(array('articlesummary' => $article->articleList));
if (defined('ajax')) {
Example #5
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
$article = new bwArticle();
$view = new bwView();
if (isset($canonical->currentArgs['tValue'])) {
    $view->setPageTitle($conf['l']['page:Tags'] . ' - ' . $canonical->currentArgs['tValue']);
    $view->setActiveNav('index');
} else {
    stopError($conf['l']['admin:msg:NoContent']);
}
$article->getArticleListByTag($canonical->currentArgs['tValue']);
loadServices();
//Load Duoshuo
// Pagination
$canonical->calTotalPages($article->totalArticles);
$view->doPagination();
$view->setPassData(array('articlesummary' => $article->articleList));
if (defined('ajax')) {
    $view->setMaster('ajax-article-list');
    $view->setWorkFlow(array('summary', 'ajax-article-list'));
} else {
    $view->setPassData(array('navigation' => bw::$cateList, 'sociallink' => bw::getSocialLinks(), 'externallink' => bw::getExternalLinks(), 'tagClound' => bw::getTagCloud()));
Example #6
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
@session_start();
$admin = new bwAdmin();
$view = new bwView();
if ($canonical->currentArgs['mainAction'] == '1') {
    if (isset($_REQUEST['mobileToken']) && !isset($_SESSION['login-token'])) {
        if (file_exists(P . 'conf/mobileauth.php')) {
            include_once P . 'conf/mobileauth.php';
            if (in_array($_REQUEST['mobileToken'], $allMobileKeys)) {
                $admin->storeMobileToken();
                $admin->verified = true;
                $_SESSION['authmobile'] = 1;
            }
        }
    }
}
if ($canonical->currentArgs['mainAction'] != 'login') {
    if (!array_key_exists('login-token', $_SESSION)) {
        if (defined('ajax')) {
            stopError($conf['l']['admin:msg:NeedLogin']);
        }
Example #7
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
$article = new bwArticle();
$article->fetchArticle($canonical->currentArgs['aID']);
$view = new bwView();
$view->setPageTitle($article->articleList[$canonical->currentArgs['aID']]['aTitle']);
$view->setMetaData($article->articleList[$canonical->currentArgs['aID']]['aTags']);
$aCateURLName = $article->articleList[$canonical->currentArgs['aID']]['aCateURLName'];
$view->setActiveNav($aCateURLName);
if (bw::$cateList[$aCateURLName]['aCateTheme']) {
    $view->setTheme(bw::$cateList[$aCateURLName]['aCateTheme']);
}
$view->setPassData($article->articleList[$canonical->currentArgs['aID']]);
$view->setPassData(array('navigation' => bw::$cateList, 'sociallink' => bw::getSocialLinks(), 'externallink' => bw::getExternalLinks(), 'tagClound' => bw::getTagCloud()));
$view->setMaster('page');
if ($conf['commentOpt'] != 0) {
    loadServices();
    if ($conf['commentOpt'] == 1 || $conf['commentOpt'] == 2) {
        //Build-in comment
        //Discarded on 2016/6/22
        $view->setWorkFlow(array('nocommentarea', 'article', 'page'));
        /*
Example #8
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2016 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
$article = new bwArticle();
$article->fetchArticle($canonical->currentArgs['aID'], true);
$view = new bwView();
$view->setPageTitle($article->articleList[$canonical->currentArgs['aID']]['aTitle']);
$article->articleList[$canonical->currentArgs['aID']]['aContent'] = $view->commonParser($article->articleList[$canonical->currentArgs['aID']]['aContent']);
$view->setActiveNav('index');
$view->setPassData($article->articleList[$canonical->currentArgs['aID']]);
$view->setPassData(array('navigation' => bw::$cateList, 'sociallink' => bw::getSocialLinks(), 'externallink' => bw::getExternalLinks(), 'tagClound' => bw::getTagCloud()));
$view->setMaster('page');
$view->setWorkFlow(array('singlepage', 'page'));
$view->finalize();
Example #9
0
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
if (!defined('P')) {
    die('Access Denied.');
}
$view = new bwView();
if ($canonical->currentArgs['mainAction'] == 'na') {
    //Authorize a mobile phone
    $knownDevices = array('iphone' => $conf['l']['page:MPiPhone'], 'ipad' => $conf['l']['page:MPiPad'], 'android' => $conf['l']['page:MPAndroid'], 'windows' => $conf['l']['page:MPWindows'], 'blackberry' => $conf['l']['page:MPBlackberry'], 'symbian' => $conf['l']['page:MPSymbian'], 'palm' => $conf['l']['page:MPPalm'], 'ipod' => $conf['l']['page:MPiPodTouch']);
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    foreach ($knownDevices as $devID => $devName) {
        if (strpos($ua, $devID) !== false) {
            $uaDev = $devName;
            break;
        }
    }
    if (!isset($uaDev)) {
        $uaDev = $conf['l']['page:MPDefault'];
    }
    $uaDev = $conf['authorName'] . $conf['l']['page:Conj'] . $uaDev;
    $view->setMaster('authmobile');
    $view->setPassData(array('deviceName' => $uaDev));
    $view->setWorkFlow(array('authmobile'));
    $authX = $view->getOutput();
    $view->setMaster('plainpage');
Example #10
0
File: rss.php Project: bo-blog/bw
<?php

/**
* 
* @link http://bw.bo-blog.com
* @copyright (c) 2014 bW Development Team
* @license MIT
*/
define('P', './');
include_once P . 'inc/system.php';
$canonical = new bwCanonicalization();
$article = new bwArticle();
$article->alterPerPage(20);
$article->getArticleList();
$outputxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\">\n<channel>\n<title>{$conf['siteName']}</title>\n<link>{$conf['siteURL']}</link>\n<description>{$conf['authorIntro']}</description>\n<image><url>{$conf['siteURL']}/conf/profile.png</url><title>{$conf['authorName']}</title><link>{$conf['siteURL']}</link></image>\n";
foreach ($article->articleList as $item) {
    $item['aContent'] = @explode('+++', $item['aContent']);
    $outputxml .= "<item>\n<title>{$item['aTitle']}</title>\n<link>{$conf['siteURL']}/{$conf['linkPrefixArticle']}/{$item['aID']}/</link>\n<author>{$conf['authorName']}</author><pubDate>" . date('c', strtotime($item['aTime'])) . "</pubDate>\n<guid isPermalLink=\"true\">{$conf['siteURL']}/{$conf['linkPrefixArticle']}/{$item['aID']}/</guid>\n<comment>{$conf['siteURL']}/{$conf['linkPrefixArticle']}/{$item['aID']}/#comment-{$item['aID']}</comment>\n<description><![CDATA[" . bwView::textFormatter($item['aContent'][0]) . "]]></description>\n</item>\n";
}
$outputxml .= "</channel></rss>";
@header("Content-Type: application/xml; charset=utf-8");
die($outputxml);
Example #11
0
 public static function textFormatter($text)
 {
     if (!is_object(self::$markdownParser)) {
         include_once P . 'inc/script/parsedown/Parsedown.php';
         self::$markdownParser = new Parsedown();
     }
     $text = self::$markdownParser->text($text);
     // Start customized markdown
     // xiami music loader
     $text = preg_replace("/!~!(.+?)\\[xiami\\]/", "<span class=\"xiamiLoader\" data-src=\"\$1\" data-root=\"" . bw::$conf['siteURL'] . "\"></span>", $text);
     // Wangyi Yun Yinyue loader
     $text = preg_replace("/!~!(.+?)\\[wangyiyun]/", "<p><iframe frameborder=\"no\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" width='330' height='86' src=\"http://music.163.com/outchain/player?type=2&id=\$1&auto=0&height=66\"></iframe></p>", $text);
     // Youku loader
     $text = preg_replace("/!~!(.+?)\\[youku\\]/", "<iframe src=\"http://player.youku.com/embed/\$1\"  frameborder='0' class=\"videoFrame\"></iframe>", $text);
     // Geolocation from Baidu
     $text = preg_replace("/!~!(.+?)\\[location\\]/", "<span class=\"icon-location geoLocator\"></span> <span class=\"geoLocator\">\$1</span>", $text);
     // !!URL = music
     $text = preg_replace("/!!<a href=\"(.+?)\">(.+?)<\\/a>/", "<audio controls><source src=\"\$1\" type=\"audio/mpeg\">Your browser does not support the audio element.</audio>", $text);
     $text = str_replace("\n", '<br/>', $text);
     $text = preg_replace("/<\\/(.+?)><br\\/>/", "</\$1>", $text);
     //Image aligned to left or right
     $text = preg_replace("/<img (.+?) alt=\"-R\"/", "<img \$1 class=\"RImg\" alt=\"\"", $text);
     $text = preg_replace("/<img (.+?) alt=\"-L\"/", "<img \$1 class=\"LImg\" alt=\"\"", $text);
     //Image Gallery
     $varAlbumID = rand(100000, 999999);
     $text = preg_replace("/<img (.+?) alt=\"-Album:(.+?)\"/", "<img \$1 class=\"ImgAlbum Alb" . $varAlbumID . "\" data-desc=\"\$2\" data-album=\"" . $varAlbumID . "\"", $text);
     $text = hook('textParser', 'Replace', $text);
     return $text;
 }