Пример #1
0
function getTrashCommentsWithPagingForOwner($blogid, $category, $name, $ip, $search, $page, $count)
{
    global $database;
    $sql = "SELECT c.*, e.title, c2.name AS parentName \n\t\tFROM {$database['prefix']}Comments c \n\t\tLEFT JOIN {$database['prefix']}Entries e ON c.blogid = e.blogid AND c.entry = e.id AND e.draft = 0 \n\t\tLEFT JOIN {$database['prefix']}Comments c2 ON c.parent = c2.id AND c.blogid = c2.blogid \n\t\tWHERE c.blogid = {$blogid} AND c.isfiltered > 0";
    $postfix = '';
    if ($category > 0) {
        $categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE parent = {$category}");
        array_push($categories, $category);
        $sql .= ' AND e.category IN (' . implode(', ', $categories) . ')';
        $postfix .= '&category=' . rawurlencode($category);
    } else {
        $sql .= ' AND (e.category >= 0 OR c.entry = 0)';
    }
    if (!empty($name)) {
        $sql .= ' AND c.name = \'' . POD::escapeString($name) . '\'';
        $postfix .= '&name=' . rawurlencode($name);
    }
    if (!empty($ip)) {
        $sql .= ' AND c.ip = \'' . POD::escapeString($ip) . '\'';
        $postfix .= '&ip=' . rawurlencode($ip);
    }
    if (!empty($search)) {
        $search = escapeSearchString($search);
        $sql .= " AND (c.name LIKE '%{$search}%' OR c.homepage LIKE '%{$search}%' OR c.comment LIKE '%{$search}%')";
        $postfix .= '&search=' . rawurlencode($search);
    }
    $sql .= ' ORDER BY c.written DESC';
    list($comments, $paging) = Paging::fetch($sql, $page, $count);
    if (strlen($postfix) > 0) {
        $paging['postfix'] .= $postfix . '&withSearch=on';
    }
    return array($comments, $paging);
}
Пример #2
0
function getNoticesWithPaging($blogid, $search, $page, $count)
{
    $context = Model_Context::getInstance();
    $pool = getDefaultDBModelOnNotice($blogid);
    if ($search !== true && $search) {
        $search = escapeSearchString($search);
        $pool->setQualifierSet(array("title", "like", $search, true), "OR", array("content", "like", $search, true));
    }
    return Paging::fetch($pool, $page, $count, $context->getProperty("uri.folder") . "/" . $context->getProperty("suri.value"));
}
Пример #3
0
function getKeywordsWithPaging($blogid, $search, $page, $count)
{
    $ctx = Model_Context::getInstance();
    $aux = '';
    if ($search !== true && $search) {
        $search = POD::escapeString($search);
        $aux = "AND (title LIKE '%{$search}%' OR content LIKE '%{$search}%')";
    }
    $visibility = doesHaveOwnership() ? '' : 'AND visibility > 0';
    $sql = "SELECT * \n\t\tFROM " . $ctx->getProperty('database.prefix') . "Entries \n\t\tWHERE blogid = {$blogid} \n\t\t\tAND draft = 0 {$visibility} \n\t\t\tAND category = -1 {$aux} \n\t\tORDER BY published DESC";
    return Paging::fetch($sql, $page, $count, $ctx->getProperty('uri.folder') . "/" . $ctx->getProperty('suri.value'));
}
Пример #4
0
function getLinksWithPagingForOwner($blogid, $page, $count)
{
    $pool = DBModel::getInstance();
    $pool->init("Links");
    $pool->setAlias("Links", "l");
    $pool->setAlias("LinkCategories", "lc");
    $pool->join("LinkCategories", "left", array(array("lc.blogid", "eq", "l.blogid"), array("lc.id", "eq", "l.category")));
    $pool->setQualifier("l.blogid", "eq", $blogid);
    $pool->setOrder("l.name", "desc");
    $pool->setProjection("l.*", "lc.name AS categoryName");
    return Paging::fetch($pool, $page, $count);
}
Пример #5
0
function getKeywordsWithPaging($blogid, $search, $page, $count)
{
    global $database, $folderURL, $suri;
    $aux = '';
    if ($search !== true && $search) {
        $search = POD::escapeString($search);
        $aux = "AND (title LIKE '%{$search}%' OR content LIKE '%{$search}%')";
    }
    $visibility = doesHaveOwnership() ? '' : 'AND visibility > 0';
    $sql = "SELECT * \n\t\tFROM {$database['prefix']}Entries \n\t\tWHERE blogid = {$blogid} \n\t\t\tAND draft = 0 {$visibility} \n\t\t\tAND category = -1 {$aux} \n\t\tORDER BY published DESC";
    return Paging::fetch($sql, $page, $count, "{$folderURL}/{$suri['value']}");
}
Пример #6
0
function getKeywordsWithPaging($blogid, $search, $page, $count)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $pool->init("Entries");
    $aux = '';
    if ($search !== true && $search) {
        $pool->setQualifierSet(array(array("title", "like", $search, true), "OR", array("content", "like", $search, true)));
    }
    if (!doesHaveOwnership()) {
        $pool->setQualifier("visibility", ">", 0);
    }
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("draft", "eq", 0);
    $pool->setQualifier("category", "eq", -1);
    $pool->setOrder("published", "desc");
    return Paging::fetch($pool, $page, $count, $context->getProperty('uri.folder') . "/" . $context->getProperty('suri.value'));
}
Пример #7
0
function getCommentsWithPaging($blogid, $page, $count, $url = null, $prefix = '?page=', $postfix = '', $countItem = null)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $comments = array();
    $pool->reset("Comments");
    $pool->setAlias("Comments", "r");
    $pool->join("Entries", "inner", array(array("r.blogid", "eq", "e.blogid"), array("r.entry", "eq", "e.id"), array("e.draft", "eq", 0)));
    $pool->setAlias("Entries", "e");
    $pool->join("Categories", "left", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id")));
    $pool->setAlias("Categories", "c");
    $pool->setQualifier("r.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("r.parent", "eq", null);
    if (!doesHaveOwnership()) {
        $pool->setQualifier("e.visibility", ">=", 2);
    }
    $pool->setQualifier("r.entry", ">", 0);
    $pool->setQualifier("r.isfiltered", "eq", 0);
    $pool->setOrder("r.written", "desc");
    $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    list($comments, $paging) = Paging::fetch($pool, $page, $count, $url, $prefix, $countItem);
    $paging['postfix'] = $postfix;
    $comments = coverComments($comments);
    return array($comments, $paging);
}
Пример #8
0
function getRemoteResponseLogsWithPagingForOwner($blogid, $category, $site, $ip, $search, $page, $count, $type = null)
{
    $pool = DBModel::getInstance();
    $postfix = '&status=sent';
    if ($category > 0) {
        // Perform before RemoteResponse pool call to prevent DBModel spoofing.
        $pool->init("Categories");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("parent", "eq", $category);
        $categories = $pool->getColumn("id");
        array_push($categories, $category);
    }
    $pool->init("RemoteResponses");
    $pool->setAlias("RemoteResponses", "t");
    $pool->setAlias("Entries", "e");
    $pool->setAlias("Categories", "c");
    $pool->join("Entries", "left", array(array("t.blogid", "eq", "e.blogid"), array("t.entry", "eq", "e.id"), array("e.draft", "eq", 0)));
    $pool->join("Categories", "left", array(array("t.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id")));
    $pool->setQualifier("t.blogid", "eq", $blogid);
    if ($category > 0) {
        $pool->setQualifier("e.category", "hasoneof", $categories);
        $postfix .= '&category=' . rawurlencode($category);
    } else {
        $pool->setQualifier("e.category", ">=", 0);
    }
    if (!is_null($type)) {
        $pool->setQualifier("t.responsetype", "eq", $type, true);
    }
    if (!empty($search)) {
        $search = escapeSearchString($search);
        $pool->setQualifierSet(array("e.title", "like", $search, true), "OR", array("e.content", "like", $search, true));
        $postfix .= '&search=' . rawurlencode($search);
    }
    $pool->setOrder("t.written", "desc");
    $pool->setProjection("t.*", "e.title AS subject", "c.name AS categoryName");
    list($responses, $paging) = Paging::fetch($pool, $page, $count);
    if (strlen($postfix) > 0) {
        $paging['postfix'] .= $postfix . '&withSearch=on';
    }
    return array($responses, $paging);
}
Пример #9
0
function MT_Cover_getRecentEntries($parameters)
{
    global $skin;
    $context = Model_Context::getInstance();
    $data = $context->getProperty('plugin.config');
    importlib("model.blog.entry");
    importlib("model.blog.tag");
    $data['coverMode'] = !isset($data['coverMode']) ? 1 : $data['coverMode'];
    if (Utils_Misc::isMetaBlog() != true) {
        $data['coverMode'] = 1;
    }
    $data['screenshot'] = !isset($data['screenshot']) ? 1 : $data['screenshot'];
    $data['screenshotSize'] = !isset($data['screenshotSize']) ? 90 : $data['screenshotSize'];
    $data['paging'] = !isset($data['paging']) ? '2' : $data['paging'];
    $data['contentLength'] = !isset($data['contentLength']) ? 250 : $data['contentLength'];
    if (isset($parameters['preview'])) {
        // preview mode
        $retval = '표지에 최신 글 목록을 추가합니다.';
        return htmlspecialchars($retval);
    }
    $entryLength = isset($parameters['entryLength']) ? $parameters['entryLength'] : 10;
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail", 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'))) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'));
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'), 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/", 0777);
    }
    $page = $data['paging'] == '1' && !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $cache = new PageCache();
    $cache->name = 'MT_Cover_RecentPS';
    if ($cache->load()) {
        //If successful loads
        $cache->contents = unserialize($cache->contents);
        // If coverpage is single mode OR coverpage is coverblog and cache is not expired, return cache contents.
        if (($data['coverMode'] == 1 || $data['coverMode'] == 2) && array_key_exists($page, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 300) {
            return $cache->contents[$page];
        }
    }
    $pool = DBModel::getInstance();
    $pool->reset("BlogSettings");
    $pool->setQualifier("name", "eq", 'visibility', true);
    $pool->setQualifier("value", "<", 2);
    $privateBlogId = $pool->getCell("blogid");
    $pool->reset("Entries");
    $pool->join("Categories", "left", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id")));
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", "beq", 0);
    if ($privateBlogId) {
        $pool->setQualifier("e.blogid", "hasnoneof", $privateBlogId);
    }
    if (Utils_Misc::isMetaBlog() == true && doesHaveOwnership() && $context->getProperty('service.type', 'single') != 'single') {
        $pool->setQualifier("e.visibility", ">", 1);
        $pool->setQualifierSet(array("c.visibility", ">", 1), "OR", array("e.category", "eq", 0));
    } else {
        if (!doesHaveOwnership()) {
            $pool->setQualifier("e.visibility", ">", 1);
            $pool->setQualifierSet(array("c.visibility", ">", 1), "OR", array("e.category", "eq", 0));
        }
    }
    if ($data['coverMode'] != 2) {
        $pool->setQualifier("e.blogid", "eq", $context->getProperty("blog.id"));
    }
    list($entries, $paging) = Paging::fetch($pool, $page, $entryLength);
    $html = '';
    foreach ((array) $entries as $entry) {
        $tagLabelView = "";
        $blogid = $data['coverMode'] == 2 ? $entry['blogid'] : $context->getProperty('blog.id');
        $entryTags = getTags($blogid, $entry['id']);
        $defaultURL = getDefaultURL($blogid);
        if (sizeof($entryTags) > 0) {
            $tags = array();
            foreach ($entryTags as $entryTag) {
                $tags[$entryTag['name']] = "<a href=\"{$defaultURL}/tag/" . (Setting::getBlogSettingGlobal('useSloganOnTag', true) ? URL::encode($entryTag['name'], $service['useEncodedURL']) : $entryTag['id']) . '">' . htmlspecialchars($entryTag['name']) . '</a>';
            }
            $tagLabelView = "<div class=\"post_tags\"><span>TAG : </span>" . implode(",\r\n", array_values($tags)) . "</div>";
        }
        if (empty($entry['category'])) {
            $entry['label'] = _text('분류없음');
            $entry['link'] = "{$defaultURL}/category";
        } else {
            $entry['link'] = "{$defaultURL}/category/" . (Setting::getBlogSettingGlobal('useSloganOnCategory', true) ? URL::encode($entry['label'], $service['useEncodedURL']) : $entry['category']);
        }
        $permalink = "{$defaultURL}/" . (Setting::getBlogSettingGlobal('useSloganOnPost', true) ? "entry/" . URL::encode($entry['slogan'], $context->getProperty('service.useEncodedURL', false)) : $entry['id']);
        $html .= '<div class="coverpost">' . CRLF;
        if ($imageName = MT_Cover_getAttachmentExtract($entry['content'])) {
            if (($tempImageSrc = MT_Cover_getImageResizer($blogid, $imageName, $data['screenshotSize'])) && $data['screenshot'] == 1) {
                $html .= '<div class="img_preview"><a href="' . $permalink . '"><img src="' . $tempImageSrc . '" alt="" /></a></div>' . CRLF;
            }
        }
        $html .= '	<div class="content_box">';
        $html .= '		<h2><a href="' . $permalink . '">' . htmlspecialchars($entry['title']) . '</a></h2>' . CRLF;
        $html .= '		<div class="post_info">' . CRLF;
        $html .= '			<span class="category"><a href="' . htmlspecialchars($entry['link']) . '">' . htmlspecialchars($entry['label']) . '</a></span>' . CRLF;
        $html .= '			<span class="date">' . Timestamp::format5($entry['published']) . '</span>' . CRLF;
        $html .= '			<span class="author"><span class="preposition">by </span>' . User::getName($entry['userid']) . '</span>' . CRLF;
        $html .= '		</div>' . CRLF;
        $html .= '		<div class="post_content">' . htmlspecialchars(Utils_Unicode::lessenAsEm(removeAllTags(stripHTML($entry['content'])), $data['contentLength'])) . '</div>' . CRLF;
        $html .= $tagLabelView;
        $html .= '		<div class="clear"></div>' . CRLF;
        $html .= '	</div>';
        $html .= '</div>' . CRLF;
    }
    if ($data['paging'] == '1') {
        $paging['page'] = $page;
        $paging['total'] = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Entries e WHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0");
        $html .= Paging::getPagingView($paging, $skin->paging, $skin->pagingItem) . CRLF;
        $html .= '<script type="text/javascript">' . CRLF;
        $html .= '//<![CDATA[' . CRLF;
        if ($paging['page'] > 1) {
            $html .= 'var prevURL = "' . $paging['url'] . '?page=' . ($paging['page'] - 1) . '"' . CRLF;
        }
        if ($paging['page'] < $paging['total']) {
            $html .= 'var nextURL = "' . $paging['url'] . '?page=' . ($paging['page'] + 1) . '"' . CRLF;
        }
        $html .= '//]]>' . CRLF;
        $html .= '</script>';
    }
    $target = $html;
    $cache->contents[$page] = $target;
    $cache->contents = serialize($cache->contents);
    $cache->dbContents = Timestamp::getUNIXtime();
    $cache->update();
    unset($cache);
    return $target;
}
Пример #10
0
function getSubscriptionLogsWithPage($page, $count)
{
    global $database;
    $blogid = getBlogId();
    requireComponent("Textcube.Model.Paging");
    return Paging::fetch("SELECT ip, host, useragent, referred FROM {$database['prefix']}SubscriptionLogs WHERE blogid = {$blogid} ORDER BY referred DESC", $page, $count);
}
Пример #11
0
function getSubscriptionLogsWithPage($page, $count)
{
    $blogid = getBlogId();
    $pool = DBModel::getInstance();
    $pool->reset("SubscriptionLogs");
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setOrder("referred", "DESC");
    $pool->setProjection('ip', 'host', 'useragent', 'referred');
    return Paging::fetch($pool, $page, $count);
    //return Paging::fetch("SELECT ip, host, useragent, referred FROM {$database['prefix']}SubscriptionLogs WHERE blogid = $blogid ORDER BY referred DESC", $page, $count);
}
Пример #12
0
function getEntriesWithPagingForOwner($blogid, $category, $search, $page, $count, $visibility = null, $starred = null, $draft = null, $tag = null)
{
    global $database, $suri;
    $teamMemberFilter = "";
    if (!Acl::check("group.editors", "entry.list")) {
        $teamMemberFilter = " AND e.userid = " . getUserId();
    }
    $sqlTable = "SELECT e.*, c.label AS categoryLabel, d.id AS draft \n\t\tFROM {$database['prefix']}Entries e \n\t\tLEFT JOIN {$database['prefix']}Categories c ON e.category = c.id AND e.blogid = c.blogid \n\t\tLEFT JOIN {$database['prefix']}Entries d ON e.blogid = d.blogid AND e.id = d.id AND d.draft = 1 ";
    $sql = " WHERE e.blogid = {$blogid} AND e.draft = 0" . $teamMemberFilter;
    if ($category > 0) {
        $categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND parent = {$category}");
        array_push($categories, $category);
        $sql .= ' AND e.category IN (' . implode(', ', $categories) . ')';
    } else {
        if ($category == -3) {
            $sql .= ' AND e.category = 0';
        } else {
            if ($category == -5) {
                $sql .= ' AND e.category >= -2';
            } else {
                if ($category == 0) {
                    $sql .= ' AND e.category >= 0';
                } else {
                    $sql .= ' AND e.category = ' . $category;
                }
            }
        }
    }
    if (isset($visibility)) {
        if (Validator::isInteger($visibility, 0, 3)) {
            $sql .= ' AND e.visibility = ' . $visibility;
        } else {
            $sql .= ' AND e.visibility ' . $visibility;
        }
    }
    if (isset($starred)) {
        if (Validator::isInteger($starred, 0, 3)) {
            $sql .= ' AND e.starred = ' . $starred;
        } else {
            $sql .= ' AND e.starred ' . $starred;
        }
    }
    if (!empty($search)) {
        $search = escapeSearchString($search);
        $sql .= " AND (e.title LIKE '%{$search}%' OR e.content LIKE '%{$search}%')";
    }
    if (!empty($tag)) {
        $sqlTable .= " LEFT JOIN {$database['prefix']}TagRelations t ON e.id = t.entry AND e.blogid = t.blogid ";
        $sql .= ' AND t.tag = ' . $tag;
    }
    $sql .= ' ORDER BY e.published DESC';
    return Paging::fetch($sqlTable . $sql, $page, $count);
}
Пример #13
0
function fetchWithPaging($sql, $page, $count, $url = null, $prefix = '?page=', $countItem = null)
{
    return Paging::fetch($sql, $page, $count, $url, $prefix, $countItem);
}
Пример #14
0
function getEntriesWithPagingForOwner($blogid, $category, $search, $page, $count, $visibility = null, $starred = null, $draft = null, $tag = null)
{
    $pool = DBModel::getInstance();
    if ($category > 0) {
        $categories = getChildCategoryId($blogid, $category);
        array_push($categories, $category);
    }
    $pool->reset("Entries");
    $pool->setAlias("Entries", "e");
    $pool->extend("Categories", "LEFT", array(array('e.blogid', 'eq', 'c.blogid'), array('e.category', '=', 'c.id')));
    $pool->setAlias("Categories", "c");
    $pool->extend("Entries d", "LEFT", array(array('e.blogid', 'eq', 'd.blogid'), array('e.id', 'eq', 'd.id'), array("d.draft", "eq", 1)));
    if (!Acl::check("group.editors", "entry.list")) {
        $pool->setQualifier("e.userid", "eq", getUserId());
    }
    $pool->setQualifier("e.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setProjection("e.*", "c.label AS categoryLabel", "d.id AS draft");
    $pool->setOrder("e.published", "DESC");
    if (!Acl::check("group.editors", "entry.list")) {
        $pool->setQualifier("e.userid", "eq", getUserId());
    }
    if ($category > 0) {
        $pool->setQualifier("e.category", "hasoneof", $categories);
    } else {
        if ($category == -3) {
            $pool->setQualifier("e.category", "eq", 0);
        } else {
            if ($category == -5) {
                $pool->setQualifier("e.category", ">=", -3);
            } else {
                if ($category == 0) {
                    $pool->setQualifier("e.category", ">=", 0);
                } else {
                    $pool->setQualifier("e.category", "eq", $category);
                }
            }
        }
    }
    if (isset($visibility)) {
        if (Validator::isInteger($visibility, 0, 3)) {
            $pool->setQualifier("e.visibility", "eq", $visibility);
        }
    }
    if (isset($starred)) {
        if (Validator::isInteger($starred, 0, 3)) {
            $pool->setQualifier("e.starred", "eq", $starred);
        }
    }
    if (!empty($search)) {
        $search = escapeSearchString($search);
        $pool->setQualifierSet(array("e.title", "like", $search, true), "OR", array("e.content", "like", $search, true));
    }
    if (!empty($tag)) {
        $pool->join("TagRelations", "left", array(array("e.id", "eq", "t.entry"), array("e.blogid", "eq", "t.blogid")));
        $pool->setAlias("TagRelations", "t");
        $pool->setQualifier("t.tag", "eq", $tag, true);
    }
    return Paging::fetch($pool, $page, $count);
}
Пример #15
0
function getCommentsWithPaging($blogid, $page, $count, $url = null, $prefix = '?page=', $postfix = '', $countItem = null)
{
    global $database;
    $comments = array();
    $sql = "SELECT r.*\n\t\tFROM\n\t\t\t{$database['prefix']}Comments r\n\t\t\tINNER JOIN {$database['prefix']}Entries e ON r.blogid = e.blogid AND r.entry = e.id AND e.draft = 0\n\t\t\tLEFT OUTER JOIN {$database['prefix']}Categories c ON e.blogid = c.blogid AND e.category = c.id\n\t\tWHERE\n\t\t\tr.blogid = {$blogid} AND e.draft = 0 AND r.parent IS NULL" . (doesHaveOwnership() ? "" : " AND e.visibility >= 2") . getPrivateCategoryExclusionQuery($blogid) . "\n\t\t\tAND r.entry > 0 AND r.isfiltered = 0\n\t\tORDER BY\n\t\t\tr.written DESC";
    list($comments, $paging) = Paging::fetch($sql, $page, $count, $url, $prefix, $countItem);
    $paging['postfix'] = $postfix;
    $comments = coverComments($comments);
    return array($comments, $paging);
}
 static function getRefererLogsWithPage($page, $count)
 {
     global $database, $blogid;
     return Paging::fetch("SELECT host, url, referred FROM {$database['prefix']}RefererLogs WHERE blogid = {$blogid} ORDER BY referred DESC", $page, $count);
 }
Пример #17
0
function MT_Cover_getRecentEntries($parameters)
{
    global $database, $blog, $service, $serviceURL, $suri, $configVal, $defaultURL, $skin;
    requireModel("blog.entry");
    requireModel("blog.tag");
    $data = Setting::fetchConfigVal($configVal);
    $data['coverMode'] = !isset($data['coverMode']) ? 1 : $data['coverMode'];
    if (Misc::isMetaBlog() != true) {
        $data['coverMode'] = 1;
    }
    $data['screenshot'] = !isset($data['screenshot']) ? 1 : $data['screenshot'];
    $data['screenshotSize'] = !isset($data['screenshotSize']) ? 90 : $data['screenshotSize'];
    $data['paging'] = !isset($data['paging']) ? '2' : $data['paging'];
    $data['contentLength'] = !isset($data['contentLength']) ? 250 : $data['contentLength'];
    if (isset($parameters['preview'])) {
        // preview mode
        $retval = '표지에 최신 글 목록을 추가합니다.';
        return htmlspecialchars($retval);
    }
    $entryLength = isset($parameters['entryLength']) ? $parameters['entryLength'] : 10;
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail", 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId())) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId());
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId(), 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/", 0777);
    }
    $page = $data['paging'] == '1' && !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $cache = new PageCache();
    $cache->name = 'MT_Cover_RecentPS';
    if ($cache->load()) {
        //If successful loads
        $cache->contents = unserialize($cache->contents);
        // If coverpage is single mode OR coverpage is coverblog and cache is not expired, return cache contents.
        if (($data['coverMode'] == 1 || $data['coverMode'] == 2) && array_key_exists($page, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 300) {
            return $cache->contents[$page];
        }
    }
    if (Misc::isMetaBlog() == true && doesHaveOwnership() && $service['type'] != 'single') {
        $visibility = 'AND e.visibility > 1 AND (c.visibility > 1 OR e.category = 0)';
    } else {
        $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 1 AND (c.visibility > 1 OR e.category = 0)';
    }
    $multiple = $data['coverMode'] == 2 ? '' : 'e.blogid = ' . getBlogId() . ' AND';
    $privateBlogId = POD::queryColumn("SELECT blogid \n\t\tFROM {$database['prefix']}BlogSettings\n\t\tWHERE name = 'visibility'\n\t\tAND value < 2");
    if (!empty($privateBlogId)) {
        $privateBlogs = ' AND e.blogid NOT IN (' . implode(',', $privateBlogId) . ')';
    } else {
        $privateBlogs = '';
    }
    list($entries, $paging) = Paging::fetch("SELECT e.blogid, e.id, e.userid, e.title, e.content, e.slogan, e.category, e.published, e.contentformatter, c.label\n\t\tFROM {$database['prefix']}Entries e\n\t\tLEFT JOIN {$database['prefix']}Categories c ON e.blogid = c.blogid AND e.category = c.id\n\t\tWHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0 {$privateBlogs}\n\t\tORDER BY published DESC", $page, $entryLength);
    $html = '';
    foreach ((array) $entries as $entry) {
        $tagLabelView = "";
        $blogid = $data['coverMode'] == 2 ? $entry['blogid'] : getBlogId();
        $entryTags = getTags($blogid, $entry['id']);
        $defaultURL = getDefaultURL($blogid);
        if (sizeof($entryTags) > 0) {
            $tags = array();
            foreach ($entryTags as $entryTag) {
                $tags[$entryTag['name']] = "<a href=\"{$defaultURL}/tag/" . (Setting::getBlogSettingGlobal('useSloganOnTag', true) ? URL::encode($entryTag['name'], $service['useEncodedURL']) : $entryTag['id']) . '">' . htmlspecialchars($entryTag['name']) . '</a>';
            }
            $tagLabelView = "<div class=\"post_tags\"><span>TAG : </span>" . implode(",\r\n", array_values($tags)) . "</div>";
        }
        if (empty($entry['category'])) {
            $entry['label'] = _text('분류없음');
            $entry['link'] = "{$defaultURL}/category";
        } else {
            $entry['link'] = "{$defaultURL}/category/" . (Setting::getBlogSettingGlobal('useSloganOnCategory', true) ? URL::encode($entry['label'], $service['useEncodedURL']) : $entry['category']);
        }
        $permalink = "{$defaultURL}/" . (Setting::getBlogSettingGlobal('useSloganOnPost', true) ? "entry/" . URL::encode($entry['slogan'], $service['useEncodedURL']) : $entry['id']);
        $html .= '<div class="coverpost">' . CRLF;
        if ($imageName = MT_Cover_getAttachmentExtract($entry['content'])) {
            if (($tempImageSrc = MT_Cover_getImageResizer($blogid, $imageName, $data['screenshotSize'])) && $data['screenshot'] == 1) {
                $html .= '<div class="img_preview"><a href="' . $permalink . '"><img src="' . $tempImageSrc . '" alt="" /></a></div>' . CRLF;
            }
        }
        $html .= '	<div class="content_box">';
        $html .= '		<h2><a href="' . $permalink . '">' . htmlspecialchars($entry['title']) . '</a></h2>' . CRLF;
        $html .= '		<div class="post_info">' . CRLF;
        $html .= '			<span class="category"><a href="' . htmlspecialchars($entry['link']) . '">' . htmlspecialchars($entry['label']) . '</a></span>' . CRLF;
        $html .= '			<span class="date">' . Timestamp::format5($entry['published']) . '</span>' . CRLF;
        $html .= '			<span class="author"><span class="preposition">by </span>' . User::getName($entry['userid']) . '</span>' . CRLF;
        $html .= '		</div>' . CRLF;
        $html .= '		<div class="post_content">' . htmlspecialchars(Utils_Unicode::lessenAsEm(removeAllTags(stripHTML($entry['content'])), $data['contentLength'])) . '</div>' . CRLF;
        $html .= $tagLabelView;
        $html .= '		<div class="clear"></div>' . CRLF;
        $html .= '	</div>';
        $html .= '</div>' . CRLF;
    }
    if ($data['paging'] == '1') {
        $paging['page'] = $page;
        $paging['total'] = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Entries e WHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0");
        $html .= getPagingView($paging, $skin->paging, $skin->pagingItem) . CRLF;
        $html .= '<script type="text/javascript">' . CRLF;
        $html .= '//<![CDATA[' . CRLF;
        if ($paging['page'] > 1) {
            $html .= 'var prevURL = "' . $paging['url'] . '?page=' . ($paging['page'] - 1) . '"' . CRLF;
        }
        if ($paging['page'] < $paging['total']) {
            $html .= 'var nextURL = "' . $paging['url'] . '?page=' . ($paging['page'] + 1) . '"' . CRLF;
        }
        $html .= '//]]>' . CRLF;
        $html .= '</script>';
    }
    $target = $html;
    $cache->contents[$page] = $target;
    $cache->contents = serialize($cache->contents);
    $cache->dbContents = Timestamp::getUNIXtime();
    $cache->update();
    unset($cache);
    return $target;
}
Пример #18
0
function getRemoteResponseLogsWithPagingForOwner($blogid, $category, $site, $ip, $search, $page, $count, $type = null)
{
    global $database;
    if (!is_null($type)) {
        $typeFilter = " AND t.responsetype = '" . POD::escapeString($type) . "'";
    } else {
        $typeFilter = '';
    }
    $postfix = '&amp;status=sent';
    $sql = "SELECT t.*, e.title AS subject, c.name AS categoryName \n\t\tFROM {$database['prefix']}RemoteResponseLogs t \n\t\tLEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0 \n\t\tLEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id \n\t\tWHERE t.blogid = {$blogid} {$typeFilter}";
    if ($category > 0) {
        $categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND parent = {$category}");
        array_push($categories, $category);
        $sql .= ' AND e.category IN (' . implode(', ', $categories) . ')';
        $postfix .= '&amp;category=' . rawurlencode($category);
    } else {
        $sql .= ' AND e.category >= 0';
    }
    if (!empty($search)) {
        $search = escapeSearchString($search);
        $sql .= " AND (e.title LIKE '%{$search}%' OR e.content LIKE '%{$search}%')";
        $postfix .= '&amp;search=' . rawurlencode($search);
    }
    $sql .= ' ORDER BY t.written DESC';
    list($responses, $paging) = Paging::fetch($sql, $page, $count);
    if (strlen($postfix) > 0) {
        $paging['postfix'] .= $postfix . '&amp;withSearch=on';
    }
    return array($responses, $paging);
}
Пример #19
0
function getLinksWithPagingForOwner($blogid, $page, $count)
{
    global $database;
    return Paging::fetch("SELECT l.*, lc.name AS categoryName\n\t\t\tFROM {$database['prefix']}Links l \n\t\t\tLEFT JOIN {$database['prefix']}LinkCategories lc ON lc.blogid = l.blogid AND lc.id = l.category\n\t\t\tWHERE l.blogid = {$blogid} ORDER BY l.name", $page, $count);
}