本文整理汇总了PHP中COM_getTopicSQL函数的典型用法代码示例。如果您正苦于以下问题:PHP COM_getTopicSQL函数的具体用法?PHP COM_getTopicSQL怎么用?PHP COM_getTopicSQL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了COM_getTopicSQL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($p1, $p2, $fulltag)
{
global $_TABLES, $_CONF;
$topic = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($p1) . "'" . COM_getTopicSQL('AND'));
if (empty($topic)) {
return "<b>Unknown Topic</b>";
}
if (!empty($p2) && $p2 != $p1) {
$topic = $p2;
} else {
$topic = $topic;
}
return '<a href="' . $_CONF['site_url'] . '/index.php?topic=' . urlencode($p1) . '">' . htmlspecialchars($topic) . '</a>';
}
示例2: handleView
/**
* Handles a comment view request
*
* @copyright Vincent Furia 2005
* @author Vincent Furia, vinny01 AT users DOT sourceforge DOT net
* @param boolean $view View or display (true for view)
* @return string HTML (possibly a refresh)
*/
function handleView($view = true)
{
global $_CONF, $_TABLES, $_USER, $LANG_ACCESS;
$display = '';
if ($view) {
$cid = COM_applyFilter($_REQUEST['cid'], true);
} else {
$cid = COM_applyFilter($_REQUEST['pid'], true);
}
if ($cid <= 0) {
return COM_refresh($_CONF['site_url'] . '/index.php');
}
$sql = "SELECT sid, title, type FROM {$_TABLES['comments']} WHERE cid = {$cid}";
$A = DB_fetchArray(DB_query($sql));
$sid = $A['sid'];
$title = $A['title'];
$type = $A['type'];
$format = $_CONF['comment_mode'];
if (isset($_REQUEST['format'])) {
$format = COM_applyFilter($_REQUEST['format']);
}
if ($format != 'threaded' && $format != 'nested' && $format != 'flat') {
if (COM_isAnonUser()) {
$format = $_CONF['comment_mode'];
} else {
$format = DB_getItem($_TABLES['usercomment'], 'commentmode', "uid = {$_USER['uid']}");
}
}
switch ($type) {
case 'article':
$sql = 'SELECT COUNT(*) AS count, commentcode, owner_id, group_id, perm_owner, perm_group, ' . "perm_members, perm_anon FROM {$_TABLES['stories']} WHERE (sid = '{$sid}') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW())' . COM_getPermSQL('AND') . COM_getTopicSQL('AND') . ' GROUP BY sid,owner_id, group_id, perm_owner, perm_group,perm_members, perm_anon ';
$result = DB_query($sql);
$B = DB_fetchArray($result);
$allowed = $B['count'];
if ($allowed == 1) {
$delete_option = SEC_hasRights('story.edit') && SEC_hasAccess($B['owner_id'], $B['group_id'], $B['perm_owner'], $B['perm_group'], $B['perm_members'], $B['perm_anon']) == 3;
$order = '';
if (isset($_REQUEST['order'])) {
$order = COM_applyFilter($_REQUEST['order']);
}
$page = 0;
if (isset($_REQUEST['page'])) {
$page = COM_applyFilter($_REQUEST['page'], true);
}
$display .= CMT_userComments($sid, $title, $type, $order, $format, $cid, $page, $view, $delete_option, $B['commentcode']);
} else {
$display .= COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG_ACCESS['storydenialmsg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
}
break;
default:
// assume plugin
$order = '';
if (isset($_REQUEST['order'])) {
$order = COM_applyFilter($_REQUEST['order']);
}
$page = 0;
if (isset($_REQUEST['page'])) {
$page = COM_applyFilter($_REQUEST['page'], true);
}
if (!($display = PLG_displayComment($type, $sid, $cid, $title, $order, $format, $page, $view))) {
return COM_refresh($_CONF['site_url'] . '/index.php');
}
break;
}
return COM_siteHeader('menu', $title) . COM_showMessageFromParameter() . $display . COM_siteFooter();
}
示例3: phpblock_storypicker
function phpblock_storypicker()
{
global $_TABLES, $_CONF, $topic;
$LANG_STORYPICKER = array('choose' => 'Choose a story');
$max_stories = 5;
//how many stories to display in the list
$topicsql = '';
$sid = '';
if (isset($_GET['story'])) {
$sid = COM_applyFilter($_GET['story']);
$stopic = DB_getItem($_TABLES['stories'], 'tid', 'sid = \'' . DB_escapeString($sid) . '\'');
if (!empty($stopic)) {
$topic = $stopic;
} else {
$sid = '';
}
}
if (empty($topic)) {
if (isset($_GET['topic'])) {
$topic = COM_applyFilter($_GET['topic']);
} elseif (isset($_POST['topic'])) {
$topic = COM_applyFilter($_POST['topic']);
} else {
$topic = '';
}
}
if (!empty($topic)) {
$topicsql = " AND tid = '" . DB_escapeString($topic) . "'";
}
if (empty($topicsql)) {
$topic = DB_getItem($_TABLES['topics'], 'tid', 'archive_flag = 1');
if (empty($topic)) {
$topicsql = '';
} else {
$topicsql = " AND tid <> '" . DB_escapeString($topic) . "'";
}
}
$sql = 'SELECT sid, title FROM ' . $_TABLES['stories'] . ' WHERE draft_flag = 0 AND date <= now()' . COM_getPermSQL(' AND') . COM_getTopicSQL(' AND') . $topicsql . ' ORDER BY date DESC LIMIT ' . $max_stories;
$res = DB_query($sql);
$list = '';
while ($A = DB_fetchArray($res)) {
$url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
$list .= '<li><a href=' . $url . '>' . htmlspecialchars(COM_truncate($A['title'], 41, '...')) . "</a></li>\n";
}
return $list;
}
示例4: MODERATE_itemList
/**
* Displays items needing moderation
*
* Displays the moderation list of items from the submission tables
*
* @type string Type of object to build list for
*
*/
function MODERATE_itemList($type = '', $token)
{
global $_CONF, $_TABLES, $LANG01, $LANG24, $LANG29, $LANG_ADMIN, $_IMAGE_TYPE;
$retval = '';
if (empty($type)) {
COM_errorLog("Submissions Error: Attempted to generate a moderation list for a null item type.");
} else {
switch ($type) {
case 'user':
// user -----------------------------------------------
$result = DB_query("SELECT uid,username,fullname,email,UNIX_TIMESTAMP(regdate) AS day FROM {$_TABLES['users']} WHERE status = 2");
$nrows = DB_numRows($result);
if ($nrows > 0) {
$data_arr = array();
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$A['edit'] = $_CONF['site_admin_url'] . '/user.php?edit=x&uid=' . $A['uid'];
$A['fullname'] = $A['fullname'];
$A['email'] = $A['email'];
$A['_type_'] = 'user';
$A['_key_'] = 'uid';
$data_arr[$i] = $A;
}
$header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 0, 'align' => 'center', 'width' => '25px'), array('text' => $LANG29[16], 'field' => 1, 'nowrap' => true), array('text' => $LANG29[17], 'field' => 2), array('text' => $LANG29[18], 'field' => 3, 'nowrap' => true), array('text' => $LANG29[47], 'field' => 4, 'align' => 'center'), array('text' => $LANG29[1], 'field' => 'approve', 'align' => 'center', 'width' => '35px'), array('text' => $LANG_ADMIN['delete'], 'field' => 'delete', 'align' => 'center', 'width' => '35px'));
$text_arr = array('has_menu' => false, 'title' => $LANG29[40], 'help_url' => 'ccusersubmission.html', 'no_data' => '', 'form_url' => "{$_CONF['site_admin_url']}/moderation.php");
$actions = '<input name="approve" type="image" src="' . $_CONF['layout_url'] . '/images/admin/accept.' . $_IMAGE_TYPE . '" style="vertical-align:bottom;" title="' . $LANG29[44] . '" onclick="return confirm(\'' . $LANG29[45] . '\');"' . '/> ' . $LANG29[1];
$actions .= ' ';
$actions .= '<input name="delbutton" type="image" src="' . $_CONF['layout_url'] . '/images/admin/delete.' . $_IMAGE_TYPE . '" style="vertical-align:text-bottom;" title="' . $LANG01[124] . '" onclick="return confirm(\'' . $LANG01[125] . '\');"' . '/> ' . $LANG_ADMIN['delete'];
$options = array('chkselect' => true, 'chkfield' => 'uid', 'chkname' => 'selitem', 'chkminimum' => 0, 'chkall' => false, 'chkactions' => $actions);
$form_arr['bottom'] = '<input type="hidden" name="type" value="user"/>' . LB . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>' . LB . '<input type="hidden" name="moderation" value="x"/>' . LB . '<input type="hidden" name="count" value="' . $nrows . '"/>';
$retval = ADMIN_simpleList('MODERATE_getListField', $header_arr, $text_arr, $data_arr, $options, $form_arr, $token);
}
break;
case 'draftstory':
// draft story ----------------------------------
$result = DB_query("SELECT sid AS id,title,UNIX_TIMESTAMP(date) AS day,tid,uid FROM {$_TABLES['stories']} WHERE (draft_flag = 1)" . COM_getTopicSQL('AND') . COM_getPermSQL('AND', 0, 3) . " ORDER BY date ASC");
$nrows = DB_numRows($result);
if ($nrows > 0) {
$data_arr = array();
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$A['edit'] = $_CONF['site_admin_url'] . '/story.php?draft=x&sid=' . $A['id'];
$A['title'] = $A['title'];
$A['tid'] = $A['tid'];
$A['_type_'] = 'draftstory';
$A['_key_'] = 'sid';
$data_arr[$i] = $A;
}
$header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 0, 'align' => 'center', 'width' => '25px'), array('text' => $LANG29[10], 'field' => 'title'), array('text' => $LANG29[14], 'field' => 'day', 'align' => 'center', 'width' => '15%'), array('text' => $LANG29[15], 'field' => 'tid', 'width' => '20%'), array('text' => $LANG29[46], 'field' => 'uid', 'width' => '15%', 'nowrap' => true), array('text' => $LANG29[1], 'field' => 'approve', 'align' => 'center', 'width' => '35px'), array('text' => $LANG_ADMIN['delete'], 'field' => 'delete', 'align' => 'center', 'width' => '35px'));
$text_arr = array('has_menu' => false, 'title' => $LANG29[35] . ' (' . $LANG24[34] . ')', 'help_url' => '', 'no_data' => $LANG29[39], 'form_url' => "{$_CONF['site_admin_url']}/moderation.php");
$actions = '<input name="approve" type="image" src="' . $_CONF['layout_url'] . '/images/admin/accept.' . $_IMAGE_TYPE . '" style="vertical-align:bottom;" title="' . $LANG29[44] . '" onclick="return confirm(\'' . $LANG29[45] . '\');"' . '/> ' . $LANG29[1];
$actions .= ' ';
$actions .= '<input name="delbutton" type="image" src="' . $_CONF['layout_url'] . '/images/admin/delete.' . $_IMAGE_TYPE . '" style="vertical-align:text-bottom;" title="' . $LANG01[124] . '" onclick="return confirm(\'' . $LANG01[125] . '\');"' . '/> ' . $LANG_ADMIN['delete'];
$options = array('chkselect' => true, 'chkfield' => 'id', 'chkname' => 'selitem', 'chkminimum' => 0, 'chkall' => false, 'chkactions' => $actions);
$form_arr['bottom'] = '<input type="hidden" name="type" value="draftstory"/>' . LB . '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"/>' . LB . '<input type="hidden" name="count" value="' . $nrows . '"/>';
$retval .= ADMIN_simpleList('MODERATE_getListField', $header_arr, $text_arr, $data_arr, $options, $form_arr, $token);
}
break;
// draftstory
// draftstory
default:
// plugin -------------------------------------------------
$function = 'plugin_itemlist_' . $type;
if (function_exists($function)) {
$plugin = new Plugin();
$plugin = $function($token);
// if the plugin returns a string, it wants to control it's own
// moderation. as far as I can tell - no plugin has used this yet
// it appears to be a feature that was added in glFusion 1.1.0rc1
// but never actually used
if (is_string($plugin) && !empty($plugin)) {
return '<div class="block-box">' . $plugin . '</div>';
// otherwise this is a plugin object (historical approach)
} elseif (is_object($plugin)) {
$helpfile = $plugin->submissionhelpfile;
$sql = $plugin->getsubmissionssql;
$H = $plugin->submissionheading;
$section_title = $plugin->submissionlabel;
$section_help = $helpfile;
$isplugin = true;
}
}
// this needs to be removed when story moves into a plugin
if ($type == 'story') {
$isplugin = false;
}
// we really only need the id from this list, so that we know key/id field name
list($key, $table, $fields, $submissiontable) = PLG_getModerationValues($type);
// the first 4 columns default to Title, Date, Topic and Submitted By unless otherwise
// specified. not sure I like this approach - but whatever - it's not
// breaking anything at the momemnt
if (!isset($H[0]) || empty($H[0])) {
//.........这里部分代码省略.........
示例5: _searchStories
/**
* Performs search on all stories
*
* @return object plugin object
*
*/
private function _searchStories()
{
global $_TABLES, $_DB_dbms, $LANG09;
// Make sure the query is SQL safe
$query = trim(DB_escapeString($this->_query));
$sql = 'SELECT s.sid AS id, s.title AS title, s.introtext AS description, ';
$sql .= 'UNIX_TIMESTAMP(s.date) AS date, s.uid AS uid, s.hits AS hits, ';
$sql .= 'CONCAT(\'/article.php?story=\',s.sid) AS url ';
$sql .= 'FROM ' . $_TABLES['stories'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topic_assignments'] . ' AS ta ';
$sql .= 'WHERE (draft_flag = 0) AND (date <= NOW()) AND (u.uid = s.uid) ';
$sql .= 'AND ta.type = \'article\' AND ta.id = sid ';
$sql .= COM_getPermSQL('AND') . COM_getTopicSQL('AND', 0, 'ta') . COM_getLangSQL('sid', 'AND') . ' ';
if (!empty($this->_topic)) {
// Retrieve list of inherited topics
if ($this->_topic == TOPIC_ALL_OPTION) {
// Stories do not have an all option so just return all stories that meet the requirements and permissions
//$sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$this->_topic."')) ";
} else {
$tid_list = TOPIC_getChildList($this->_topic);
$sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '" . $this->_topic . "'))) ";
}
}
if (!empty($this->_author)) {
$sql .= 'AND (s.uid = \'' . $this->_author . '\') ';
}
$search_s = new SearchCriteria('stories', $LANG09[65]);
$columns = array('title' => 'title', 'introtext', 'bodytext');
$sql .= $search_s->getDateRangeSQL('AND', 'date', $this->_dateStart, $this->_dateEnd);
list($sql, $ftsql) = $search_s->buildSearchSQL($this->_keyType, $query, $columns, $sql);
$sql .= " GROUP BY s.sid";
$search_s->setSQL($sql);
$search_s->setFTSQL($ftsql);
$search_s->setRank(5);
$search_s->setURLRewrite(true);
// Search Story Comments
$sql = 'SELECT c.cid AS id, c.title AS title, c.comment AS description, ';
$sql .= 'UNIX_TIMESTAMP(c.date) AS date, c.uid AS uid, \'0\' AS hits, ';
// MSSQL has a problem when concatenating numeric values
if ($_DB_dbms == 'mssql') {
$sql .= '\'/comment.php?mode=view&cid=\' + CAST(c.cid AS varchar(10)) AS url ';
} else {
$sql .= 'CONCAT(\'/comment.php?mode=view&cid=\',c.cid) AS url ';
}
$sql .= 'FROM ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topic_assignments'] . ' AS ta, ' . $_TABLES['comments'] . ' AS c ';
$sql .= 'LEFT JOIN ' . $_TABLES['stories'] . ' AS s ON ((s.sid = c.sid) ';
$sql .= COM_getPermSQL('AND', 0, 2, 's') . COM_getLangSQL('sid', 'AND', 's') . ') ';
$sql .= 'WHERE (u.uid = c.uid) AND (s.draft_flag = 0) AND (s.commentcode >= 0) AND (s.date <= NOW()) ';
$sql .= 'AND ta.type = \'article\' AND ta.id = s.sid ' . COM_getTopicSQL('AND', 0, 'ta');
if (!empty($this->_topic)) {
if ($this->_topic == TOPIC_ALL_OPTION) {
// Stories do not have an all option so just return all story comments that meet the requirements and permissions
//$sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$this->_topic."')) ";
} else {
$sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '" . $this->_topic . "'))) ";
}
}
if (!empty($this->_author)) {
$sql .= 'AND (c.uid = \'' . $this->_author . '\') ';
}
$search_c = new SearchCriteria('comments', array($LANG09[65], $LANG09[66]));
$columns = array('title' => 'c.title', 'comment');
$sql .= $search_c->getDateRangeSQL('AND', 'c.date', $this->_dateStart, $this->_dateEnd);
list($sql, $ftsql) = $search_c->buildSearchSQL($this->_keyType, $query, $columns, $sql);
$sql .= " GROUP BY id";
$search_c->setSQL($sql);
$search_c->setFTSQL($ftsql);
$search_c->setRank(2);
return array($search_s, $search_c);
}
示例6: plugin_displaycomment_article
/**
* article: display [a] comment[s]
*
* @param string $id Unique idenifier for item comment belongs to
* @param int $cid Comment id to display (possibly including sub-comments)
* @param string $title Page/comment title
* @param string $order 'ASC' or 'DESC' or blank
* @param string $format 'threaded', 'nested', or 'flat'
* @param int $page Page number of comments to display
* @param boolean $view True to view comment (by cid), false to display (by $pid)
* @return mixed results of calling the plugin_displaycomment_ function
*/
function plugin_displaycomment_article($id, $cid, $title, $order, $format, $page, $view)
{
global $_TABLES, $LANG_ACCESS;
$retval = '';
$sql = 'SELECT COUNT(*) AS count, commentcode, owner_id, group_id, perm_owner, perm_group, ' . "perm_members, perm_anon FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta WHERE (sid = '{$id}') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW()) AND ta.type = "article" AND ta.id = sid ' . COM_getPermSQL('AND') . COM_getTopicSQL('AND', 0, 'ta') . ' GROUP BY sid, owner_id, group_id, perm_owner, perm_group,perm_members, perm_anon ';
$result = DB_query($sql);
$A = DB_fetchArray($result);
$allowed = $A['count'];
if ($allowed > 0) {
// Was equal 1 but when multiple topics in play the comment could belong to more than onetopic creating a higher count
$delete_option = SEC_hasRights('story.edit') && SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3;
$retval .= CMT_userComments($id, $title, 'article', $order, $format, $cid, $page, $view, $delete_option, $A['commentcode']);
} else {
$retval .= COM_showMessageText($LANG_ACCESS['storydenialmsg'], $LANG_ACCESS['accessdenied']);
}
return $retval;
}
示例7: COM_olderStuff
/**
* Creates older stuff block
*
* Creates the olderstuff block for display.
* Actually updates the olderstuff record in the gl_blocks database.
* @return void
*/
function COM_olderStuff()
{
global $_TABLES, $_CONF;
$sql['mysql'] = "SELECT sid,tid,title,comments,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
$sql['mssql'] = "SELECT sid,tid,title,comments,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
$sql['pgsql'] = "SELECT sid,tid,title,comments,date_part('epoch',date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
$result = DB_query($sql);
$nrows = DB_numRows($result);
if ($nrows > 0) {
$dateonly = $_CONF['dateonly'];
if (empty($dateonly)) {
$dateonly = '%d-%b';
// fallback: day - abbrev. month name
}
$day = 'noday';
$string = '';
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$daycheck = strftime('%A', $A['day']);
if ($day != $daycheck) {
if ($day != 'noday') {
$daylist = COM_makeList($oldnews, 'list-older-stories');
$daylist = preg_replace("/(\r\n)|(\r)|(\n)/", '', $daylist);
$string .= $daylist . '<br' . XHTML . '>';
}
$day2 = strftime($dateonly, $A['day']);
$string .= '<h3>' . $daycheck . ' <small>' . $day2 . '</small></h3>' . LB;
$oldnews = array();
$day = $daycheck;
}
$oldnews_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
$oldnews[] = COM_createLink($A['title'], $oldnews_url) . ' (' . COM_numberFormat($A['comments']) . ')';
}
if (!empty($oldnews)) {
$daylist = COM_makeList($oldnews, 'list-older-stories');
$daylist = preg_replace("/(\r\n)|(\r)|(\n)/", '', $daylist);
$string .= $daylist;
$string = addslashes($string);
DB_query("UPDATE {$_TABLES['blocks']} SET content = '{$string}' WHERE name = 'older_stories'");
}
}
}
示例8: _searchStories
/**
* Performs search on all stories
*
* @access private
* @return object plugin object
*
*/
function _searchStories()
{
global $_TABLES, $_DB_dbms, $LANG09;
// Make sure the query is SQL safe
$query = trim(addslashes($this->_query));
$sql = 'SELECT s.sid AS id, s.title AS title, s.introtext AS description, ';
$sql .= 'UNIX_TIMESTAMP(s.date) AS date, s.uid AS uid, s.hits AS hits, ';
$sql .= 'CONCAT(\'/article.php?story=\',s.sid) AS url ';
$sql .= 'FROM ' . $_TABLES['stories'] . ' AS s, ' . $_TABLES['users'] . ' AS u ';
$sql .= 'WHERE (draft_flag = 0) AND (date <= NOW()) AND (u.uid = s.uid) ';
$sql .= COM_getPermSQL('AND') . COM_getTopicSQL('AND') . COM_getLangSQL('sid', 'AND') . ' ';
if (!empty($this->_topic)) {
$sql .= 'AND (s.tid = \'' . $this->_topic . '\') ';
}
if (!empty($this->_author)) {
$sql .= 'AND (s.uid = \'' . $this->_author . '\') ';
}
$search_s = new SearchCriteria('stories', $LANG09[65]);
$columns = array('title' => 'title', 'introtext', 'bodytext');
$sql .= $search_s->getDateRangeSQL('AND', 'date', $this->_dateStart, $this->_dateEnd);
list($sql, $ftsql) = $search_s->buildSearchSQL($this->_keyType, $query, $columns, $sql);
$search_s->setSQL($sql);
$search_s->setFTSQL($ftsql);
$search_s->setRank(5);
$search_s->setURLRewrite(true);
// Search Story Comments
$sql = 'SELECT c.cid AS id, c.title AS title, c.comment AS description, ';
$sql .= 'UNIX_TIMESTAMP(c.date) AS date, c.uid AS uid, ';
// MSSQL has a problem when concatenating numeric values
if ($_DB_dbms == 'mssql') {
$sql .= '\'/comment.php?mode=view&cid=\' + CAST(c.cid AS varchar(10)) AS url ';
} else {
$sql .= 'CONCAT(\'/comment.php?mode=view&cid=\',c.cid) AS url ';
}
$sql .= 'FROM ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['comments'] . ' AS c ';
$sql .= 'LEFT JOIN ' . $_TABLES['stories'] . ' AS s ON ((s.sid = c.sid) ';
$sql .= COM_getPermSQL('AND', 0, 2, 's') . COM_getTopicSQL('AND', 0, 's') . COM_getLangSQL('sid', 'AND', 's') . ') ';
$sql .= 'WHERE (u.uid = c.uid) AND (s.draft_flag = 0) AND (s.commentcode >= 0) AND (s.date <= NOW()) ';
if (!empty($this->_topic)) {
$sql .= 'AND (s.tid = \'' . $this->_topic . '\') ';
}
if (!empty($this->_author)) {
$sql .= 'AND (c.uid = \'' . $this->_author . '\') ';
}
$search_c = new SearchCriteria('comments', array($LANG09[65], $LANG09[66]));
$columns = array('title' => 'c.title', 'comment');
$sql .= $search_c->getDateRangeSQL('AND', 'c.date', $this->_dateStart, $this->_dateEnd);
list($sql, $ftsql) = $search_c->buildSearchSQL($this->_keyType, $query, $columns, $sql);
$search_c->setSQL($sql);
$search_c->setFTSQL($ftsql);
$search_c->setRank(2);
return array($search_s, $search_c);
}
示例9: COM_showMessageText
$pageBody .= COM_showMessageText($LANG03[7] . $last . $LANG03[8] . $goBack, $LANG12[26], true, 'error');
} else {
$sid = isset($_REQUEST['sid']) ? COM_sanitizeID(COM_applyFilter($_REQUEST['sid'])) : '';
$type = isset($_REQUEST['type']) ? COM_applyFilter($_REQUEST['type']) : '';
$title = isset($_REQUEST['title']) ? strip_tags($_REQUEST['title']) : '';
$postmode = $_CONF['comment_postmode'];
$pid = isset($_REQUEST['pid']) ? COM_applyFilter($_REQUEST['pid'], true) : 0;
if ($type != 'article') {
if (!in_array($type, $_PLUGINS)) {
$type = '';
}
}
if (!empty($sid) && !empty($type)) {
if (empty($title)) {
if ($type == 'article') {
$title = DB_getItem($_TABLES['stories'], 'title', "sid = '" . DB_escapeString($sid) . "'" . COM_getPermSQL('AND') . COM_getTopicSQL('AND'));
}
// CMT_commentForm expects non-htmlspecial chars for title...
$title = str_replace('&', '&', $title);
$title = str_replace('"', '"', $title);
$title = str_replace('<', '<', $title);
$title = str_replace('>', '>', $title);
}
if (isset($_CONF['comment_engine']) && $_CONF['comment_engine'] != 'internal') {
$pageBody = PLG_displayComment($type, $sid, 0, $title, '', 'nobar', 0, 0);
} else {
$outputHandle = outputHandler::getInstance();
$outputHandle->addMeta('name', 'robots', 'noindex');
$pageBody .= PLG_displayComment($type, $sid, 0, $title, '', 'nobar', 0, 0) . CMT_commentForm($title, '', $sid, $pid, $type, $mode, $postmode);
}
} else {
示例10: plugin_displaycomment_article
/**
* article: display comment(s)
*
* @param string $id Unique idenifier for item comment belongs to
* @param int $cid Comment id to display (possibly including sub-comments)
* @param string $title Page/comment title
* @param string $order 'ASC' or 'DESC' or blank
* @param string $format 'threaded', 'nested', or 'flat'
* @param int $page Page number of comments to display
* @param boolean $view True to view comment (by cid), false to display (by $pid)
* @return mixed results of calling the plugin_displaycomment_ function
*/
function plugin_displaycomment_article($id, $cid, $title, $order, $format, $page, $view)
{
global $_CONF, $_TABLES, $LANG_ACCESS;
USES_lib_story();
USES_class_story();
$retval = '';
// display story
$sql = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . "u.uid, u.username, u.fullname, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s LEFT JOIN {$_TABLES['users']} AS u ON s.uid=u.uid " . "LEFT JOIN {$_TABLES['topics']} AS t on s.tid=t.tid " . "WHERE (sid = '" . DB_escapeString($id) . "') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW())' . COM_getPermSQL('AND', 0, 2, 's') . COM_getTopicSQL('AND', 0, 't') . ' GROUP BY sid,owner_id, group_id, perm_owner, s.perm_group,s.perm_members, s.perm_anon ';
$result = DB_query($sql);
$nrows = DB_numRows($result);
if ($A = DB_fetchArray($result)) {
$story = new Story();
$story->loadFromArray($A);
$retval .= STORY_renderArticle($story, 'n');
}
// end
$sql = 'SELECT COUNT(*) AS count, commentcode, uid, owner_id, group_id, perm_owner, perm_group, ' . "perm_members, perm_anon FROM {$_TABLES['stories']} " . "WHERE (sid = '" . DB_escapeString($id) . "') " . 'AND (draft_flag = 0) AND (commentcode >= 0) AND (date <= NOW())' . COM_getPermSQL('AND') . COM_getTopicSQL('AND') . ' GROUP BY sid,owner_id, group_id, perm_owner, perm_group,perm_members, perm_anon ';
$result = DB_query($sql);
$B = DB_fetchArray($result);
$allowed = $B['count'];
if ($allowed == 1) {
$delete_option = SEC_hasRights('story.edit') && SEC_hasAccess($B['owner_id'], $B['group_id'], $B['perm_owner'], $B['perm_group'], $B['perm_members'], $B['perm_anon']) == 3;
$retval .= CMT_userComments($id, $title, 'article', $order, $format, $cid, $page, $view, $delete_option, $B['commentcode'], $B['uid']);
} else {
$retval .= COM_showMessageText($LANG_ACCESS['storydenialmsg'], $LANG_ACCESS['accessdenied'], true);
}
return $retval;
}
示例11: COM_olderStuff
/**
* Creates older stuff block
*
* Creates the olderstuff block for display.
* Actually updates the olderstuff record in the blocks table.
* @return void
*/
function COM_olderStuff()
{
global $_TABLES, $_CONF;
$sql = "SELECT sid,tid,title,comments,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
$result = DB_query($sql);
$nrows = DB_numRows($result);
if ($nrows > 0) {
$dateonly = $_CONF['dateonly'];
if (empty($dateonly)) {
$dateonly = 'd-M';
// fallback: day - abbrev. month name
}
$day = 'noday';
$string = '';
$dt = new Date();
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$dt->setTimestamp($A['day']);
$daycheck = $dt->format("z", true);
if ($day != $daycheck) {
if ($day != 'noday') {
$daylist = COM_makeList($oldnews, 'list-older-stories');
$daylist = str_replace(array("\r", "\n"), '', $daylist);
$string .= $daylist;
// . '<br/>';
}
$day2 = $dt->format($_CONF['dateonly'], true);
$string .= '<h3>' . $dt->format('l', true) . ' <small>' . $day2 . '</small></h3>' . LB;
$oldnews = array();
$day = $daycheck;
}
$oldnews_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
$oldnews[] = COM_createLink(COM_truncate($A['title'], $_CONF['title_trim_length'], '...'), $oldnews_url, array('title' => htmlspecialchars($A['title'], ENT_COMPAT, COM_getEncodingt()))) . ' (' . COM_numberFormat($A['comments']) . ')';
}
if (!empty($oldnews)) {
$daylist = COM_makeList($oldnews, 'list-older-stories');
$daylist = str_replace(array("\r", "\n"), '', $daylist);
$string .= $daylist;
$string = DB_escapeString($string);
DB_query("UPDATE {$_TABLES['blocks']} SET content = '{$string}' WHERE name = 'older_stories'");
}
}
}
示例12: plugin_itemlist_story_draft
/**
* Returns SQL & Language texts to moderation.php
*
* @return mixed Plugin object or void if not allowed
*
*/
function plugin_itemlist_story_draft()
{
global $_TABLES, $LANG24, $LANG29;
if (SEC_hasRights('story.edit')) {
$plugin = new Plugin();
$plugin->submissionlabel = $LANG29[35] . ' (' . $LANG24[34] . ')';
$plugin->submissionhelpfile = 'ccdraftsubmission.html';
$plugin->getsubmissionssql = "SELECT sid AS id,title,date,tid FROM {$_TABLES['stories']} WHERE (draft_flag = 1)" . COM_getTopicSQL('AND') . COM_getPermSQL('AND', 0, 3) . " ORDER BY date ASC";
$plugin->addSubmissionHeading($LANG29[10]);
$plugin->addSubmissionHeading($LANG29[14]);
$plugin->addSubmissionHeading($LANG29[15]);
return $plugin;
}
}
示例13: COM_whatsNewBlock
/**
* Shows any new information in a block
* Return the HTML that shows any new stories, comments, etc
*
* @param string $help Help file for block
* @param string $title Title used in block header
* @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre)
* @return string Return the HTML that shows any new stories, comments, etc
*/
function COM_whatsNewBlock($help = '', $title = '', $position = '')
{
global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW;
if ($_CONF['whatsnew_cache_time'] > 0) {
$cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme'];
$retval = CACHE_check_instance($cacheInstance);
if ($retval) {
$lu = CACHE_get_instance_update($cacheInstance);
$now = time();
if ($now - $lu < $_CONF['whatsnew_cache_time']) {
return $retval;
}
}
}
$retval = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position));
$topicSql = '';
if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
$topicSql = COM_getTopicSQL('AND', 0, 'ta');
}
if ($_CONF['hidenewstories'] == 0) {
$where_sql = " AND ta.type = 'article' AND ta.id = sid";
$archiveTid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
if (!empty($archiveTid)) {
$where_sql .= " AND (ta.tid <> '{$archiveTid}')";
}
// Find the newest stories
$sql['mysql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicSql . COM_getLangSQL('sid', 'AND') . "\n GROUP BY sid, title, date ORDER BY date DESC";
$sql['pgsql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicSql . COM_getLangSQL('sid', 'AND') . "\n GROUP BY sid, title, date ORDER BY date DESC";
$result = DB_query($sql);
$numRows = DB_numRows($result);
if (empty($title)) {
$title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'");
}
// Any late breaking news stories?
$retval .= '<h3>' . $LANG01[99] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newstoriesinterval']) . '</small></h3>';
if ($numRows > 0) {
$newArticles = array();
for ($x = 0; $x < $numRows; $x++) {
$A = DB_fetchArray($result);
$url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
$title = COM_undoSpecialChars(stripslashes($A['title']));
$titleToUse = COM_truncate($title, $_CONF['title_trim_length'], '...');
if ($title != $titleToUse) {
$attr = array('title' => htmlspecialchars($title));
} else {
$attr = array();
}
$anchorText = str_replace('$', '$', $titleToUse);
$anchorText = str_replace(' ', ' ', $anchorText);
$newArticles[] = COM_createLink($anchorText, $url, $attr);
}
$retval .= COM_makeList($newArticles, 'list-new-plugins');
} else {
$retval .= $LANG01[100] . '<br' . XHTML . '>' . LB;
// No new stories
}
if ($_CONF['hidenewcomments'] == 0 || $_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
$retval .= '<div class="divider-whats-new"></div>';
}
}
if ($_CONF['hidenewcomments'] == 0) {
// Go get the newest comments
$retval .= '<h3>' . $LANG01[83] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']) . '</small></h3>';
$new_plugin_comments = PLG_getWhatsNewComment();
if (!empty($new_plugin_comments)) {
// Sort array by element lastdate newest to oldest
foreach ($new_plugin_comments as $k => $v) {
$b[$k] = strtolower($v['lastdate']);
}
arsort($b);
$temp = array();
foreach ($b as $key => $val) {
$temp[] = $new_plugin_comments[$key];
}
$new_plugin_comments = $temp;
$newComments = array();
$count = 0;
foreach ($new_plugin_comments as $A) {
$count .= +1;
$url = '';
$info = PLG_getItemInfo($A['type'], $A['sid'], 'url');
if (!empty($info)) {
$url = $info . '#comments';
}
// Check to see if url (plugin may not support PLG_getItemInfo
if (!empty($url)) {
$title = COM_undoSpecialChars(stripslashes($A['title']));
$titleToUse = COM_truncate($title, $_CONF['title_trim_length'], '...');
if ($title != $titleToUse) {
$attr = array('title' => htmlspecialchars($title));
} else {
//.........这里部分代码省略.........
示例14: parse
//.........这里部分代码省略.........
$caption = trim($p2);
}
if ($display < 0) {
$display = 3;
}
$hash = CACHE_security_hash();
$instance_id = 'whatsnew_headlines_' . $uniqueID . '_' . $hash . '_' . $_USER['theme'];
if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
return $cache;
}
$archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
$sql = " (date <= NOW()) AND (draft_flag = 0)";
if (empty($topic)) {
$sql .= COM_getLangSQL('tid', 'AND', 's');
}
// if a topic was provided only select those stories.
if (!empty($topic)) {
$sql .= " AND s.tid = '" . DB_escapeString($topic) . "' ";
}
if ($featured == 1) {
$sql .= " AND s.featured = 1 ";
} else {
if ($featured == 2) {
$sql .= " AND s.featured = 0 ";
}
}
if ($frontpage == 1) {
$sql .= " AND frontpage = 1 ";
}
if ($topic != $archivetid) {
$sql .= " AND s.tid != '{$archivetid}' ";
}
$sql .= COM_getPermSQL('AND', 0, 2, 's');
$sql .= COM_getTopicSQL('AND', 0, 's') . ' ';
$userfields = 'u.uid, u.username, u.fullname';
if ($_CONF['allow_user_photo'] == 1) {
$userfields .= ', u.photo';
if ($_CONF['use_gravatar']) {
$userfields .= ', u.email';
}
}
$orderBy = ' date DESC ';
$headlinesSQL = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql . "ORDER BY featured DESC," . $orderBy;
if ($display > 0) {
$headlinesSQL .= " LIMIT " . $display;
}
$result = DB_query($headlinesSQL);
$numRows = DB_numRows($result);
if ($numRows < $cols) {
$cols = $numRows;
}
if ($cols > 6) {
$cols = 6;
}
if ($numRows > 0) {
$T = new Template($_CONF['path'] . 'system/autotags/');
$T->set_file('page', $template);
$T->set_var('columns', $cols);
$T->set_block('page', 'headlines', 'hl');
$newstories = array();
while ($A = DB_fetchArray($result)) {
$T->unset_var('readmore_url');
$T->unset_var('lang_readmore');
if ($A['attribution_author'] != '') {
$author = $A['attribution_author'];
} else {
示例15: SYND_feedUpdateCheckTopic
/**
* Check if a feed for stories from a topic needs to be updated.
*
* @param string $tid topic id
* @param string $update_info list of story ids
* @param string $limit number of entries or number of hours
* @param string $updated_topic (optional) topic to be updated
* @param string $updated_id (optional) entry id to be updated
* @return boolean false = feed needs to be updated
*
*/
function SYND_feedUpdateCheckTopic($tid, $update_info, $limit, $updated_topic = '', $updated_id = '')
{
global $_CONF, $_TABLES, $_SYND_DEBUG;
$where = '';
if (!empty($limit)) {
if (substr($limit, -1) == 'h') {
$limitsql = '';
$hours = substr($limit, 0, -1);
$where = " AND date >= DATE_SUB(NOW(),INTERVAL {$hours} HOUR)";
} else {
$limitsql = ' LIMIT ' . $limit;
}
} else {
$limitsql = ' LIMIT 10';
}
// "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() AND tid = '$tid'" . COM_getTopicSQL('AND', 1) . " AND perm_anon > 0 ORDER BY date DESC $limitsql"
$sql = "SELECT sid\n FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE draft_flag = 0 AND date <= NOW() AND perm_anon > 0\n AND ta.type = 'article' AND ta.id = sid\n AND ta.tid = '{$tid}'" . COM_getTopicSQL('AND', 1, 'ta') . "\n GROUP BY sid\n ORDER BY date DESC {$limitsql}";
$result = DB_query($sql);
$nrows = DB_numRows($result);
$sids = array();
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
if ($A['sid'] == $updated_id) {
// no need to look any further - this feed has to be updated
return false;
}
$sids[] = $A['sid'];
}
$current = implode(',', $sids);
if ($_SYND_DEBUG) {
COM_errorLog("Update check for topic {$tid}: comparing new list ({$current}) with old list ({$update_info})", 1);
}
return $current != $update_info ? false : true;
}