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); }
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")); }
function getNoticesWithPaging($blogid, $search, $page, $count) { global $database, $folderURL, $suri; $aux = ''; if ($search !== true && $search) { $search = escapeSearchString($search); $aux = "AND (title LIKE '%{$search}%' OR content LIKE '%{$search}%')"; } $visibility = doesHaveOwnership() ? '' : 'AND visibility > 1'; $sql = "SELECT * FROM {$database['prefix']}Entries WHERE blogid = {$blogid} AND draft = 0 {$visibility} AND category = -2 {$aux} ORDER BY published DESC"; return Paging::fetch($sql, $page, $count, "{$folderURL}/{$suri['value']}"); }
function getRemoteResponseList($blogid, $search, $type = null) { global $database; if (!is_null($type)) { $typeFilter = " AND responsetype = '" . POD::escapeString($type) . "'"; } else { $typeFilter = ''; } $list = array('title' => "{$search}", 'items' => array()); $search = escapeSearchString($search); $authorized = doesHaveOwnership() ? '' : getPrivateCategoryExclusionQuery($blogid); if ($result = POD::queryAll("SELECT t.id, t.entry, t.url, t.site, t.subject, t.excerpt, t.written, e.slogan\n \t\tFROM {$database['prefix']}RemoteResponses t\n\t\tLEFT JOIN {$database['prefix']}Entries e ON t.entry = e.id AND t.blogid = e.blogid AND e.draft = 0\n\t\tWHERE t.blogid = {$blogid}\n\t\t\tAND t.isfiltered = 0\n\t\t\tAND t.entry > 0 {$authorized} {$typeFilter} \n\t\t\tAND (t.excerpt like '%{$search}%' OR t.subject like '%{$search}%')")) { foreach ($result as $response) { array_push($list['items'], $response); } } return $list; }
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); }
function getSearchFeedByKeyword($blogid, $search, $mode = 'rss', $title = null) { global $database, $serviceURL, $defaultURL, $blog, $service; $channel = array(); $channel = initializeRSSchannel($blogid); $search = escapeSearchString($search); $entries = POD::queryAll("SELECT \n\t\t\te.*, \n\t\t\tc.name AS categoryName,\n\t\t\tu.name AS author,\n\t\t\tu.loginid AS email\n\t\tFROM {$database['prefix']}Entries e\n\t\tLEFT JOIN {$database['prefix']}Categories c\n\t\t\tON e.blogid = c.blogid AND e.category = c.id\n\t\tLEFT JOIN {$database['prefix']}Users u\n\t\t\tON e.userid = u.userid\n\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 AND e.visibility >= " . ($blog['publishEolinSyncOnRSS'] ? '2' : '3') . " AND c.visibility > 1 AND (e.title LIKE '%{$search}%' OR e.content LIKE '%{$search}%') \n\t\tORDER BY e.published \n\t\tDESC LIMIT {$blog['entriesOnRSS']}"); if (!$entries) { $entries = array(); } $channel['items'] = getFeedItemByEntries($entries); if (!is_null($title)) { $channel['title'] = RSSMessage($blog['title'] . ': ' . _textf('%1 이 포함된 글 목록', htmlspecialchars($title))); } $rss = array('channel' => $channel); if ($mode == 'rss') { return publishRSS($blogid, $rss); } else { if ($mode == 'atom') { return publishATOM($blogid, $rss); } } return false; }
function getFeedEntry($blogid, $group = 0, $feed = 0, $entry = 0, $unreadOnly = false, $starredOnly = false, $searchKeyword = null, $position = 'current', $markAsRead = 'read') { // if failed, return false or null. check both! global $database; $setting = getReaderSetting($blogid); $searchKeyword = escapeSearchString($searchKeyword); if ($entry == 0 || $position != 'current') { if ($starredOnly !== false) { $condition = 'AND s.item IS NOT NULL'; } else { if ($searchKeyword !== null) { $condition = "AND (i.title LIKE '%{$searchKeyword}%' OR i.description LIKE '%{$searchKeyword}%')"; } else { $condition = ''; } } $condition .= $group == 0 ? '' : " AND g.id = {$group}"; $condition .= $feed == 0 ? '' : " AND f.id = {$feed}"; $sql = "SELECT\n\t\t\t\t\t\ti.id, i.title AS entry_title, i.description, f.title AS blog_title, i.author, i.written, i.tags, i.permalink, rd.item AS wasread, f.language, enclosure\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$database['prefix']}FeedGroups g,\n\t\t\t\t\t\t{$database['prefix']}FeedGroupRelations r,\n\t\t\t\t\t\t{$database['prefix']}Feeds f,\n\t\t\t\t\t\t{$database['prefix']}FeedItems i\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$database['prefix']}FeedStarred s\n\t\t\t\t\tON\n\t\t\t\t\t\ts.blogid = {$blogid} AND\n\t\t\t\t\t\ti.id = s.item\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$database['prefix']}FeedReads rd\n\t\t\t\t\tON\n\t\t\t\t\t\trd.blogid = {$blogid} AND\n\t\t\t\t\t\ti.id = rd.item\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tr.blogid = {$blogid} AND\n\t\t\t\t\t\tr.blogid = g.blogid AND\n\t\t\t\t\t\tg.id = r.groupid AND\n\t\t\t\t\t\tr.feed = f.id AND\n\t\t\t\t\t\tf.id = i.feed\n\t\t\t\t\t\t{$condition}\n\t\t\t\t\tGROUP BY i.id, entry_title, i.description, blog_title, i.author, i.written, i.tags, i.permalink, wasread, f.language, enclosure\n\t\t\t\t\tORDER BY i.written DESC, i.id DESC"; if ($position == 'current') { if ($row = POD::queryRow("{$sql} LIMIT 1")) { $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']); $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true); } return $row; } else { $result = POD::queryAll($sql); $prevRow = null; while ($row = array_shift($result)) { if ($row['id'] == $entry) { if ($position == 'before') { while ($row = array_shift($result)) { if ($unreadOnly == false || !$row['wasread']) { break; } } if ($markAsRead == 'read') { POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$row['id']})"); } if ($row) { $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']); $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true); } return $row; } else { if ($position == 'after') { if ($markAsRead == 'read') { POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$prevRow['id']})"); } if ($prevRow) { $prevRow['description'] = adjustRelativePathImage($prevRow['description'], $row['permalink']); $prevRow['description'] = filterJavaScript($prevRow['description'], $setting['allowscript'] == 1 ? false : true); } return $prevRow; } } } if ($unreadOnly == false || !$row['wasread']) { $prevRow = $row; } } return null; } } else { POD::query("REPLACE INTO {$database['prefix']}FeedReads VALUES({$blogid}, {$entry})"); $sql = "SELECT\n\t\t\t\t\t\ti.id, i.title AS entry_title, i.description, f.title AS blog_title, i.author, i.written, i.tags, i.permalink, f.language, enclosure\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$database['prefix']}FeedGroups g,\n\t\t\t\t\t\t{$database['prefix']}FeedGroupRelations r,\n\t\t\t\t\t\t{$database['prefix']}Feeds f,\n\t\t\t\t\t\t{$database['prefix']}FeedItems i\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tr.blogid = {$blogid} AND\n\t\t\t\t\t\tr.blogid = g.blogid AND\n\t\t\t\t\t\tr.feed = f.id AND\n\t\t\t\t\t\tr.groupid = g.id AND\n\t\t\t\t\t\ti.id = {$entry} AND\n\t\t\t\t\t\tf.id = i.feed"; if ($row = POD::queryRow($sql)) { $row['description'] = adjustRelativePathImage($row['description'], $row['permalink']); $row['description'] = filterJavaScript($row['description'], $setting['allowscript'] == 1 ? false : true); } return $row; } }
function getCommentList($blogid, $search) { global $database; $list = array('title' => "{$search}", 'items' => array()); $search = escapeSearchString($search); $authorized = doesHaveOwnership() ? '' : 'AND c.secret = 0 ' . getPrivateCategoryExclusionQuery($blogid); if ($result = POD::queryAll("SELECT c.id, c.entry, c.parent, c.name, c.comment, c.written, e.slogan\n\t\tFROM {$database['prefix']}Comments c\n\t\tINNER JOIN {$database['prefix']}Entries e ON c.entry = e.id AND c.blogid = e.blogid AND e.draft = 0\n\t\tWHERE c.entry > 0\n\t\t\tAND c.blogid = {$blogid} {$authorized}\n\t\t\tAND c.isfiltered = 0\n\t\t\tAND (c.comment like '%{$search}%' OR c.name like '%{$search}%')\n\t\tORDER BY c.written")) { foreach ($result as $comment) { array_push($list['items'], $comment); } } return $list; }
function getCommentList($blogid, $search) { $list = array('title' => "{$search}", 'items' => array()); $search = escapeSearchString($search); $context = Model_Context::getInstance(); $pool = DBModel::getInstance(); $pool->reset('Comments'); $pool->setAlias("Comments", "c"); $pool->setAlias("Entries", "e"); $pool->join("Entries", "inner", array(array("c.entry", "eq", "e.id"), array("c.blogid", "eq", "e.blogid"), array("e.draft", "eq", 0))); $pool->setQualifier('c.blogid', 'eq', $blogid); $pool->setQualifier('c.entry', '>', 0); $pool->setQualifier('parent', 'eq', NULL); $pool->setQualifier('isfiltered', 'eq', 0); $pool->setQualifierSet(array("c.comment", "like", $search, true), "OR", array("c.name", "like", $search, true)); if (doesHaveOwnership()) { $pool->setQualifier("c.secret", "eq", 0); $pool = getPrivateCategoryExclusionQualifier($pool, $blogid); } $pool->setOrder("c.written", "asc"); if ($entry == 0) { $pool->setOrder('written', 'desc'); } else { if ($order == 'DESC') { $pool->setOrder('id', 'desc'); } else { $pool->setOrder('id', 'asc'); } } if ($result = $pool->getAll()) { $comments = coverComments($result); } if ($result = $pool->getAll("c.id, c.entry, c.parent, c.name, c.comment, c.written, e.slogan")) { foreach ($result as $comment) { array_push($list['items'], $comment); } } return $list; }
function getRemoteResponseList($blogid, $search, $type = null) { $pool = DBModel::getInstance(); $list = array('title' => "{$search}", 'items' => array()); $pool->init("RemoteResponses"); $pool->setAlias("RemoteResponses", "t"); $pool->setAlias("Entries", "e"); $pool->join("Entries", "left", array(array("t.entry", "eq", "e.id"), array("t.blogid", "eq", "e.blogid"), array("e.draft", "eq", 0))); $pool->setQualifier("t.blogid", "eq", $blogid); $pool->setQualifier("t.isfiltered", "eq", 0); $pool->setQualifier("t.entry", ">", 0); if (doesHaveOwnership()) { $pool = getPrivateCategoryExclusionQualifier($pool, $blogid); } if (!is_null($type)) { $pool->setQualifier("responsetype", "eq", $type, true); } if (!empty($search)) { $search = escapeSearchString($search); $pool->setQualifierSet(array("t.excerpt", "like", $search, true), "OR", array("t.subject", "like", $search, true)); } if ($result = $pool->getAll("t.id, t.entry, t.url, t.site, t.subject, t.excerpt, t.written, e.slogan")) { foreach ($result as $response) { array_push($list['items'], $response); } } return $list; }
?> <?php } else { ?> <center><strong>No Record Found.</strong></center> <?php echo "0"; } } else { $searchTerm = isset($_GET) && isset($_GET['term']) ? sanitize_string(trim($_GET['term'])) : ''; //echo 'else';print_r($_GET); //$searchTerm = str_replace("/","",sanitize_string($searchTerm)); $searchTerm = escapeSearchString($searchTerm); //$searchTerm = Slug($searchTerm); //$searchTerm = mysql_real_escape_string(str_replace(array('_', '%'), array('\_', '\%'),$searchTerm )); /*if(preg_match('/'.preg_quote('^\'£$%^&*()}{@#~?><,@|-=-_+-¬', '/').'/', $searchTerm)) { $_SESSION['msgType'] = array('from'=>'user', 'type'=>'error', 'var'=>"multiple",'val'=>"No project found."); redirect($base_url.'index.php'); }*/ $perpage = 6; if (isset($searchTerm) && $searchTerm != '') { $extra = ''; if (!isset($_GET) || isset($_GET['page']) && $_GET['page'] == '') { $page = 1; } else { $page = isset($_GET) && isset($_GET['page']) ? $_GET['page'] : 1; }
function getSearchFeedByKeyword($blogid, $search, $mode = 'rss', $title = null) { $context = Model_Context::getInstance(); $channel = array(); $channel = initializeRSSchannel($blogid); $search = escapeSearchString($search); $pool = DBModel::getInstance(); $pool->reset("Entries"); $pool->setAlias("Entries", "e"); $pool->setAlias("Categories", "c"); $pool->setAlias("Users", "u"); $pool->extend("Categories", "left", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id"))); $pool->extend("Users", "left", array(array("e.userid", "eq", "u.userid"))); $pool->setQualifier("e.blogid", "eq", $blogid); $pool->setQualifier("e.draft", "eq", 0); $pool->setQualifier("e.visibility", ">=", $context->getProperty('blog.publishEolinSyncOnRSS') ? 2 : 3); $pool->setQualifier("c.visibility", ">", 1); $pool->setQualifierSet(array("e.title", "like", $search, true), "OR", array("e.content", "like", $search, true)); $pool->setOrder("e.published", "desc"); $pool->setLimit($context->getProperty('blog.entriesOnRSS')); $entries = $pool->getAll("e.*,c.name AS categoryName, u.name as author, u.loginid AS email"); if (!$entries) { $entries = array(); } return getFeedWithEntries($blogid, $entries, _textf('%1 이 포함된 글 목록', $title), $mode); }
function flushSearchKeywordRSS($search = null) { global $database; if (empty($search)) { $search = ''; } else { $search = escapeSearchString($search); } $searchEntries = POD::queryColumn("SELECT name\n\t\t\tFROM {$database['prefix']}PageCacheLog\n\t\t\tWHERE blogid = " . getBlogId() . "\n\t\t\tAND (name like 'searchATOM-" . $search . "%'\n\t\t\t\tOR name like 'searchRSS-" . $search . "%')"); if (!empty($searchEntries)) { CacheControl::purgeItems($searchEntries); } return true; }
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); }
function getSearchFeedByKeyword($blogid, $search, $mode = 'rss', $title = null) { $ctx = Model_Context::getInstance(); $channel = array(); $channel = initializeRSSchannel($blogid); $search = escapeSearchString($search); $entries = POD::queryAll("SELECT \n\t\t\te.*, \n\t\t\tc.name AS categoryName,\n\t\t\tu.name AS author,\n\t\t\tu.loginid AS email\n\t\tFROM " . $ctx->getProperty('database.prefix') . "Entries e\n\t\tLEFT JOIN " . $ctx->getProperty('database.prefix') . "Categories c\n\t\t\tON e.blogid = c.blogid AND e.category = c.id\n\t\tLEFT JOIN " . $ctx->getProperty('database.prefix') . "Users u\n\t\t\tON e.userid = u.userid\n\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 AND e.visibility >= " . ($ctx->getProperty('blog.publishEolinSyncOnRSS') ? '2' : '3') . " AND c.visibility > 1 AND (e.title LIKE '%{$search}%' OR e.content LIKE '%{$search}%') \n\t\tORDER BY e.published \n\t\tDESC LIMIT " . $ctx->getProperty('blog.entriesOnRSS')); if (!$entries) { $entries = array(); } return getFeedWithEntries($blogid, $entries, _textf('%1 이 포함된 글 목록', $title), $mode); }