$poll->setVar("end_time", time() + (86400 * 10)); } if ( !empty($_POST["notify"]) && $end_time > time() ) { // if notify, set mail status to "not mailed" $poll->setVar("mail_status", POLL_NOTMAILED); } else { // if not notify, set mail status to already "mailed" $poll->setVar("mail_status", POLL_MAILED); } if ( !empty($_POST["reset"]) ) { // reset all logs XoopsPollLog::deleteByPollId($poll->getVar("poll_id")); XoopsPollOption::resetCountByPollId($poll->getVar("poll_id")); } if (!$poll->store()) { forum_message($poll->getHtmlErrors()); exit(); } $poll->updateCount(); include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_clear_module_cache($xoopsModule->getVar('mid')); redirect_header("viewtopic.php?topic_id=$topic_id",1,_MD_POLL_DBUPDATED); //exit(); } if ( $op == "log" ) { //include XOOPS_ROOT_PATH."/header.php"; echo "<h4>"._MD_POLL_POLLCONF."</h4>"; echo "<br />View Log<br /> Sorry, not yet. ;-)"; //include XOOPS_ROOT_PATH."/footer.php"; //exit();
/** * Write online information to the database * * @param int $uid UID of the active user * @param string $uname Username * @param string $timestamp * @param string $xforum Current forum * @param string $ip User's IP adress * @return bool TRUE on success */ function write($uid, $uname, $time, $xforum, $ip, $xforumtopic) { global $xoopsModule; $uid = intval($uid); if ($uid > 0) { $sql = "SELECT COUNT(*) FROM " . $GLOBALS["xoopsDB"]->prefix('xf_online') . " WHERE online_uid=" . $uid; } else { $sql = "SELECT COUNT(*) FROM " . $GLOBALS["xoopsDB"]->prefix('xf_online') . " WHERE online_uid=" . $uid . " AND online_ip='" . $ip . "'"; } list($count) = $GLOBALS["xoopsDB"]->fetchRow($GLOBALS["xoopsDB"]->queryF($sql)); if ($count > 0) { $sql = "UPDATE " . $GLOBALS["xoopsDB"]->prefix('xf_online') . " SET online_updated= '" . $time . "', online_forum = '" . $xforum . "', online_topic = '" . $xforumtopic . "' WHERE online_uid = " . $uid; if ($uid == 0) { $sql .= " AND online_ip='" . $ip . "'"; } } else { $sql = sprintf("INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)", $GLOBALS["xoopsDB"]->prefix('xf_online'), $uid, $GLOBALS["xoopsDB"]->quoteString($uname), $time, $GLOBALS["xoopsDB"]->quoteString($ip), $xforum, $xforumtopic); } if (!$GLOBALS["xoopsDB"]->queryF($sql)) { forum_message("can not update online info: ".$sql); return false; } $mysql_version = substr(trim(mysql_get_server_info()), 0, 3); /* for MySQL 4.1+ */ if($mysql_version >= "4.1"): $sql = "DELETE FROM ".$GLOBALS["xoopsDB"]->prefix('xf_online'). " WHERE". " ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM ".$GLOBALS["xoopsDB"]->prefix('online')." WHERE online_module =".$xoopsModule->getVar('mid')." ) )". " OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM ".$GLOBALS["xoopsDB"]->prefix('online')." WHERE online_module =".$xoopsModule->getVar('mid')." AND online_uid = 0 ) )"; if($result = $GLOBALS["xoopsDB"]->queryF($sql)){ return true; }else{ forum_message("clean xoops online error: ".$sql); return false; } else: $sql = "DELETE ".$GLOBALS["xoopsDB"]->prefix('xf_online')." FROM ".$GLOBALS["xoopsDB"]->prefix('xf_online'). " LEFT JOIN ".$GLOBALS["xoopsDB"]->prefix('online')." AS aa ". " ON ".$GLOBALS["xoopsDB"]->prefix('xf_online').".online_uid = aa.online_uid WHERE ".$GLOBALS["xoopsDB"]->prefix('xf_online').".online_uid > 0 AND aa.online_uid IS NULL"; $result = $GLOBALS["xoopsDB"]->queryF($sql); $sql = "DELETE ".$GLOBALS["xoopsDB"]->prefix('xf_online')." FROM ".$GLOBALS["xoopsDB"]->prefix('xf_online'). " LEFT JOIN ".$GLOBALS["xoopsDB"]->prefix('online')." AS aa ". " ON ".$GLOBALS["xoopsDB"]->prefix('xf_online').".online_ip = aa.online_ip WHERE ".$GLOBALS["xoopsDB"]->prefix('xf_online').".online_uid = 0 AND aa.online_ip IS NULL"; $result = $GLOBALS["xoopsDB"]->queryF($sql); return true; endif; }
function &getAllPosters(&$topic, $isApproved = true) { $sql = 'SELECT DISTINCT uid FROM ' . $this->db->prefix('xf_posts') . " WHERE topic_id=" . $topic->getVar('topic_id')." AND uid>0"; if($isApproved) $sql .= ' AND approved = 1'; $result = $this->db->query($sql); if (!$result) { forum_message("xforumTopicHandler::getAllPosters error:" . $sql); return array(); } $ret = array(); while ($myrow = $this->db->fetchArray($result)) { $ret[] = $myrow['uid']; } return $ret; }
/** * clean orphan items from database * * @return bool true on success */ function cleanOrphan() { /* for MySQL 4.1+ */ if($this->mysql_major_version() >= 4): $sql = "DELETE FROM ".$this->table. " WHERE (forum_id >0 AND forum_id NOT IN ( SELECT DISTINCT forum_id FROM ".$this->db->prefix("xf_forums").") )"; else: // for 4.0 + /* */ $sql = "DELETE ".$this->table." FROM ".$this->table. " LEFT JOIN ".$this->db->prefix("xf_forums")." AS aa ON ".$this->table.".forum_id = aa.forum_id ". " WHERE ".$this->table.".forum_id > 0 AND (aa.forum_id IS NULL)"; /* */ // for 4.1+ /* $sql = "DELETE bb FROM ".$this->table." AS bb". " LEFT JOIN ".$this->db->prefix("xf_forums")." AS aa ON bb.forum_id = aa.forum_id ". " WHERE bb.forum_id > 0 AND (aa.forum_id IS NULL)"; */ endif; if (!$result = $this->db->queryF($sql)) { forum_message("cleanOrphan:". $sql); return false; } return true; }
/** * clean orphan items from database * * @return bool true on success */ function cleanOrphan() { parent::cleanOrphan($this->db->prefix("xf_topics"), "topic_id"); parent::cleanOrphan($this->db->prefix("xf_posts_text"), "post_id"); /* for MySQL 4.1+ */ if($this->mysql_major_version() >= 4): $sql = "DELETE FROM ".$this->db->prefix("xf_posts_text"). " WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ".$this->table.") )"; else: // for 4.0+ /* */ $sql = "DELETE ".$this->db->prefix("xf_posts_text")." FROM ".$this->db->prefix("xf_posts_text"). " LEFT JOIN ".$this->table." AS aa ON ".$this->db->prefix("xf_posts_text").".post_id = aa.post_id ". " WHERE (aa.post_id IS NULL)"; /* */ // Alternative for 4.1+ /* $sql = "DELETE bb FROM ".$this->db->prefix("xf_posts_text")." AS bb". " LEFT JOIN ".$this->table." AS aa ON bb.post_id = aa.post_id ". " WHERE (aa.post_id IS NULL)"; */ endif; if (!$result = $this->db->queryF($sql)) { forum_message("cleanOrphan:". $sql); return false; } return true; }
function b_forum_author_show($options) { global $xoopsConfig; global $access_forums; $db = &Database::getInstance(); $myts = &MyTextSanitizer::getInstance(); $block = array(); $i = 0; $type = "topic"; $order = "count"; $extra_criteria = ""; $time_criteria = null; if(!empty($options[2])) { $time_criteria = time() - forum_getSinceTime($options[2]); $extra_criteria = " AND topic_time>".$time_criteria; } switch ($options[0]) { case 'topic': break; case 'digest': $extra_criteria = " AND topic_digest=1"; if($time_criteria) $extra_criteria .= " AND digest_time>".$time_criteria; break; case 'sticky': $extra_criteria .= " AND topic_sticky=1"; break; case 'post': default: $type = "post"; if($time_criteria) $extra_criteria = " AND post_time>".$time_criteria; break; } $xforumConfig = getConfigForBlock(); if(!isset($access_forums)){ $forum_handler = &xoops_getmodulehandler('forum', 'xforum'); if(!$access_obj =& $forum_handler->getForums(0, 'access', array('forum_id', 'cat_id', 'forum_type')) ){ return null; } $access_forums = array_keys( $access_obj ); // get all accessible forums unset($access_obj ); } if (!empty($options[5])) { $allowedforums = array_filter(array_slice($options, 5), "b_forum_array_filter"); // get allowed forums $allowed_forums = array_intersect($allowedforums, $access_forums); }else{ $allowed_forums = $access_forums; } if($type=="topic"){ $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count FROM ' . $db->prefix('xf_topics') . ' WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; }else{ $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND approved = 1'; $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count FROM ' . $db->prefix('xf_posts') . ' WHERE uid>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; } $result = $db->query($query, $options[1], 0); if (!$result) { forum_message("xforum block query error: ".$query); return false; } $author = array(); while ($row = $db->fetchArray($result)) { $author[$row["author"]]["count"] = $row["count"]; } if (count($author) < 1) return false; $author_name = forum_getUnameFromIds(array_keys($author), $xforumConfig['show_realname']); foreach(array_keys($author) as $uid){ $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]); } $block['authors'] =& $author; $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; $block['indexNav'] = intval($options[4]); return $block; }
' t.topic_id, t.topic_title, t.topic_subject,'. ' p.post_id, p.post_time, p.subject, p.uid, p.poster_name, p.post_karma, p.require_reply, p.dohtml, p.dosmiley, p.doxcode,'. ' pt.post_text'. ' FROM ' . $xoopsDB->prefix('xf_posts') . ' AS p'. ' LEFT JOIN ' . $xoopsDB->prefix('xf_topics') . ' AS t ON t.topic_last_post_id=p.post_id'. ' LEFT JOIN ' . $xoopsDB->prefix('xf_posts_text') . ' AS pt ON pt.post_id=p.post_id'. ' LEFT JOIN ' . $xoopsDB->prefix('xf_forums') . ' AS f ON f.forum_id=p.forum_id'. ' WHERE 1=1 ' . $forum_criteria . $approve_criteria . ' ORDER BY p.post_time DESC'; $limit = intval($xoopsModuleConfig['rss_maxitems'] * 1.5); if (!$result = $xoopsDB->query($query,$limit)) { forum_message("query for rss builder error: ".$query); return $xmlrss_handler->get($rss); } $rows = array(); while ($row = $xoopsDB->fetchArray($result)) { $users[$row['uid']] = 1; $rows[] = $row; } if(count($rows)<1) { return $xmlrss_handler->get($rss); } $users =& forum_getUnameFromIds(array_keys($users), $xoopsModuleConfig['show_realname']); foreach($rows as $topic){ if( $xoopsModuleConfig['enable_karma'] && $topic['post_karma'] > 0 ) continue; if( $xoopsModuleConfig['allow_require_reply'] && $topic['require_reply']) continue;