function __construct() { $this->_db =& JFactory::getDBO(); $this->_my =& JFactory::getUser(); $this->_session =& KunenaFactory::getSession(); $this->_config = KunenaFactory::getConfig(); $this->_isimage = false; $this->_isfile = false; if (CKunenaTools::isModerator($this->_my->id) || $this->_my->id && $this->_config->allowimageregupload || !$this->_my->id && $this->_config->allowimageupload) { $this->validImageExts = explode(',', $this->_config->imagetypes); } if (CKunenaTools::isModerator($this->_my->id) || $this->_my->id && $this->_config->allowfileregupload || !$this->_my->id && $this->_config->allowfileupload) { $this->validFileExts = explode(',', $this->_config->filetypes); } $this->setImageResize(intval($this->_config->imagesize) * 1024, intval($this->_config->imagewidth), intval($this->_config->imageheight), intval($this->_config->imagequality)); }
function displayFlat() { if (!$this->allow) { echo JText::_('COM_KUNENA_NO_ACCESS'); return; } if (CKunenaTools::isModerator($this->my->id, $this->catid)) { $this->actionMove = true; $this->actionDropdown[] = JHTML::_('select.option', 'bulkDel', JText::_('COM_KUNENA_DELETE_SELECTED')); $this->actionDropdown[] = JHTML::_('select.option', 'bulkMove', JText::_('COM_KUNENA_MOVE_SELECTED')); if ($this->config->mod_see_deleted == '1' && CKunenaTools::isModerator() || $this->config->mod_see_deleted == '0' && CKunenaTools::isAdmin()) { $this->actionDropdown[] = JHTML::_('select.option', 'bulkDelPerm', JText::_('COM_KUNENA_BUTTON_PERMDELETE_LONG')); $this->actionDropdown[] = JHTML::_('select.option', 'bulkRestore', JText::_('COM_KUNENA_BUTTON_UNDELETE_LONG')); } } if ($this->myprofile->ordering != '0') { $this->topic_ordering = $this->myprofile->ordering == '1' ? 'DESC' : 'ASC'; } else { $this->topic_ordering = $this->config->default_sort == 'asc' ? 'ASC' : 'DESC'; // Just to make sure only valid options make it } CKunenaTools::loadTemplate('/threads/flat.php'); }
public function floodProtection() { // Flood protection $ip = $_SERVER["REMOTE_ADDR"]; if ($this->config->floodprotection && !CKunenaTools::isModerator($this->my->id, $this->catid)) { $this->_db->setQuery("SELECT MAX(time) FROM #__kunena_messages WHERE ip={$this->_db->Quote($ip)}"); $lastPostTime = $this->_db->loadResult(); if (KunenaError::checkDatabaseError()) { return false; } if ($lastPostTime + $this->config->floodprotection > CKunenaTimeformat::internalTime()) { echo JText::_('COM_KUNENA_POST_TOPIC_FLOOD1') . ' ' . $this->config->floodprotection . ' ' . JText::_('COM_KUNENA_POST_TOPIC_FLOOD2') . '<br />'; echo JText::_('COM_KUNENA_POST_TOPIC_FLOOD3'); return true; } } return false; }
<?php } ?> </td> </tr> <?php } ?> <?php // Show bbcode editor CKunenaTools::loadTemplate('/editor/bbcode.php'); ?> <?php if ($this->config->allowfileupload || $this->config->allowfileregupload && $this->my->id != 0 || ($this->config->allowimageupload || $this->config->allowimageregupload && $this->my->id != 0 || CKunenaTools::isModerator($this->my->id, $this->catid))) { //$this->document->addScript ( KUNENA_DIRECTURL . 'js/plupload/gears_init.js' ); //$this->document->addScript ( KUNENA_DIRECTURL . 'js/plupload/plupload.full.min.js' ); ?> <tr id="kpost-attachments" class="krow<?php echo 1 + ($this->k ^= 1); ?> "> <td class="kcol-first"> <strong><?php echo JText::_('COM_KUNENA_EDITOR_ATTACHMENTS'); ?> </strong> </td> <td class="kcol-mid"> <div id="kattachment-id" class="kattachment">
protected function _moderatorProtection() { // FIXME: only allow action in categories where user has moderator rights if (!CKunenaTools::isModerator($this->my->id, $this->catid)) { $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_NOT_MODERATOR'), 'notice'); return true; } return false; }
function getView() { // Is user allowed to read category from the URL? if ($this->catid && !$this->session->canRead($this->catid)) { return; } $this->allow = 1; $where[] = "a.hold IN ({$this->hold})"; $where = implode(' AND ', $where); $query = "SELECT a.*, b.*, p.id AS poll_id, modified.name AS modified_name, modified.username AS modified_username\n\t\t\tFROM #__kunena_messages AS a\n\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\tLEFT JOIN #__kunena_polls AS p ON a.id=p.threadid\n\t\t\tWHERE a.id={$this->db->Quote($this->id)} AND {$where}"; $this->db->setQuery($query); $this->first_message = $this->db->loadObject(); // Invalid message id (deleted, on hold?) if (KunenaError::checkDatabaseError() || !$this->first_message) { return; } // Is user allowed to see the forum specified in the message? if (!$this->session->canRead($this->first_message->catid)) { $this->allow = 0; return; } $this->thread = $this->first_message->thread; // Test if this is a valid URL. If not, redirect browser to the right location if ($this->first_message->moved || $this->thread != $this->id || $this->catid != $this->first_message->catid) { $this->catid = $this->first_message->catid; if ($this->first_message->moved) { $newurl = array(); parse_str($this->first_message->message, $newloc); $this->id = $newloc['id']; $query = "SELECT catid, thread FROM #__kunena_messages AS a WHERE a.id='{$this->id}'"; $this->db->setQuery($query); $newpos = $this->db->loadObject(); if (!$newpos) { $this->allow = 0; return; } if (KunenaError::checkDatabaseError()) { return; } $this->thread = $newpos->thread; $this->catid = $newpos->catid; } // This query to calculate the page this reply is sitting on within this thread $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where} AND a.id<={$this->db->Quote($this->id)}"; $this->db->setQuery($query); $replyCount = $this->db->loadResult(); if (KunenaError::checkDatabaseError()) { return; } $replyPage = $replyCount > $this->config->messages_per_page ? ceil($replyCount / $this->config->messages_per_page) : 1; $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->thread, $replyPage, $this->config->messages_per_page, $this->first_message->id, false); } //Get the category name for breadcrumb $this->db->setQuery("SELECT * FROM #__kunena_categories WHERE id={$this->db->Quote($this->catid)}"); $this->catinfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } //Get Parent's cat.name for breadcrumb $this->db->setQuery("SELECT id, name FROM #__kunena_categories WHERE id={$this->db->Quote($this->catinfo->parent)}"); $objCatParentInfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } // START $this->emoticons = smile::getEmoticons(0); $this->prevCheck = $this->session->lasttime; $this->read_topics = explode(',', $this->session->readtopics); $showedEdit = 0; $this->kunena_forum_locked = $this->catinfo->locked; //check if topic is locked $this->topicLocked = $this->first_message->locked; if (!$this->topicLocked) { //topic not locked; check if forum is locked $this->topicLocked = $this->catinfo->locked; } $this->topicSticky = $this->first_message->ordering; CKunenaTools::markTopicRead($this->thread, $this->my->id); //update the hits counter for this topic & exclude the owner if ($this->my->id == 0 || $this->first_message->userid != $this->my->id) { $this->db->setQuery("UPDATE #__kunena_messages SET hits=hits+1 WHERE id={$this->db->Quote($this->thread)} AND parent='0'"); $this->db->query(); KunenaError::checkDatabaseError(); } $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where}"; $this->db->setQuery($query); $this->total_messages = $this->db->loadResult(); KunenaError::checkDatabaseError(); // If page does not exist, redirect to the last page if ($this->total_messages <= $this->limitstart) { $page = ceil($this->total_messages / $this->limit); $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, $page, $this->limit, '', false); } $maxpages = 7 - 2; // odd number here (show - 2) $totalpages = ceil($this->total_messages / $this->limit); $page = floor($this->limitstart / $this->limit) + 1; $firstpage = 1; if ($this->ordering == 'desc') { $firstpage = $totalpages; } // Get replies of current thread $query = "SELECT a.*, b.*, modified.name AS modified_name, modified.username AS modified_username\n\t\t\t\t\tFROM #__kunena_messages AS a\n\t\t\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\t\t\tWHERE a.thread={$this->db->Quote($this->thread)} AND {$where}\n\t\t\t\t\tORDER BY id {$this->ordering}"; $this->db->setQuery($query, $this->limitstart, $this->limit); $this->messages = (array) $this->db->loadObjectList('id'); KunenaError::checkDatabaseError(); // First collect the message ids of the first message and all replies $messageids = array(); $this->threaded = array(); $userlist = array(); foreach ($this->messages as $message) { $messageids[] = $message->id; // Threaded ordering if (isset($this->messages[$message->parent])) { $this->threaded[$message->parent][] = $message->id; } else { $this->threaded[0][] = $message->id; } $userlist[intval($message->userid)] = intval($message->userid); $userlist[intval($message->modified_by)] = intval($message->modified_by); } if (!isset($this->messages[$this->mesid])) { $this->mesid = reset($messageids); } if ($this->layout != 'view') { if (!isset($this->messages[$this->id])) { $this->messages = $this->getThreadedOrdering(0, array('edge')); } else { $this->messages = $this->getThreadedOrdering(); } } // create a list of ids we can use for our sql $idstr = @join(",", $messageids); // Load attachments require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php'; $attachments = CKunenaAttachments::getInstance(); if (is_a($attachments, 'CKunenaAttachments')) { $message_attachments = $attachments->get($idstr); // Now that we have all relevant messages in messages, asign any matching attachments foreach ($this->messages as $message) { // Mark as new if ($this->my->id && $this->prevCheck < $message->time && !in_array($message->thread, $this->read_topics)) { $message->new = true; } else { $message->new = false; } // Assign attachments if (isset($message_attachments[$message->id])) { $message->attachments = $message_attachments[$message->id]; } } // Done with attachments } $this->pagination = $this->getPagination($this->catid, $this->thread, $page, $totalpages, $maxpages); //meta description and keywords $metaKeys = kunena_htmlspecialchars("{$this->first_message->subject}, {$objCatParentInfo->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . $this->app->getCfg('sitename')); // Create Meta Description form the content of the first message // better for search results display but NOT for search ranking! $metaDesc = KunenaParser::stripBBCode($this->first_message->message); $metaDesc = strip_tags($metaDesc); // Now remove all tags $metaDesc = preg_replace('/\\s+/', ' ', $metaDesc); // remove newlines $metaDesc = preg_replace('/^[^\\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers $metaDesc = trim($metaDesc); // Remove trailing spaces and beginning // remove multiple spaces while (strpos($metaDesc, ' ') !== false) { $metaDesc = str_replace(' ', ' ', $metaDesc); } // limit to 185 characters - google will cut off at ~150 if (strlen($metaDesc) > 185) { $metaDesc = rtrim(JString::substr($metaDesc, 0, 182)) . '...'; } $metaDesc = htmlspecialchars($metaDesc); $document =& JFactory::getDocument(); $document->setMetadata('keywords', $metaKeys); $document->setDescription($metaDesc); $this->layout_buttons = array(); if ($this->config->enable_threaded_layouts) { if ($this->layout != 'view') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('flat', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-flat', JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'threaded') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('threaded', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-threaded', JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'indented') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('indented', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-indented', JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } } //Perform subscriptions check only once $this->cansubscribe = 0; if ($this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->my->id) { $this->db->setQuery("SELECT thread, future1 FROM #__kunena_subscriptions WHERE userid={$this->db->Quote($this->my->id)} AND thread={$this->db->Quote($this->thread)}"); $fb_subscribed = $this->db->loadObject(); KunenaError::checkDatabaseError(); if (!$fb_subscribed) { $this->cansubscribe = 1; } elseif ($fb_subscribed->future1 == 1) { $query_thread = "UPDATE #__kunena_subscriptions\n\t\t\t\t\tSET future1=0 WHERE thread={$this->db->Quote($this->thread)} AND userid={$this->db->Quote($this->my->id)}"; $this->db->setQuery($query_thread); $this->db->query(); } } //Perform favorites check only once $fb_canfavorite = 0; $this->db->setQuery("SELECT MAX(userid={$this->db->Quote($this->my->id)}) AS favorited, COUNT(*) AS totalfavorited FROM #__kunena_favorites WHERE thread={$this->db->Quote($this->thread)}"); list($this->favorited, $this->totalfavorited) = $this->db->loadRow(); KunenaError::checkDatabaseError(); if ($this->config->allowfavorites && $this->my->id) { if (!$this->favorited) { $fb_canfavorite = 1; } } //get the Moderator list for display $this->db->setQuery("SELECT m.*, u.* FROM #__kunena_moderation AS m INNER JOIN #__users AS u ON u.id=m.userid WHERE m.catid={$this->db->Quote($this->catid)} AND u.block=0"); $this->modslist = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); $this->catModerators = array(); foreach ($this->modslist as $mod) { $this->catModerators[] = $mod->userid; $userlist[intval($mod->userid)] = intval($mod->userid); } // Prefetch all users/avatars to avoid user by user queries during template iterations KunenaUser::loadUsers($userlist); //data ready display now if (CKunenaTools::isModerator($this->my->id, $this->catid) || $this->topicLocked == 0) { //this user is allowed to reply to this topic $this->thread_reply = CKunenaLink::GetTopicPostReplyLink('reply', $this->catid, $this->thread, CKunenaTools::showButton('reply', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC_LONG')); } // Thread Subscription if ($this->cansubscribe == 1) { // this user is allowed to subscribe - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_subscribe = CKunenaLink::GetTopicPostLink('subscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->cansubscribe == 0) { // this user is allowed to unsubscribe $this->thread_subscribe = CKunenaLink::GetTopicPostLink('unsubscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC_LONG')); } //START: FAVORITES if ($fb_canfavorite == 1) { // this user is allowed to add a favorite - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_favorite = CKunenaLink::GetTopicPostLink('favorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowfavorites && $fb_canfavorite == 0) { // this user is allowed to unfavorite $this->thread_favorite = CKunenaLink::GetTopicPostLink('unfavorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC_LONG')); } // FINISH: FAVORITES if (CKunenaTools::isModerator($this->my->id, $this->catid) || !$this->kunena_forum_locked) { //this user is allowed to post a new topic $this->thread_new = CKunenaLink::GetPostNewTopicLink($this->catid, CKunenaTools::showButton('newtopic', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC_LONG')); } if (CKunenaTools::isModerator($this->my->id, $this->catid)) { // offer the moderator always the move link to relocate a topic to another forum // and the (un)sticky bit links // and the (un)lock links if ($this->topicSticky == 0) { $this->thread_sticky = CKunenaLink::GetTopicPostLink('sticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC_LONG')); } else { $this->thread_sticky = CKunenaLink::GetTopicPostLink('unsticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC_LONG')); } if ($this->topicLocked == 0) { $this->thread_lock = CKunenaLink::GetTopicPostLink('lock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC_LONG')); } else { $this->thread_lock = CKunenaLink::GetTopicPostLink('unlock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC_LONG')); } $this->thread_delete = CKunenaLink::GetTopicPostLink('deletethread', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC_LONG')); $this->thread_moderate = CKunenaLink::GetTopicPostReplyLink('moderatethread', $this->catid, $this->id, CKunenaTools::showButton('moderate', JText::_('COM_KUNENA_BUTTON_MODERATE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_MODERATE')); } $this->headerdesc = nl2br(smile::smileReplace($this->catinfo->headerdesc, 0, $this->config->disemoticons, $this->emoticons)); $tabclass = array("row1", "row2"); $this->mmm = 0; $this->replydir = $this->ordering == 'DESC' ? -1 : 1; if ($this->replydir < 0) { $this->replynum = $this->total_messages - $this->limitstart + 1; } else { $this->replynum = $this->limitstart; } $this->myname = $this->config->username ? $this->my->username : $this->my->name; $this->allow_anonymous = !empty($this->catinfo->allow_anonymous) && $this->my->id; $this->anonymous = $this->allow_anonymous && !empty($this->catinfo->post_anonymous); }
echo JText::_('COM_KUNENA_BAN_BANMANAGER'); ?> "><?php echo JText::_('COM_KUNENA_BAN_BANMANAGER'); ?> </dt> <dd style="display: none;"> <?php $this->displayBanManager(); ?> </dd> <?php } ?> <?php if (CKunenaTools::isModerator($this->my->id) && $this->my->id != $this->user->id) { ?> <dt class="closed" title="<?php echo JText::_('COM_KUNENA_BAN_BANHISTORY'); ?> "><?php echo JText::_('COM_KUNENA_BAN_BANHISTORY'); ?> </dt> <dd style="display: none;"> <?php $this->displayBanHistory(); ?> </dd> <?php }
} $kunena_app->redirect(CKunenaLink::GetLatestPageAutoRedirectURL($pid, $kunena_config->messages_per_page, $catid)); } else { while (@ob_end_clean()) { } $kunena_app->redirect(CKunenaLink::GetMyProfileURL($userid)); } return; } // This checkes to see if it's not too soon for a new karma change if (!CKunenaTools::isModerator($kunena_my->id, $catid)) { $userprofile = KunenaFactory::getUser($kunena_my->id); $karma_time_old = $userprofile->karma_time; $karma_time_diff = $time - $karma_time_old; } if (CKunenaTools::isModerator($kunena_my->id, $catid) || $karma_time_diff >= $karma_min_seconds) { if ($do == "increase") { $kunena_db->setQuery("UPDATE #__kunena_users SET karma_time={$kunena_db->Quote($time)} WHERE userid={$kunena_db->Quote($kunena_my->id)} "); $kunena_db->query(); if (KunenaError::checkDatabaseError()) { return; } $kunena_db->setQuery("UPDATE #__kunena_users SET karma=karma+1 WHERE userid={$kunena_db->Quote($userid)}"); $kunena_db->query(); if (KunenaError::checkDatabaseError()) { return; } // Activity integration $activity = KunenaFactory::getActivityIntegration(); $activity->onAfterKarma($userid, $kunena_my->id, 1); if ($pid) {
echo $who_name; ?> </div> <div> <?php $onlineList = array(); $hiddenList = array(); foreach ($users as $user) { if ($user->showOnline > 0) { $onlineList[] = CKunenaLink::GetProfileLink(intval($user->id)); } else { $hiddenList[] = CKunenaLink::GetProfileLink(intval($user->id)); } } echo implode(', ', $onlineList); if (!empty($hiddenList) && CKunenaTools::isModerator($this->my->id)) { ?> <br /> <span class="khidden-ktitle ks"><?php echo JText::_('COM_KUNENA_HIDDEN_USERS'); ?> : </span> <br /> <?php echo implode(', ', $hiddenList); ?> <?php } ?> </div> <div class="kwholegend ks">
function GetProfileLink($userid, $name = null, $title = '', $rel = 'nofollow', $class = '') { if (!$name) { $profile = KunenaFactory::getUser($userid); $name = htmlspecialchars($profile->getName(), ENT_COMPAT, 'UTF-8'); } if ($userid == 0) { $uclass = 'kwho-guest'; } else { if (CKunenaTools::isAdmin($userid)) { $uclass = 'kwho-admin'; } else { if (CKunenaTools::isModerator($userid, false)) { $uclass = 'kwho-globalmoderator'; } else { if (CKunenaTools::isModerator($userid)) { $uclass = 'kwho-moderator'; } else { $uclass = 'kwho-user'; } } } } if ($userid > 0) { $link = CKunenaLink::GetProfileURL($userid); if (!empty($link)) { return CKunenaLink::GetHrefLink($link, $name, $title, $rel, $uclass); } } return "<span class=\"{$uclass}\">{$name}</span>"; }
/** * Search constructor * @param limitstart First shown item * @param limit Limit */ function CKunenaSearch() { $this->my = JFactory::getUser(); $this->app = JFactory::getApplication(); $this->doc = JFactory::getDocument(); $this->db = JFactory::getDBO(); $this->config = KunenaFactory::getConfig(); $this->session = KunenaFactory::getSession(); // TODO: started_by // TODO: active_in // Default values for checkboxes depends on function $this->func = JString::strtolower(JRequest::getCmd('func')); if ($this->func == 'search') { $this->defaults['exactname'] = $this->defaults['childforums'] = 1; } else { $this->defaults['exactname'] = $this->defaults['childforums'] = 0; } $q = JRequest::getVar('q', ''); // Search words // Backwards compability for old templates if (empty($q) && isset($_REQUEST['searchword'])) { $q = JRequest::getVar('searchword', ''); } $q = JString::trim($q); $this->params['titleonly'] = JRequest::getInt('titleonly', $this->defaults['titleonly']); $this->params['searchuser'] = JRequest::getVar('searchuser', $this->defaults['searchuser']); $this->params['starteronly'] = JRequest::getInt('starteronly', $this->defaults['starteronly']); $this->params['exactname'] = JRequest::getInt('exactname', $this->defaults['exactname']); $this->params['replyless'] = JRequest::getInt('replyless', $this->defaults['replyless']); $this->params['replylimit'] = JRequest::getInt('replylimit', $this->defaults['replylimit']); $this->params['searchdate'] = JRequest::getVar('searchdate', $this->defaults['searchdate']); $this->params['beforeafter'] = JRequest::getVar('beforeafter', $this->defaults['beforeafter']); $this->params['sortby'] = JRequest::getVar('sortby', $this->defaults['sortby']); $this->params['order'] = JRequest::getVar('order', $this->defaults['order']); $this->params['childforums'] = JRequest::getInt('childforums', $this->defaults['childforums']); $this->params['catids'] = strtr(JRequest::getVar('catids', '0', 'get'), KUNENA_URL_LIST_SEPARATOR, ','); $this->params['show'] = JRequest::getInt('show', $this->defaults['show']); $this->limitstart = JRequest::getInt('limitstart', 0); $this->limit = JRequest::getInt('limit', $this->config->messages_per_page_search); extract($this->params); if ($this->limit < 1 || $this->limit > 40) { $this->limit = $this->limit = $this->config->messages_per_page_search; } if (isset($_POST['q']) || isset($_POST['searchword'])) { $catids = JRequest::getVar('catids', array(0), 'post', 'array'); JArrayHelper::toInteger($catids); $this->params['catids'] = implode(',', $catids); $url = CKunenaLink::GetSearchURL($this->func, $q, $this->limitstart, $this->limit, $this->getUrlParams()); header("HTTP/1.1 303 See Other"); header("Location: " . htmlspecialchars_decode($url)); $this->app->close(); } $catids = explode(',', $this->params['catids']); JArrayHelper::toInteger($catids); $this->params['catids'] = implode(',', $catids); if ($q == JText::_('COM_KUNENA_GEN_SEARCH_BOX')) { $q = ''; } $this->q = $q; $arr_searchwords = preg_split('/[\\s,]*\'([^\']+)\'[\\s,]*|[\\s,]*"([^"]+)"[\\s,]*|[\\s,]+/u', $q, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $do_search = FALSE; $this->arr_kunena_searchstrings = array(); foreach ($arr_searchwords as $q) { $q = JString::trim($q); if (JString::strlen($q) > 1) { $do_search = TRUE; } $this->arr_kunena_searchstrings[] = $q; } if (JString::strlen($this->params['searchuser']) > 0) { $do_search = TRUE; } $arr_searchwords = $this->arr_kunena_searchstrings; $this->str_kunena_username = $this->params['searchuser']; if ($do_search != TRUE) { $this->int_kunena_errornr = 1; $this->str_kunena_errormsg = JText::_('COM_KUNENA_SEARCH_ERR_SHORTKEYWORD'); return; } $search_forums = $this->get_search_forums($this->params['catids'], $this->params['childforums']); /* if there are no forums to search in, set error and return */ if (empty($search_forums)) { $this->int_kunena_errornr = 2; $this->str_kunena_errormsg = JText::_('COM_KUNENA_SEARCH_NOFORUM'); return; } for ($x = 0; $x < count($arr_searchwords); $x++) { $searchword = $arr_searchwords[$x]; $searchword = $this->db->getEscaped(JString::trim($searchword)); if (empty($searchword)) { continue; } $matches = array(); $not = ''; $operator = ' OR '; if (substr($searchword, 0, 1) == '-' && strlen($searchword) > 1) { $not = 'NOT'; $operator = 'AND'; $searchword = JString::substr($searchword, 1); } if ($this->params['titleonly'] == '0') { $querystrings[] = "(t.message {$not} LIKE '%{$searchword}%' {$operator} m.subject {$not} LIKE '%{$searchword}%')"; } else { $querystrings[] = "(m.subject {$not} LIKE '%{$searchword}%')"; } } //User searching if (JString::strlen($this->params['searchuser']) > 0) { if ($this->params['exactname'] == '1') { $querystrings[] = "m.name LIKE '" . $this->db->getEscaped($this->params['searchuser']) . "'"; } else { $querystrings[] = "m.name LIKE '%" . $this->db->getEscaped($this->params['searchuser']) . "%'"; } } $time = 0; switch ($this->params['searchdate']) { case 'lastvisit': $this->db->setQuery("SELECT lasttime FROM #__kunena_sessions WHERE userid={$this->db->Quote($this->my->id)}"); $time = $this->db->loadResult(); break; case 'all': break; case '1': case '7': case '14': case '30': case '90': case '180': case '365': $time = time() - 86400 * intval($this->params['searchdate']); //24*3600 break; default: $time = time() - 86400 * 365; $searchdate = '365'; } if ($time) { if ($this->params['beforeafter'] == 'after') { $querystrings[] = "m.time > '{$time}'"; } else { $querystrings[] = "m.time <= '{$time}'"; } } /* build query */ $querystrings[] = "m.moved='0'"; //Search also unapproved, trash $this->show = array(); if (CKunenaTools::isModerator($this->my->id) && $this->params['show'] > 0) { $search_forums_array = explode(',', $search_forums); $search_forums = array(); foreach ($search_forums_array as $currforum) { if (CKunenaTools::isModerator($this->my->id, $currforum)) { $search_forums[] = $currforum; } } if (empty($search_forums)) { return; } $search_forums = implode(',', $search_forums); $querystrings[] = "m.hold='" . (int) $this->params['show'] . "'"; } else { $querystrings[] = "m.hold='0'"; } $querystrings[] = "m.catid IN ({$search_forums})"; $where = implode(' AND ', $querystrings); $groupby = array(); if ($this->params['order'] == 'dec') { $order1 = 'DESC'; } else { $order1 = 'ASC'; } switch ($this->params['sortby']) { case 'title': $orderby = "m.subject {$order1}, m.time {$order1}"; break; case 'views': $orderby = "m.hits {$order1}, m.time {$order1}"; break; /* case 'threadstart': $orderby = "m.time {$order1}, m.ordering {$order1}, m.hits {$order1}"; break; */ /* case 'threadstart': $orderby = "m.time {$order1}, m.ordering {$order1}, m.hits {$order1}"; break; */ case 'forum': $orderby = "m.catid {$order1}, m.time {$order1}, m.ordering {$order1}"; break; /* case 'replycount': case 'postusername': */ /* case 'replycount': case 'postusername': */ case 'lastpost': default: $orderby = "m.time {$order1}, m.ordering {$order1}, m.catid {$order1}"; } if (count($groupby) > 0) { $groupby = ' GROUP BY ' . implode(',', $groupby); } else { $groupby = ''; } /* get total */ $this->db->setQuery("SELECT COUNT(*) FROM #__kunena_messages AS m JOIN #__kunena_messages_text AS t ON m.id=t.mesid WHERE {$where} {$groupby}"); $this->total = $this->db->loadResult(); KunenaError::checkDatabaseError(); /* if there are no forums to search in, set error and return */ if ($this->total == 0) { $this->int_kunena_errornr = 3; $this->str_kunena_errormsg = JText::_('COM_KUNENA_SEARCH_ERR_NOPOSTS'); return; } if ($this->total < $this->limitstart) { $this->limitstart = (int) ($this->total / $this->limit); } /* get results */ $sql = "SELECT m.id, m.subject, m.catid, m.thread, m.name, m.time, t.mesid, t.message,\n\t\t\t\t\t\tc.name AS catname, c.class_sfx\n \t\tFROM #__kunena_messages_text AS t JOIN #__kunena_messages AS m ON m.id=t.mesid\n \t\tJOIN #__kunena_categories AS c ON m.catid = c.id\n \t\tWHERE {$where} {$groupby} ORDER BY {$orderby}"; $this->db->setQuery($sql, $this->limitstart, $this->limit); $rows = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); $this->str_kunena_errormsg = $sql . '<br />' . $this->db->getErrorMsg(); if (count($rows) > 0) { $this->arr_kunena_results = $rows; } else { $this->arr_kunena_results = array(); } return; }
"> <td class = "td-1"> <div style = "float: right; width: 14ex;"></div> <span> <?php if ($user->userid == 0) { echo JText::_('COM_KUNENA_GUEST'); } else { echo CKunenaLink::GetProfileLink(intval($user->userid)); } ?> </span> <?php if (CKunenaTools::isAdmin($this->my->id) && $this->config->hide_ip) { echo '(' . $this->escape($user->userip) . ')'; } elseif (CKunenaTools::isModerator($this->my->id) && !$this->config->hide_ip) { echo '(' . $this->escape($user->userip) . ')'; } ?> </td> <td class = "td-2" nowrap = "nowrap"> <span title="<?php echo CKunenaTimeformat::showDate($user->time, 'config_post_dateformat_hover'); ?> "> <?php echo CKunenaTimeformat::showDate($user->time, 'config_post_dateformat'); ?> </span> </td>
function TagExtended(&$tag_new, &$task, $tag, $between) { /* # Function replaces TAGs with corresponding # Encode was already been called for between */ $kunena_config = KunenaFactory::getConfig(); $kunena_my =& JFactory::getUser(); if ($task->in_code) { switch (JString::strtolower($tag->name)) { case 'code:1': // fb ancient compatibility // fb ancient compatibility case 'code': $kunena_config = KunenaFactory::getConfig(); if ($kunena_config->highlightcode) { $between = preg_replace('/\\[table\\](.*?)\\[\\/table\\]/s', '', $between); if (KUNENA_JOOMLA_COMPAT == '1.5') { $path = JPATH_ROOT . '/libraries/geshi'; jimport('geshi.geshi'); } else { $path = JPATH_ROOT . '/plugins/content/geshi/geshi'; require_once $path . '/geshi.php'; } if (file_exists($path . '/geshi.php')) { $path .= '/geshi'; $type = isset($tag->options["type"]) ? $tag->options["type"] : "php"; if ($type == "js") { $type = "javascript"; } else { if ($type == "html") { $type = "html4strict"; } } if (!file_exists($path . '/' . $type . ".php")) { $type = "php"; } $code = str_replace("\t", "\t", $between); $geshi = new GeSHi($code, $type); //$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS,37); $geshi->enable_keyword_links(false); //$geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $code = $geshi->parse_code(); $code = str_replace("\n", "<br />", $code); //$code = ereg_replace(">([0-9]+)<br \/","><b>\\1.<\/b><br \/",$code); $tag_new = '<div class="highlight">' . $code . '</div>'; $task->in_code = FALSE; } else { return TAGPARSER_RET_NOTHING; } return TAGPARSER_RET_REPLACED; } else { $types = array("php", "mysql", "html", "js", "javascript"); if (!empty($tag->options["type"]) && in_array($tag->options["type"], $types)) { $t_type = $tag->options["type"]; } else { $t_type = "php"; } // Preserve spaces and tabs in code $code = str_replace("\t", "__KTAB__", $between); $code = str_replace("\r\n", "__KRN__", $code); $code = str_replace("\n", "__KRN__", $code); $code = str_replace("\r", "__KRN__", $code); $code = kunena_htmlspecialchars($code); $tag_new = "<div class=\"highlight\"><pre class=\"{$t_type}\">{$code}</pre></div>"; $task->in_code = FALSE; return TAGPARSER_RET_REPLACED; } break; default: break; } return TAGPARSER_RET_NOTHING; } switch (JString::strtolower($tag->name)) { // in general $between was already Encoded (if not explicitly suppressed!) case 'ol': // <br /> is not allowed inside <ol> $tag_new = "<ol>" . strtr($between, array("\r\n" => ' ', "\n" => ' ', "\r" => ' ')) . '</ol>'; return TAGPARSER_RET_REPLACED; break; case 'ul': // <br /> is not allowed inside <ul> $tag_new = "<ul>" . strtr($between, array("\r\n" => ' ', "\n" => ' ', "\r" => ' ')) . '</ul>'; return TAGPARSER_RET_REPLACED; break; case 'table': // <br /> is not allowed inside <table> $tag_new = "<table>" . strtr($between, array("\r\n" => ' ', "\n" => ' ', "\r" => ' ')) . '</table>'; return TAGPARSER_RET_REPLACED; break; case 'email': if (substr($between, 0, 7) == 'mailto:') { $tempstr = substr($between, 7); } $tag_new = kunenaBBCodeEmailCloak(array(1 => $between)); return TAGPARSER_RET_REPLACED; break; case 'url': $tempstr = $between; if (!preg_match("`^(/|https?://)`", $tempstr)) { $tempstr = 'http://' . $tempstr; } $tag_new = '<a href="' . $tempstr . '" rel="nofollow" target="_blank">' . $between . '</a>'; return TAGPARSER_RET_REPLACED; break; case 'img': $task->autolink_disable--; // continue autolink conversion if ($between) { if ($kunena_my->id == 0 && $kunena_config->showimgforguest == 0) { // Hide between content from non registered users $tag_new = '<b>' . JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEIMG') . '</b>'; return TAGPARSER_RET_REPLACED; } $fileurl = $between; if (!preg_match('`^(/|https?://)`', $fileurl)) { $fileurl = 'http://' . $fileurl; } if ($kunena_config->bbcode_img_secure != 'image') { static $file_ext = null; $matches = null; if (empty($file_ext)) { $params = JComponentHelper::getParams('com_media'); $file_ext = explode(',', $params->get('upload_extensions')); } preg_match('/\\.([\\w\\d]+)$/', $fileurl, $matches); if (!isset($matches[1]) || !in_array(JString::strtolower($matches[1]), $file_ext)) { // if the image has not exentions return it like a link and if it's allowed in configuration if ($kunena_config->bbcode_img_secure == 'link') { $tag_new = '<a href="' . $fileurl . '" rel="nofollow" target="_blank">' . $between . '</a>'; return TAGPARSER_RET_REPLACED; } else { $tag_new = $fileurl; return TAGPARSER_RET_REPLACED; } break; } } // Legacy attachments support (mostly used to remove image from attachments list), but also fixes broken links if (isset($this->parent->attachments) && strpos($fileurl, '/media/kunena/attachments/legacy/images/')) { // Make sure that filename does not contain path or URL $filename = $fileurl; if (($slash = strrpos($filename, '/')) !== false) { $filename = substr($filename, $slash + 1); } if (($slash = strrpos($filename, '\\')) !== false) { $filename = substr($filename, $slash + 1); } // Remove attachment from the attachments list and show it if it exists $attachments =& $this->parent->attachments; $attachment = null; foreach ($attachments as $att) { if ($att->filename == $filename && $att->folder == 'media/kunena/attachments/legacy/images') { $attachment = $att; unset($attachments[$att->id]); $this->parent->inline_attachments[$attachment->id] = $attachment; $tag_new = "<div class=\"kmsgimage\">{$attachment->imagelink}</div>"; return TAGPARSER_RET_REPLACED; } } // No match -- assume that we have normal img tag } // Make sure we add image size if specified $imgtagsize = isset($tag->options["size"]) ? (int) kunena_htmlspecialchars($tag->options["size"]) : 0; // Need to check if we are nested inside a URL code if ($task->autolink_disable == 0 && $kunena_config->lightbox) { $tag_new = '<div class="kmsgimage"><a href="' . $fileurl . '" title="" rel="lightbox[gallery]"><img src="' . $fileurl . '"' . ($imgtagsize ? ' width="' . $imgtagsize . '"' : '') . ' style="max-height:' . $kunena_config->imageheight . 'px; " alt="" /></a></div>'; } else { $tag_new = '<div class="kmsgimage"><img src="' . $fileurl . ($imgtagsize ? '" width="' . $imgtagsize : '') . '" style="max-height:' . $kunena_config->imageheight . 'px; " alt="" /></div>'; } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'file': $task->autolink_disable--; // continue autolink conversion if ($between) { if ($kunena_my->id == 0 && $kunena_config->showfileforguest == 0) { // Hide between content from non registered users $tag_new = '<b>' . JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEFILE') . '</b>'; return TAGPARSER_RET_REPLACED; } else { // Kunena 1.6: Added strict checks to make sure that user is not trying to do anything bad // URL is not used anymore -- we show attachments by using real path and current URL jimport('joomla.filesystem.file'); $filename = !empty($tag->options["name"]) ? $tag->options["name"] : $between; // Make sure that filename does not contain path or URL if (($slash = strrpos($filename, '/')) !== false) { $filename = substr($filename, $slash + 1); } if (($slash = strrpos($filename, '\\')) !== false) { $filename = substr($filename, $slash + 1); } $filepath = "attachments/legacy/files/{$filename}"; if (!is_file(KPATH_MEDIA . '/' . $filepath)) { // File does not exist (or URL was pointing somewhere else) $tag_new = '<div class="kmsgattach"><h4>' . JText::sprintf('COM_KUNENA_ATTACHMENT_DELETED', kunena_htmlspecialchars($filename)) . '</h4></div>'; return TAGPARSER_RET_REPLACED; } else { if (isset($this->parent->attachments)) { // Remove attachment from the attachments list $attachments =& $this->parent->attachments; foreach ($attachments as $att) { if ($att->filename == $filename && $att->folder == 'media/kunena/attachments/legacy/files') { $attachment = $att; unset($attachments[$att->id]); $this->parent->inline_attachments[$attachment->id] = $attachment; break; } } } $fileurl = KURL_MEDIA . $filepath; $filesize = isset($tag->options["size"]) ? $tag->options["size"] : filesize(KPATH_MEDIA . '/' . $filepath); $tag_new = '<div class="kmsgattach"><h4>' . JText::_('COM_KUNENA_FILEATTACH') . '</h4>'; $tag_new .= JText::_('COM_KUNENA_FILENAME') . ' <a href="' . $fileurl . '" target="_blank" rel="nofollow">' . kunena_htmlspecialchars($filename) . '</a><br />'; $tag_new .= JText::_('COM_KUNENA_FILESIZE') . ' ' . kunena_htmlspecialchars($filesize) . '</div>'; } } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'attachment': $task->autolink_disable--; // continue autolink conversion if (!is_object($this->parent) && !isset($this->parent->attachments)) { return TAGPARSER_RET_REPLACED; } $attachments =& $this->parent->attachments; $attachment = null; if (!empty($tag->options['default'])) { $attobj = CKunenaAttachments::getInstance(); $attachment = $attobj->getAttachment($tag->options["default"]); if (is_object($attachment)) { unset($attachments[$attachment->id]); } } else { if (empty($between)) { $attachment = array_shift($attachments); } else { if (!empty($attachments)) { foreach ($attachments as $att) { if ($att->filename == $between) { $attachment = $att; unset($attachments[$att->id]); break; } } } } } if (!$attachment && !empty($this->parent->inline_attachments)) { foreach ($this->parent->inline_attachments as $att) { if ($att->filename == $between) { $attachment = $att; break; } } } if (is_object($attachment) && !empty($attachment->disabled)) { // Hide between content from non registered users $tag_new = '<div class="kmsgattach">' . $attachment->textLink . '</div>'; } else { if (is_object($attachment) && is_file(JPATH_ROOT . "/{$attachment->folder}/{$attachment->filename}")) { $this->parent->inline_attachments[$attachment->id] = $attachment; $link = JURI::base() . "{$attachment->folder}/{$attachment->filename}"; if (empty($attachment->imagelink)) { $tag_new = '<div class="kmsgattach"><h4>' . JText::_('COM_KUNENA_FILEATTACH') . '</h4>' . JText::_('COM_KUNENA_FILENAME') . ' <a href="' . $link . '" target="_blank" rel="nofollow">' . $attachment->filename . '</a><br />' . JText::_('COM_KUNENA_FILESIZE') . ' ' . number_format(intval($attachment->size) / 1024, 0, '', ',') . ' KB' . '</div>'; } else { $tag_new = "<div class=\"kmsgimage\">{$attachment->imagelink}</div>"; } } else { $tag_new = '<div class="kmsgattach"><h4>' . JText::sprintf('COM_KUNENA_ATTACHMENT_DELETED', kunena_htmlspecialchars($between)) . '</h4></div>'; } } return TAGPARSER_RET_REPLACED; break; case 'quote': $post = isset($tag->options["post"]) ? $tag->options["post"] : false; $user = isset($tag->options["default"]) ? $tag->options["default"] : false; $tag_new = ''; if ($user) { $tag_new .= "<b>" . $user . " " . JText::_('COM_KUNENA_POST_WROTE') . ":</b>\n"; } $tag_new .= '<div class="kmsgtext-quote">' . $between . '</div>'; return TAGPARSER_RET_REPLACED; break; // // disable module bbcode // TODO: make safe to use - prevent public from calling modules that are not allowed // case 'module' : // if ($between) { // $tempstr = kunena_htmlspecialchars ( $between, ENT_QUOTES ); // // if (JDocumentHTML::countModules ( $tempstr )) { // $document = &JFactory::getDocument (); // $renderer = $document->loadRenderer ( 'modules' ); // $options = array ('style' => 'xhtml' ); // $position = $tempstr; // $tag_new = $renderer->render ( $position, $options, null ); // } else { // trigger_error ( 'Joomla module: ' . $tempstr . ' does not exist.', E_USER_NOTICE ); // } // // return TAGPARSER_RET_REPLACED; // } // return TAGPARSER_RET_NOTHING; // // break; // // disable module bbcode // TODO: make safe to use - prevent public from calling modules that are not allowed // case 'module' : // if ($between) { // $tempstr = kunena_htmlspecialchars ( $between, ENT_QUOTES ); // // if (JDocumentHTML::countModules ( $tempstr )) { // $document = &JFactory::getDocument (); // $renderer = $document->loadRenderer ( 'modules' ); // $options = array ('style' => 'xhtml' ); // $position = $tempstr; // $tag_new = $renderer->render ( $position, $options, null ); // } else { // trigger_error ( 'Joomla module: ' . $tempstr . ' does not exist.', E_USER_NOTICE ); // } // // return TAGPARSER_RET_REPLACED; // } // return TAGPARSER_RET_NOTHING; // // break; case 'article': if ($between) { $param = ''; if (!empty($tag->options['default'])) { $param = $tag->options['default']; } $articleid = (int) $between; $kunena_app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $kunena_db = JFactory::getDBO(); $user = JFactory::getUser(); $html = $link = ''; if (KUNENA_JOOMLA_COMPAT == '1.5') { $query = 'SELECT a.*, u.name AS author, u.usertype, cc.title AS category, s.title AS section, s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access FROM #__content AS a LEFT JOIN #__categories AS cc ON cc.id = a.catid LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content" LEFT JOIN #__users AS u ON u.id = a.created_by WHERE a.id=' . $kunena_db->quote($articleid); $kunena_db->setQuery($query); $article = $kunena_db->loadObject(); if ($article) { if (!$article->cat_pub && $article->catid || !$article->sec_pub && $article->sectionid) { $html = JText::_("Article cannot be shown"); } else { if ($article->cat_access > $user->get('aid', 0) && $article->catid || $article->sec_access > $user->get('aid', 0) && $article->sectionid || $article->access > $user->get('aid', 0)) { $html = JText::_("This message contains an article, but you do not have permissions to see it."); } } } else { $html = JText::_("Article cannot be shown"); } } else { $query = 'SELECT a.*, u.name AS author, u.usertype, cc.title AS category, cc.published AS cat_pub, cc.access AS cat_access FROM #__content AS a LEFT JOIN #__categories AS cc ON cc.id = a.catid LEFT JOIN #__users AS u ON u.id = a.created_by WHERE a.id=' . $kunena_db->quote($articleid); $kunena_db->setQuery($query); $article = $kunena_db->loadObject(); if ($article) { // Get credentials to check if the user has right to see the article $app = JFactory::getApplication('site'); $params = $app->getParams(); $registry = new JRegistry(); $registry->loadJSON($article->attribs); $article->params = clone $params; $article->params->merge($registry); $groups = $user->getAuthorisedViewLevels(); if (!$article->cat_pub && $article->catid) { $html = JText::_("Article cannot be shown"); } else { if (!in_array($article->access, $groups)) { $html = JText::_("This message contains an article, but you do not have permissions to see it."); } } } else { $html = JText::_("Article cannot be shown"); } } if (!$html) { require_once JPATH_ROOT . '/components/com_content/helpers/route.php'; if (KUNENA_JOOMLA_COMPAT == '1.5') { $url = JRoute::_(ContentHelperRoute::getArticleRoute($article->id, $article->catid, $article->sectionid)); } else { $slug = isset($article->alias) ? $article->id . ':' . $article->alias : $article->id; $catslug = isset($article->category_alias) ? $article->catid . ':' . $article->category_alias : $article->catid; $url = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug)); } // TODO: make configurable if (!$param) { $param = 'intro'; } switch ($param) { case 'full': if (!empty($article->fulltext)) { $article->text = $article->introtext . ' ' . $article->fulltext; $link = '<a href="' . $url . '" class="readon">' . JText::_('COM_KUNENA_READMORE') . '</a>'; break; } // continue to intro // continue to intro case 'intro': if (!empty($article->introtext)) { $article->text = $article->introtext; $link = '<a href="' . $url . '" class="readon">' . JText::_('COM_KUNENA_READMORE') . '</a>'; break; } // continue to link // continue to link case 'link': default: $link = '<a href="' . $url . '" class="readon">' . $article->title . '</a>'; break; } if (!empty($article->text)) { $params = clone $kunena_app->getParams('com_content'); $aparams = new JParameter($article->attribs); $params->merge($aparams); // Identify the source of the event to be Kunena itself // this is important to avoid recursive event behaviour with our own plugins $params->set('ksource', 'kunena'); JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onPrepareContent', array(&$article, &$params, 0)); $html = $article->text; } } $html = str_replace(array("\r\n", "\n", "\r"), "__KRN__", $html); $tag_new = '<div class="kmsgtext-article">' . $html . '</div>' . $link; return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'list': $type = isset($tag->options['type']) ? $tag->options['type'] : ''; $type = $type == 'decimal' ? 'ol' : 'ul'; $tag_new = "<{$type}>"; if (strstr($between, '[*]')) { $linearr = explode('[*]', $between); for ($i = 0; $i < count($linearr); $i++) { $tmp = JString::trim($linearr[$i]); if (strlen($tmp)) { $tag_new .= '<li>' . JString::trim($linearr[$i]) . '</li>'; } } } else { $tag_new .= strtr($between, array("\r\n" => ' ', "\n" => ' ', "\r" => ' ')); } $tag_new .= "</{$type}>"; return TAGPARSER_RET_REPLACED; break; case 'video': $task->autolink_disable--; if (!$between) { return TAGPARSER_RET_NOTHING; } // --- config start ------------ $vid_minwidth = 200; $vid_minheight = 44; // min. display size //$vid_maxwidth = 640; $vid_maxheight = 480; // max. display size $vid_maxwidth = (int) ($kunena_config->rtewidth * 9 / 10); // Max 90% of text width $vid_maxheight = 720; // max. display size $vid_sizemax = 100; // max. display zoom in percent // --- config end -------------- $vid["type"] = isset($tag->options["type"]) ? kunena_htmlspecialchars(JString::strtolower($tag->options["type"])) : ''; $vid["param"] = isset($tag->options["param"]) ? kunena_htmlspecialchars($tag->options["param"]) : ''; if (!$vid["type"]) { $vid_players = array('divx' => 'divx', 'flash' => 'swf', 'mediaplayer' => 'avi,mp3,wma,wmv', 'quicktime' => 'mov,qt,qti,qtif,qtvr', 'realplayer', 'rm'); foreach ($vid_players as $vid_player => $vid_exts) { foreach (explode(',', $vid_exts) as $vid_ext) { if (preg_match('/^(.*\\.' . $vid_ext . ')$/i', $between) > 0) { $vid["type"] = $vid_player; break 2; } } } unset($vid_players); } if (!$vid["type"]) { $vid_auto = preg_match('/^http:\\/\\/.*?([^.]*)\\.[^.]*(\\/|$)/', $between, $vid_regs) > 0; if ($vid_auto) { $vid["type"] = JString::strtolower($vid_regs[1]); switch ($vid["type"]) { case 'clip': $vid["type"] = 'clip.vn'; break; case 'web': $vid["type"] = 'web.de'; break; case 'wideo': $vid["type"] = 'wideo.fr'; break; } } } $vid_providers = array('animeepisodes' => array('flash', 428, 352, 0, 0, 'http://video.animeepisodes.net/vidiac.swf', '\\/([\\w\\-]*).htm', array(array(6, 'flashvars', 'video=%vcode%'))), 'biku' => array('flash', 450, 364, 0, 0, 'http://www.biku.com/opus/player.swf?VideoID=%vcode%&embed=true&autoStart=false', '\\/([\\w\\-]*).html', ''), 'bofunk' => array('flash', 446, 370, 0, 0, 'http://www.bofunk.com/e/%vcode%', '', ''), 'break' => array('flash', 464, 392, 0, 0, 'http://embed.break.com/%vcode%', '', ''), 'clip.vn' => array('flash', 448, 372, 0, 0, 'http://clip.vn/w/%vcode%,en,0', '\\/watch\\/([\\w\\-]*),vn', ''), 'clipfish' => array('flash', 464, 380, 0, 0, 'http://www.clipfish.de/videoplayer.swf?as=0&videoid=%vcode%&r=1&c=0067B3', 'videoid=([\\w\\-]*)', ''), 'clipshack' => array('flash', 430, 370, 0, 0, 'http://clipshack.com/player.swf?key=%vcode%', 'key=([\\w\\-]*)', array(array(6, 'wmode', 'transparent'))), 'collegehumor' => array('flash', 480, 360, 0, 0, 'http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=%vcode%&fullscreen=1', '\\/video:(\\d*)', ''), 'current' => array('flash', 400, 400, 0, 0, 'http://current.com/e/%vcode%', '\\/items\\/(\\d*)', array(array(6, 'wmode', 'transparent'))), 'dailymotion' => array('flash', 420, 331, 0, 0, 'http://www.dailymotion.com/swf/%vcode%', '\\/video\\/([a-zA-Z0-9]*)', ''), 'downloadfestival' => array('flash', 450, 358, 0, 0, 'http://www.downloadfestival.tv/mofo/video/player/playerb003External.swf?rid=%vcode%', '\\/watch\\/([\\d]*)', ''), 'fliptrack' => array('flash', 402, 302, 0, 0, 'http://www.fliptrack.com/v/%vcode%', '\\/watch\\/([\\w\\-]*)', ''), 'fliqz' => array('flash', 450, 392, 0, 0, 'http://content.fliqz.com/components/2d39cfef9385473c89939c2a5a7064f5.swf', 'vid=([\\w]*)', array(array(6, 'flashvars', 'file=%vcode%&'), array(6, 'wmode', 'transparent'), array(6, 'bgcolor', '#000000'))), 'gametrailers' => array('flash', 480, 392, 0, 0, 'http://www.gametrailers.com/remote_wrap.php?mid=%vcode%', '\\/(\\d*).html', ''), 'gamevideos' => array('flash', 420, 405, 0, 0, 'http://www.gamevideos.com/swf/gamevideos11.swf?embedded=1&fullscreen=1&autoplay=0&src=http://www.gamevideos.com/video/videoListXML%3Fid%3D%vcode%%26adPlay%3Dfalse', '\\/video\\/id\\/(\\d*)', array(array(6, 'bgcolor', '#000000'), array(6, 'wmode', 'window'))), 'glumbert' => array('flash', 448, 336, 0, 0, 'http://www.glumbert.com/embed/%vcode%', '\\/media\\/([\\w\\-]*)', array(array(6, 'wmode', 'transparent'))), 'gmx' => array('flash', 425, 367, 0, 0, 'http://video.gmx.net/movie/%vcode%', '\\/watch\\/(\\d*)', ''), 'google' => array('flash', 400, 326, 0, 0, 'http://video.google.com/googleplayer.swf?docId=%vcode%', 'docid=(\\d*)', ''), 'googlyfoogly' => array('mediaplayer', 400, 300, 0, 25, 'http://media.googlyfoogly.com/images/videos/%vcode%.wmv', '', ''), 'ifilm' => array('flash', 448, 365, 0, 0, 'http://www.ifilm.com/efp', '\\/video\\/(\\d*)', array(array(6, 'flashvars', 'flvbaseclip=%vcode%'))), 'jumpcut' => array('flash', 408, 324, 0, 0, 'http://jumpcut.com/media/flash/jump.swf?id=%vcode%&asset_type=movie&asset_id=%vcode%&eb=1', '\\/\\?id=([\\w\\-]*)', ''), 'kewego' => array('flash', 400, 368, 0, 0, 'http://www.kewego.com/p/en/%vcode%.html', '\\/([\\w\\-]*)\\.html', array(array(6, 'wmode', 'transparent'))), 'liveleak' => array('flash', 450, 370, 0, 0, 'http://www.liveleak.com/player.swf', '\\/view\\?i=([\\w\\-]*)', array(array(6, 'flashvars', 'autostart=false&token=%vcode%'), array(6, 'wmode', 'transparent'))), 'livevideo' => array('flash', 445, 369, 0, 0, 'http://www.livevideo.com/flvplayer/embed/%vcode%', '', ''), 'megavideo' => array('flash', 432, 351, 0, 0, 'http://www.megavideo.com/v/%vcode%..0', '', array(array(6, 'wmode', 'transparent'))), 'metacafe' => array('flash', 400, 345, 0, 0, 'http://www.metacafe.com/fplayer/%vcode%/.swf', '\\/watch\\/(\\d*\\/[\\w\\-]*)', array(array(6, 'wmode', 'transparent'))), 'mofile' => array('flash', 480, 395, 0, 0, 'http://tv.mofile.com/cn/xplayer.swf', '\\.com\\/([\\w\\-]*)', array(array(6, 'flashvars', 'v=%vcode%&autoplay=0&nowSkin=0_0'), array(6, 'wmode', 'transparent'))), 'multiply' => array('flash', 400, 350, 0, 0, 'http://images.multiply.com/multiply/multv.swf', '', array(array(6, 'flashvars', 'first_video_id=%vcode%&base_uri=multiply.com&is_owned=1'))), 'myspace' => array('flash', 430, 346, 0, 0, 'http://lads.myspace.com/videos/vplayer.swf', 'VideoID=(\\d*)', array(array(6, 'flashvars', 'm=%vcode%&v=2&type=video'))), 'myvideo' => array('flash', 470, 406, 0, 0, 'http://www.myvideo.de/movie/%vcode%', '\\/watch\\/(\\d*)', ''), 'quxiu' => array('flash', 437, 375, 0, 0, 'http://www.quxiu.com/photo/swf/swfobj.swf?id=%vcode%', '\\/play_([\\d_]*)\\.htm', array(array(6, 'menu', 'false'))), 'revver' => array('flash', 480, 392, 0, 0, 'http://flash.revver.com/player/1.0/player.swf?mediaId=%vcode%', '\\/video\\/([\\d_]*)', ''), 'rutube' => array('flash', 400, 353, 0, 0, 'http://video.rutube.ru/%vcode%', '\\.html\\?v=([\\w]*)'), 'sapo' => array('flash', 400, 322, 0, 0, 'http://rd3.videos.sapo.pt/play?file=http://rd3.videos.sapo.pt/%vcode%/mov/1', 'videos\\.sapo\\.pt\\/([\\w]*)', array(array(6, 'wmode', 'transparent'))), 'sevenload' => array('flash', 425, 350, 0, 0, 'http://sevenload.com/pl/%vcode%/425x350/swf', '\\/videos\\/([\\w]*)', array(array(6, 'flashvars', 'apiHost=api.sevenload.com&showFullScreen=1'))), 'sharkle' => array('flash', 340, 310, 0, 0, 'http://sharkle.com/sharkle.swf?rnd=%vcode%&buffer=3', '', array(array(6, 'wmode', 'transparent'))), 'spikedhumor' => array('flash', 400, 345, 0, 0, 'http://www.spikedhumor.com/player/vcplayer.swf?file=http://www.spikedhumor.com/videocodes/%vcode%/data.xml&auto_play=false', '\\/articles\\/([\\d]*)', ''), 'stickam' => array('flash', 400, 300, 0, 0, 'http://player.stickam.com/flashVarMediaPlayer/%vcode%', 'mId=([\\d]*)', ''), 'streetfire' => array('flash', 428, 352, 0, 0, 'http://videos.streetfire.net/vidiac.swf', '\\/([\\w-]*).htm', array(array(6, 'flashvars', 'video=%vcode%'))), 'stupidvideos' => array('flash', 451, 433, 0, 0, 'http://img.purevideo.com/images/player/player.swf?sa=1&sk=5&si=2&i=%vcode%', '\\/\\?m=new#([\\d_]*)', ''), 'toufee' => array('flash', 550, 270, 0, 0, 'http://toufee.com/movies/Movie.swf', 'u=[a-zA-Z]*(\\d*)', array(array(6, 'flashvars', 'movieID=%vcode%&domainName=toufee'))), 'tudou' => array('flash', 400, 300, 0, 0, 'http://www.tudou.com/v/%vcode%', '\\/view\\/([\\w-]*)', array(array(6, 'wmode', 'transparent'))), 'unf-unf' => array('flash', 425, 350, 0, 0, 'http://www.unf-unf.de/video/flvplayer.swf?file=http://www.unf-unf.de/video/clips/%vcode%.flv', '\\/([\\w-]*).html', array(array(6, 'wmode', 'transparent'))), 'uume' => array('flash', 400, 342, 0, 0, 'http://www.uume.com/v/%vcode%_UUME', '\\/play_([\\w-]*)', ''), 'veoh' => array('flash', 540, 438, 0, 0, 'http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=%vcode%', '\\/videos\\/([\\w-]*)', ''), 'videoclipsdump' => array('flash', 480, 400, 0, 0, 'http://www.videoclipsdump.com/player/simple.swf', '', array(array(6, 'flashvars', 'url=http://www.videoclipsdump.com/files/%vcode%.flv&autoplay=0&watermark=http://www.videoclipsdump.com/flv_watermark.php&buffer=10&full=0&siteurl=http://www.videoclipsdump.com&interval=10000&totalrotate=3'))), 'videojug' => array('flash', 400, 345, 0, 0, 'http://www.videojug.com/film/player?id=%vcode%', '', ''), 'videotube' => array('flash', 480, 400, 0, 0, 'http://www.videotube.de/flash/player.swf', '\\/watch\\/(\\d*)', array(array(6, 'flashvars', 'baseURL=http://www.videotube.de/watch/%vcode%'), array(6, 'wmode', 'transparent'))), 'vidiac' => array('flash', 428, 352, 0, 0, 'http://www.vidiac.com/vidiac.swf', '\\/([\\w-]*).htm', array(array(6, 'flashvars', 'video=%vcode%'))), 'vidilife' => array('flash', 445, 369, 0, 0, 'http://www.vidiLife.com/flash/flvplayer.swf?autoStart=0&popup=1&video=http://www.vidiLife.com/media/flash_api.cfm?id=%vcode%&version=8', '', ''), 'vimeo' => array('flash', 400, 321, 0, 0, 'http://www.vimeo.com/moogaloop.swf?clip_id=%vcode%&server=www.vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=0&color=', '\\.com\\/(\\d*)', ''), 'wangyou' => array('flash', 441, 384, 0, 0, 'http://v.wangyou.com/images/x_player.swf?id=%vcode%', '\\/p(\\d*).html', array(array(6, 'wmode', 'transparent'))), 'web.de' => array('flash', 425, 367, 0, 0, 'http://video.web.de/movie/%vcode%', '\\/watch\\/(\\d*)', ''), 'wideo.fr' => array('flash', 400, 368, 0, 0, 'http://www.wideo.fr/p/fr/%vcode%.html', '\\/([\\w-]*).html', array(array(6, 'wmode', 'transparent'))), 'youku' => array('flash', 480, 400, 0, 0, 'http://player.youku.com/player.php/sid/%vcode%/v.swf', '\\/v_show\\/id_(.*)\\.html', ''), 'youtube' => array('flash', 425, 355, 0, 0, 'http://www.youtube.com/v/%vcode%?fs=1&hd=0&rel=1', '\\/watch\\?v=([\\w\\-]*)', array(array(6, 'wmode', 'transparent')))); if (isset($vid_providers[$vid["type"]])) { list($vid_type, $vid_width, $vid_height, $vid_addx, $vid_addy, $vid_source, $vid_match, $vid_par2) = isset($vid_providers[$vid["type"]]) ? $vid_providers[$vid["type"]] : $vid_providers["_default"]; } else { return TAGPARSER_RET_NOTHING; } unset($vid_providers); if (!empty($vid_auto)) { if ($vid_match and preg_match("/{$vid_match}/i", $between, $vid_regs) > 0) { $between = $vid_regs[1]; } else { return TAGPARSER_RET_NOTHING; } } $vid_source = preg_replace('/%vcode%/', $between, $vid_source); if (!is_array($vid_par2)) { $vid_par2 = array(); } $vid_size = isset($tag->options["size"]) ? intval($tag->options["size"]) : 0; if ($vid_size > 0 and $vid_size < $vid_sizemax) { $vid_width = (int) ($vid_width * $vid_size / 100); $vid_height = (int) ($vid_height * $vid_size / 100); } $vid_width += $vid_addx; $vid_height += $vid_addy; if (!isset($tag->options["size"])) { if (isset($tag->options["width"])) { if ($tag->options['width'] == '1') { $tag->options['width'] = $vid_minwidth; } } if (isset($tag->options["width"])) { $vid_width = intval($tag->options["width"]); } if (isset($tag->options["height"])) { if ($tag->options['height'] == '1') { $tag->options['height'] = $vid_minheight; } } if (isset($tag->options["height"])) { $vid_height = intval($tag->options["height"]); } } if ($vid_width < $vid_minwidth) { $vid_width = $vid_minwidth; } if ($vid_width > $vid_maxwidth) { $vid_width = $vid_maxwidth; } if ($vid_height < $vid_minheight) { $vid_height = $vid_minheight; } if ($vid_height > $vid_maxheight) { $vid_height = $vid_maxheight; } switch ($vid_type) { case 'divx': $vid_par1 = array(array(1, 'classid', 'clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616'), array(1, 'codebase', 'http://go.divx.com/plugin/DivXBrowserPlugin.cab'), array(4, 'type', 'video/divx'), array(4, 'pluginspage', 'http://go.divx.com/plugin/download/'), array(6, 'src', $vid_source), array(6, 'autoplay', 'false'), array(5, 'width', $vid_width), array(5, 'height', $vid_height)); $vid_allowpar = array('previewimage'); break; case 'flash': $vid_par1 = array(array(1, 'classid', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'), array(1, 'codebase', 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab'), array(2, 'movie', $vid_source), array(4, 'src', $vid_source), array(4, 'type', 'application/x-shockwave-flash'), array(4, 'pluginspage', 'http://www.macromedia.com/go/getflashplayer'), array(6, 'quality', 'high'), array(6, 'allowFullScreen', 'true'), array(6, 'allowScriptAccess', 'never'), array(5, 'width', $vid_width), array(5, 'height', $vid_height)); $vid_allowpar = array('flashvars', 'wmode', 'bgcolor', 'quality'); break; case 'mediaplayer': $vid_par1 = array(array(1, 'classid', 'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'), array(1, 'codebase', 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab'), array(4, 'type', 'application/x-mplayer2'), array(4, 'pluginspage', 'http://www.microsoft.com/Windows/MediaPlayer/'), array(6, 'src', $vid_source), array(6, 'autostart', 'false'), array(6, 'autosize', 'true'), array(5, 'width', $vid_width), array(5, 'height', $vid_height)); $vid_allowpar = array(); break; case 'quicktime': $vid_par1 = array(array(1, 'classid', 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'), array(1, 'codebase', 'http://www.apple.com/qtactivex/qtplugin.cab'), array(4, 'type', 'video/quicktime'), array(4, 'pluginspage', 'http://www.apple.com/quicktime/download/'), array(6, 'src', $vid_source), array(6, 'autoplay', 'false'), array(6, 'scale', 'aspect'), array(5, 'width', $vid_width), array(5, 'height', $vid_height)); $vid_allowpar = array(); break; case 'realplayer': $vid_par1 = array(array(1, 'classid', 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'), array(4, 'type', 'audio/x-pn-realaudio-plugin'), array(6, 'src', $vid_source), array(6, 'autostart', 'false'), array(6, 'controls', 'ImageWindow,ControlPanel'), array(5, 'width', $vid_width), array(5, 'height', $vid_height)); $vid_allowpar = array(); break; default: return TAGPARSER_RET_NOTHING; } $vid_par3 = array(); foreach ($tag->options as $vid_key => $vid_value) { if (in_array(JString::strtolower($vid_key), $vid_allowpar)) { array_push($vid_par3, array(6, $vid_key, kunena_htmlspecialchars($vid_value))); } } $vid_object = $vid_param = $vid_embed = array(); foreach (array_merge($vid_par1, $vid_par2, $vid_par3) as $vid_data) { list($vid_key, $vid_name, $vid_value) = $vid_data; if ($vid_key & 1) { $vid_object[$vid_name] = ' ' . $vid_name . '="' . preg_replace('/%vcode%/', $between, $vid_value) . '"'; } if ($vid_key & 2) { $vid_param[$vid_name] = '<param name="' . $vid_name . '" value="' . preg_replace('/%vcode%/', $between, $vid_value) . '" />'; } if ($vid_key & 4) { $vid_embed[$vid_name] = ' ' . $vid_name . '="' . preg_replace('/%vcode%/', $between, $vid_value) . '"'; } } $tag_new = '<object'; foreach ($vid_object as $vid_data) { $tag_new .= $vid_data; } $tag_new .= '>'; foreach ($vid_param as $vid_data) { $tag_new .= $vid_data; } $tag_new .= '<embed'; foreach ($vid_embed as $vid_data) { $tag_new .= $vid_data; } $tag_new .= ' /></object>'; return TAGPARSER_RET_REPLACED; break; case 'ebay': if ($between) { $task->autolink_disable--; // continue autolink conversion $ebay_maxwidth = (int) ($kunena_config->rtewidth * 9 / 10); // Max 90% of text width $ebay_maxheight = (int) $kunena_config->rteheight; // max. display size $tag_new = ""; if (is_numeric($between)) { // Numeric: we have to assume this is an item id $tag_new .= '<object width="' . $ebay_maxwidth . '" height="' . $ebay_maxheight . '"><param name="movie" value="http://togo.ebay.com/togo/togo.swf" /><param name="flashvars" value="base=http://togo.ebay.com/togo/&lang=' . $kunena_config->ebaylanguagecode . '&mode=normal&itemid=' . $between . '&campid=5336042350" /><embed src="http://togo.ebay.com/togo/togo.swf" type="application/x-shockwave-flash" width="355" height="300" flashvars="base=http://togo.ebay.com/togo/&lang=' . $kunena_config->ebaylanguagecode . '&mode=normal&itemid=' . $between . '&campid=5336042350"></embed></object>'; } else { // Non numeric: we have to assume this is a search $tag_new .= '<object width="' . $ebay_maxwidth . '" height="' . $ebay_maxheight . '"><param name="movie" value="http://togo.ebay.com/togo/togo.swf?2008013100" /><param name="flashvars" value="base=http://togo.ebay.com/togo/&lang=' . $kunena_config->ebaylanguagecode . '&mode=search&query=' . $between . '&campid=5336042350" /><embed src="http://togo.ebay.com/togo/togo.swf?2008013100" type="application/x-shockwave-flash" width="355" height="300" flashvars="base=http://togo.ebay.com/togo/&lang=' . $kunena_config->ebaylanguagecode . '&mode=search&query=' . $between . '&campid=5336042350"></embed></object>'; } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'map': if ($between) { $task->autolink_disable--; // continue autolink conversion $map_maxwidth = (int) ($kunena_config->rtewidth * 9 / 10); // Max 90% of text width $map_maxheight = (int) $kunena_config->rteheight; // max. display size $kmap =& KunenaGoogleMaps::getInstance(); $tag_new = $kmap->addMap($between); return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'tableau': if ($between) { $task->autolink_disable--; // continue autolink conversion $viz_maxwidth = (int) ($kunena_config->rtewidth * 9 / 10); // Max 90% of text width $viz_maxheight = isset($tag->options["height"]) && is_numeric($tag->options["height"]) ? (int) $tag->options["height"] : (int) $kunena_config->rteheight; //$url_data = parse_url ( $between ); if (preg_match('/(https?:\\/\\/.*?)\\/(?:.*\\/)*(.*\\/.*)\\?.*:toolbar=(yes|no)/', $between, $matches)) { $tableauserver = $matches[1]; $vizualization = $matches[2]; $toolbar = $matches[3]; $tag_new = '<script type="text/javascript" src="' . $tableauserver . '/javascripts/api/viz_v1.js"></script><object class="tableauViz" width="' . $viz_maxwidth . '" height="' . $viz_maxheight . '" style="display:none;"><param name="name" value="' . $vizualization . '" /><param name="toolbar" value="' . $toolbar . '" /></object>'; } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'hide': if ($between) { if ($kunena_my->id == 0) { // Hide between content from non registered users $tag_new = JText::_('COM_KUNENA_BBCODE_HIDDENTEXT'); } else { // Display but highlight the fact that it is hidden from guests $tag_new = '<b>' . JText::_('COM_KUNENA_BBCODE_HIDE_IN_MESSAGE') . '</b>' . '<div class="kmsgtext-hide">' . $between . '</div>'; } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'confidential': if ($between) { if (!empty($this->parent->msg->userid) && $this->parent->msg->userid == $kunena_my->id || !empty($this->parent->catid) && CKunenaTools::isModerator($kunena_my->id, $this->parent->catid)) { // Display but highlight the fact that it is hidden from everyone except admins and mods $tag_new = '<b>' . JText::_('COM_KUNENA_BBCODE_CONFIDENTIAL_TEXT') . '</b><div class="kmsgtext-confidential">' . $between . '</div>'; } return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'spoiler': if ($between) { if ($this->spoilerid == 0) { // Only need the script for the first spoiler we find $kunena_document = JFactory::getDocument(); $kunena_document->addCustomTag('<script language = "JavaScript" type = "text/javascript">' . 'function kShowDetail(srcElement) {' . 'var targetID, srcElement, targetElement, imgElementID, imgElement;' . 'targetID = srcElement.id + "_details";' . 'imgElementID = srcElement.id + "_img";' . 'targetElement = document.getElementById(targetID);' . 'imgElement = document.getElementById(imgElementID);' . 'if (targetElement.style.display == "none") {' . 'targetElement.style.display = "";' . 'imgElement.src = "' . KUNENA_JLIVEURL . '/components/com_kunena/template/default/images/emoticons/w00t.png";' . '} else {' . 'targetElement.style.display = "none";' . 'imgElement.src = "' . KUNENA_JLIVEURL . '/components/com_kunena/template/default/images/emoticons/pinch.png";' . '}} </script>'); } $this->spoilerid++; $randomid = 'spoiler_' . rand(); $tag_new = '<div id="' . $randomid . '" onclick="javascript:kShowDetail(this);" class = "kspoiler" ><img id="' . $randomid . '_img"' . ' src="' . KUNENA_JLIVEURL . '/components/com_kunena/template/default/images/emoticons/pinch.png" border="0" alt=":pinch:" /> <strong>' . (isset($tag->options["title"]) ? $tag->options["title"] : JText::_('COM_KUNENA_BBCODE_SPOILER')) . '</strong></div><div id="' . $randomid . '_details" style="display:none;"><span class="fb_quote">' . $between . '</span></div>'; return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; case 'spoilerlight': if ($between) { $tag_new = '<span title="' . $between . '"><strong>' . JText::_('COM_KUNENA_EDITOR_SPOILER') . '</strong></span>'; return TAGPARSER_RET_REPLACED; } return TAGPARSER_RET_NOTHING; break; default: break; } return TAGPARSER_RET_NOTHING; }
protected function checkAuthorName($field, $value) { if (!$this->_my->id || $this->getOption('anonymous')) { // Unregistered or anonymous users: Do not allow existing username jimport('joomla.user.helper'); $nicktaken = JUserHelper::getUserId($value); if (empty($value) || $nicktaken || $value == $this->_my->name) { $this->set('name', $name = JText::_('COM_KUNENA_USERNAME_ANONYMOUS')); $this->_app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_FIELD_NAME_CONFLICT_ANON', $value, $name), 'notice'); } } else { // Registered users if (empty($value)) { return $this->setError($field, JText::_('COM_KUNENA_POST_FIELD_NAME_EMPTY')); } if (CKunenaTools::isModerator($this->_my->id, $this->parent->catid)) { // Moderators can to do whatever they want to } else { if ($this->_config->changename) { // Others are not allowed to use username from other users jimport('joomla.user.helper'); $nicktaken = JUserHelper::getUserId($value); if ($nicktaken && $nicktaken != $this->_my->id) { return $this->setError($field, JText::_('COM_KUNENA_POST_FIELD_NAME_CONFLICT_REG')); } } else { $this->set('name', $this->_myuser->getName()); } } } return true; }
?> <label id="childforums-lbl"> <input type="checkbox" name="childforums" value="1" <?php if ($this->params['childforums']) { echo 'checked="checked"'; } ?> /> <span onclick="document.adminForm.childforums.checked=(! document.adminForm.childforums.checked);"><?php echo JText::_('COM_KUNENA_SEARCH_SEARCHIN_CHILDREN'); ?> </span> </label> </fieldset> <?php if (CKunenaTools::isModerator($this->my->id)) { ?> <fieldset class="fieldset"> <legend><?php echo JText::_('COM_KUNENA_SEARCH_SHOW'); ?> </legend> <input id="show0" type="radio" name="show" value="0" <?php if ($this->params['show'] == 0) { echo 'checked="checked"'; } ?> /> <label for="show0"><?php echo JText::_('COM_KUNENA_SEARCH_SHOW_NORMAL'); ?>
function __construct($userid, $do = '') { $this->_app = JFactory::getApplication(); $this->my = JFactory::getUser(); $this->do = $do; if ($this->do == 'login') { return $this->login(); } elseif ($this->do == 'logout') { return $this->logout(); } kimport('html.parser'); require_once KPATH_SITE . '/lib/kunena.timeformat.class.php'; $this->_db = JFactory::getDBO(); $this->config = KunenaFactory::getConfig(); if (!$userid) { $this->user = $this->my; } else { $this->user = JFactory::getUser($userid); } if ($this->user->id == 0 || $this->my->id == 0 && !$this->config->pubprofile) { $this->allow = false; $this->header = JText::_('COM_KUNENA_LOGIN_NOTIFICATION'); $this->body = JText::_('COM_KUNENA_PROFILEPAGE_NOT_ALLOWED_FOR_GUESTS') . ' ' . JText::_('COM_KUNENA_NO_ACCESS'); CKunenaTools::loadTemplate('/login.php'); return; } $integration = KunenaFactory::getProfile(); $activityIntegration = KunenaFactory::getActivityIntegration(); $template = KunenaFactory::getTemplate(); $this->params = $template->params; if (get_class($integration) == 'KunenaProfileNone') { $this->allow = false; $this->header = JText::_('COM_KUNENA_PROFILE_DISABLED'); $this->body = JText::_('COM_KUNENA_PROFILE_DISABLED') . ' ' . JText::_('COM_KUNENA_NO_ACCESS'); CKunenaTools::loadTemplate('/login.php'); return; } $this->allow = true; $this->profile = KunenaFactory::getUser($this->user->id); if (!$this->profile->exists()) { $this->profile->save(); } if ($this->profile->userid == $this->my->id) { if ($this->do != 'edit') { $this->editlink = CKunenaLink::GetMyProfileLink($this->profile->userid, JText::_('COM_KUNENA_EDIT'), 'nofollow', 'edit'); } else { $this->editlink = CKunenaLink::GetMyProfileLink($this->profile->userid, JText::_('COM_KUNENA_BACK'), 'nofollow'); } } $this->name = $this->user->username; if ($this->config->userlist_name) { $this->name = $this->user->name . ' (' . $this->name . ')'; } if ($this->config->showuserstats) { if ($this->config->userlist_usertype) { $this->usertype = $this->user->usertype; } $this->rank_image = $this->profile->getRank(0, 'image'); $this->rank_title = $this->profile->getRank(0, 'title'); $this->posts = $this->profile->posts; $this->userpoints = $activityIntegration->getUserPoints($this->profile->userid); $this->usermedals = $activityIntegration->getUserMedals($this->profile->userid); } if ($this->config->userlist_joindate || CKunenaTools::isModerator($this->my->id)) { $this->registerdate = $this->user->registerDate; } if ($this->config->userlist_lastvisitdate || CKunenaTools::isModerator($this->my->id)) { $this->lastvisitdate = $this->user->lastvisitDate; } $this->avatarlink = $this->profile->getAvatarLink('kavatar', 'profile'); $this->personalText = $this->profile->personalText; $this->signature = $this->profile->signature; $this->timezone = $this->user->getParam('timezone', $this->_app->getCfg('offset', 0)); $this->moderator = CKunenaTools::isModerator($this->profile->userid); $this->admin = CKunenaTools::isAdmin($this->profile->userid); switch ($this->profile->gender) { case 1: $this->genderclass = 'male'; $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_MALE'); break; case 2: $this->genderclass = 'female'; $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_FEMALE'); break; default: $this->genderclass = 'unknown'; $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_UNKNOWN'); } if ($this->profile->location) { $this->locationlink = '<a href="http://maps.google.com?q=' . kunena_htmlspecialchars($this->profile->location) . '" target="_blank">' . kunena_htmlspecialchars($this->profile->location) . '</a>'; } else { $this->locationlink = JText::_('COM_KUNENA_LOCATION_UNKNOWN'); } $this->online = $this->profile->isOnline(); $this->showUnusedSocial = true; $avatar = KunenaFactory::getAvatarIntegration(); $this->editavatar = is_a($avatar, 'KunenaAvatarKunena') ? true : false; kimport('userban'); $this->banInfo = KunenaUserBan::getInstanceByUserid($userid, true); $this->canBan = $this->banInfo->canBan(); if ($this->config->showbannedreason) { $this->banReason = $this->banInfo->reason_public; } }
function loadCategories() { if ($this->_loaded) { return; } $this->_loaded = true; $catids = array(); foreach ($this->categories[0] as $cat) { $catids[] = $cat->id; } if (empty($catids)) { return; } $catlist = implode(',', $catids); $readlist = $this->session->readtopics; if ($this->config->shownew && $this->my->id) { $subquery = " (SELECT COUNT(DISTINCT thread) FROM #__kunena_messages AS mmm WHERE c.id=mmm.catid AND mmm.hold='0' AND mmm.time>{$this->db->Quote($this->prevCheck)} AND mmm.thread NOT IN ({$readlist})) AS new"; } else { $subquery = " 0 AS new"; } // TODO: optimize this query (just combined many queries into one) $query = "SELECT c.*, m.id AS mesid, m.thread, m.catid, t.subject AS topicsubject, m.subject, m.name AS mname, u.id AS userid, u.username, u.name AS uname,\n\t\t\t(SELECT COUNT(*) FROM #__kunena_messages AS mm WHERE m.thread=mm.thread) AS msgcount, {$subquery}\n\t\t\tFROM #__kunena_categories AS c\n\t\t\tLEFT JOIN #__kunena_messages AS m ON c.id_last_msg=m.id\n\t\t\tLEFT JOIN #__kunena_messages AS t ON m.thread=t.id\n\t\t\tLEFT JOIN #__users AS u ON u.id=m.userid\n\t\t\tWHERE c.parent IN ({$catlist}) AND c.published='1' AND c.id IN({$this->session->allowed}) ORDER BY ordering, name"; $this->db->setQuery($query); $allsubcats = $this->db->loadObjectList(); if (KunenaError::checkDatabaseError()) { return; } $this->tabclass = array("row1", "row2"); $subcats = array(); $routerlist = array(); $userlist = array(); $myprofile = KunenaFactory::getUser(); if ($myprofile->ordering != '0') { $topic_ordering = $myprofile->ordering == '1' ? true : false; } else { $topic_ordering = $this->config->default_sort == 'asc' ? false : true; } foreach ($allsubcats as $i => $subcat) { if ($subcat->mesid) { $routerlist[$subcat->thread] = $subcat->subject; } if ($topic_ordering) { $subcat->page = 1; } else { $subcat->page = ceil($subcat->msgcount / $this->config->messages_per_page); } if ($this->config->shownew && $this->my->id != 0) { if ($subcat->new) { // Check Unread Cat Images if (is_file(KUNENA_ABSCATIMAGESPATH . $subcat->id . "_on.gif")) { $allsubcats[$i]->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $subcat->id . "_on.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $allsubcats[$i]->htmlCategoryIcon = CKunenaTools::showIcon('kunreadforum', JText::_('COM_KUNENA_GEN_FORUM_NEWPOST')); } } else { // Check Read Cat Images if (is_file(KUNENA_ABSCATIMAGESPATH . $subcat->id . "_off.gif")) { $allsubcats[$i]->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $subcat->id . "_off.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $allsubcats[$i]->htmlCategoryIcon = CKunenaTools::showIcon('kreadforum', JText::_('COM_KUNENA_GEN_FORUM_NOTNEW')); } } } else { if (is_file(KUNENA_ABSCATIMAGESPATH . $subcat->id . "_notlogin.gif")) { $allsubcats[$i]->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $subcat->id . "_notlogin.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $allsubcats[$i]->htmlCategoryIcon = CKunenaTools::showIcon('knotloginforum', JText::_('COM_KUNENA_GEN_FORUM_NOTNEW')); } } // collect user ids for avatar prefetch when integrated $userlist[intval($subcat->userid)] = intval($subcat->userid); } require_once KUNENA_PATH . '/router.php'; KunenaRouter::loadMessages($routerlist); $modcats = array(); foreach ($allsubcats as $subcat) { $this->categories[$subcat->parent][] = $subcat; $subcats[] = $subcat->id; if ($subcat->moderated) { $modcats[] = $subcat->id; } } // Get the childforums $this->childforums = array(); if (count($subcats)) { $subcatlist = implode(',', $subcats); if ($this->config->shownew && $this->my->id) { $subquery = " (SELECT COUNT(DISTINCT thread) FROM #__kunena_messages AS m WHERE c.id=m.catid AND m.hold='0' AND m.time>{$this->db->Quote($this->prevCheck)} AND m.thread NOT IN ({$readlist})) AS new"; } else { $subquery = "0 AS new"; } $query = "SELECT c.id, c.name, c.description, c.parent, c.numTopics, c.numPosts, {$subquery}\n\t\t\tFROM #__kunena_categories AS c\n\t\t\tWHERE c.parent IN ({$subcatlist}) AND c.published='1' AND c.id IN({$this->session->allowed}) ORDER BY c.ordering, c.name"; $this->db->setQuery($query); $childforums = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); foreach ($childforums as $i => $childforum) { //Begin: parent read unread iconset if ($this->config->showchildcaticon) { if ($this->config->shownew && $this->my->id != 0) { if ($childforum->new) { // Check Unread Cat Images if (is_file(KUNENA_ABSCATIMAGESPATH . $childforum->id . "_on_childsmall.gif")) { $childforum->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $childforum->id . "_on_childsmall.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $childforum->htmlCategoryIcon = CKunenaTools::showIcon('kunreadforum-sm', JText::_('COM_KUNENA_GEN_FORUM_NEWPOST')); } } else { // Check Read Cat Images if (is_file(KUNENA_ABSCATIMAGESPATH . $childforum->id . "_off_childsmall.gif")) { $childforum->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $childforum->id . "_off_childsmall.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $childforum->htmlCategoryIcon = CKunenaTools::showIcon('kreadforum-sm', JText::_('COM_KUNENA_GEN_FORUM_NOTNEW')); } } } else { // Not Login Cat Images if (is_file(KUNENA_ABSCATIMAGESPATH . $childforum->id . "_notlogin_childsmall.gif")) { $childforum->htmlCategoryIcon = "<img src=\"" . KUNENA_URLCATIMAGES . $childforum->id . "_notlogin_childsmall.gif\" border=\"0\" class='kforum-cat-image' alt=\" \" />"; } else { $childforum->htmlCategoryIcon = CKunenaTools::showIcon('knotloginforum-sm', JText::_('COM_KUNENA_GEN_FORUM_NOTNEW')); } } } else { $childforum->htmlCategoryIcon = ''; } $this->childforums[$childforum->parent][] = $childforum; } } $this->modlist = array(); $this->pending = array(); if (count($modcats)) { if ($this->config->listcat_show_moderators) { $modcatlist = implode(',', $modcats); $this->db->setQuery("SELECT * FROM #__kunena_moderation AS m\n\t\t\t\t\tINNER JOIN #__users AS u ON u.id=m.userid\n\t\t\t\t\tWHERE m.catid IN ({$modcatlist}) AND u.block=0"); $modlist = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); foreach ($modlist as $mod) { $this->modlist[$mod->catid][] = $mod; $userlist[intval($mod->userid)] = intval($mod->userid); } } if (CKunenaTools::isModerator($this->my->id)) { foreach ($modcats as $i => $catid) { if (!CKunenaTools::isModerator($this->my->id, $catid)) { unset($modcats[$i]); } } if (count($modcats)) { $modcatlist = implode(',', $modcats); $this->db->setQuery("SELECT catid, COUNT(*) AS count\n\t\t\t\t\tFROM #__kunena_messages\n\t\t\t\t\tWHERE catid IN ({$modcatlist}) AND hold='1'\n\t\t\t\t\tGROUP BY catid"); $pending = $this->db->loadAssocList(); KunenaError::checkDatabaseError(); foreach ($pending as $i) { if ($i['count']) { $this->pending[$i['catid']] = $i['count']; } } } } } // Prefetch all users/avatars to avoid user by user queries during template iterations kimport('user'); KunenaUser::loadUsers($userlist); }
protected function _removeAttachment($data) { $result = array(); // only registered users when the board is online will endup here // $data has already been escaped as part of this class // TODO: Get attachment details $query = "SELECT a.*, m.*\n\t\t\tFROM #__kunena_attachments AS a\n\t\t\tJOIN #__kunena_messages AS m ON a.mesid = m.id\n\t\t\tWHERE a.id = '" . $data . "'"; $this->_db->setQuery($query); $attachment = $this->_db->loadObject(); if ($this->_db->getErrorNum()) { $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError()); return $result; } // Verify permissions, user must be author of the message this // attachment is attached to or be a moderator or admin of the site if ($attachment->userid != $this->_my->id && !CKunenaTools::isModerator($this->_my->id, $attachment->catid) && !CKunenaTools::isAdmin()) { // not the author, not a moderator, not an admin // nothing todo here - end with permission error $result = array('status' => '-1', 'error' => JText::_('COM_KUNENA_AJAX_PERMISSION_DENIED')); return $result; } // Request coming form valid user, moderator or admin... // First remove files from filsystem - check for thumbs and raw in case this is an image if (file_exists(JPATH_ROOT . $attachment->folder . $attachment->filename)) { JFile::delete(JPATH_ROOT . $attachment->folder . $attachment->filename); } if (file_exists(JPATH_ROOT . $attachment->folder . '/raw/' . $attachment->filename)) { JFile::delete(JPATH_ROOT . $attachment->folder . '/raw/' . $attachment->filename); } if (file_exists(JPATH_ROOT . $attachment->folder . '/thumb/' . $attachment->filename)) { JFile::delete(JPATH_ROOT . $attachment->folder . '/thumb/' . $attachment->filename); } // Finally delete attachment record from db $query = "DELETE FROM #__kunena_attachments AS a\n\t\t\t\t\tWHERE a.id = {$this->_db->Quote($data)}"; $this->_db->setQuery($query); $this->_db->query(); if ($this->_db->getErrorNum()) { $result = array('status' => '-1', 'error' => KunenaError::getDatabaseError()); } else { $result = array('status' => '1', 'error' => JText::_('COM_KUNENA_AJAX_ATTACHMENT_DELETED')); } return $result; }
protected function _Delete($MessageID, $DeleteAttachments = false, $mode = KN_DEL_MESSAGE) { // Private delete function // $mode // KN_DEL_MESSAGE ... delete current message only // KN_DEL_THREAD ... delete entire thread // KN_DEL_ATTACH ... delete Attachments of message // Reset error message $this->_ResetErrorMessage(); // Sanitize parameters! $MessageID = intval($MessageID); $mode = intval($mode); // no need to check $DeleteAttachments as we only test for true // Always check security clearance before taking action! // Only moderators can delete messages by using this function if (!CKunenaTools::isModerator($this->_my->id)) { $this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_NOT_MODERATOR'); return false; } $this->_db->setQuery("SELECT `id`, `userid`, `catid`, `hold`, `parent`, `thread`, `subject`, `time` AS timestamp FROM #__kunena_messages WHERE `id`={$this->_db->Quote($MessageID)}"); $currentMessage = $this->_db->loadObject(); if (KunenaError::checkDatabaseError()) { return false; } // Check that message to be moved actually exists if (!is_object($currentMessage)) { $this->_errormsg = JText::sprintf('COM_KUNENA_MODERATION_ERROR_MESSAGE_NOT_FOUND', $MessageID); return false; } // Check that user has moderator permissions in the category if (!CKunenaTools::isModerator($this->_my->id, $currentMessage->catid)) { $this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_NOT_MODERATOR_IN_CATEGORY', $currentMessage->id, $currentMessage->catid); return false; } // Assemble delete logic based on $mode switch ($mode) { case KN_DEL_MESSAGE: //Delete only the actual message $sql = "UPDATE #__kunena_messages SET `hold`=2 WHERE `id`={$this->_db->Quote($MessageID)};"; if ($currentMessage->parent == 0) { $this->_setSecondMessageParent($MessageID, $currentMessage); } break; case KN_DEL_MESSAGE_PERMINANTLY: // Delete the message from the database // FIXME: if only admins are allowed to do this, add restriction (and make it general/changeble) $sql = "DELETE FROM #__kunena_messages WHERE `id`={$this->_db->Quote($MessageID)};"; $query = "DELETE FROM #__kunena_messages_text WHERE `mesid`={$this->_db->Quote($MessageID)}; "; $this->_db->setQuery($query); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } if ($currentMessage->parent == 0) { $this->_setSecondMessageParent($MessageID, $currentMessage); } if ($currentMessage->userid > 0) { $query = "UPDATE #__kunena_users SET posts=posts-1 WHERE `userid`={$this->_db->Quote($MessageID)}; "; $this->_db->setQuery($query); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } } $this->deleteAttachments($MessageID); break; case KN_DEL_THREAD_PERMINANTLY: //Delete a complete thread from the databases $query = "SELECT `id`,`userid` FROM #__kunena_messages WHERE `thread`={$this->_db->Quote($currentMessage->thread)};"; $this->_db->setQuery($query); $ThreadDatas = $this->_db->loadObjectList(); if (KunenaError::checkDatabaseError()) { return false; } $userid = array(); $messid = array(); if (is_array($ThreadDatas)) { foreach ($ThreadDatas as $mes) { $userid[] = $mes->userid; $messid[] = $mes->id; // Delete all attachments in this thread if ($DeleteAttachments) { $this->deleteAttachments($mes->id); } } $sql2 = "DELETE FROM #__kunena_messages_text WHERE `mesid` IN ({$this->_db->Quote(implode(',', $messid))});"; $this->_db->setQuery($sql2); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } // Need to update number of posts of each users in this thread if ($mes->userid > 0) { $query = "UPDATE #__kunena_users SET posts=posts-1 WHERE `userid` IN ({$this->_db->Quote(implode(',', $userid))}); "; $this->_db->setQuery($query); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } } } $sql = "DELETE FROM #__kunena_messages WHERE `thread`={$this->_db->Quote($currentMessage->thread)};"; break; case KN_UNDELETE_THREAD: $sql1 = "UPDATE #__kunena_messages SET `hold`=0 WHERE `id`={$this->_db->Quote($MessageID)};"; $this->_db->setQuery($sql1); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } $sql = "UPDATE #__kunena_messages SET `hold`=0 WHERE hold=3 AND `thread`={$this->_db->Quote($currentMessage->thread)} AND `id`!={$this->_db->Quote($MessageID)} ;"; break; case KN_DEL_THREAD: //Delete a complete thread $sql1 = "UPDATE #__kunena_messages SET `hold`=2 WHERE `id`={$this->_db->Quote($MessageID)};"; $this->_db->setQuery($sql1); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } $sql = "UPDATE #__kunena_messages SET `hold`=3 WHERE hold IN (0,1) AND `thread`={$this->_db->Quote($currentMessage->thread)} AND `id`!={$this->_db->Quote($MessageID)} ;"; break; case KN_DEL_ATTACH: //Delete only the attachments require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php'; $attachments = CKunenaAttachments::getInstance(); $attachments->deleteMessage($MessageID); break; default: // Unsupported mode - Error! $this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_UNSUPPORTED_MODE'); return false; } // Execute delete if (isset($sql)) { $this->_db->setQuery($sql); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } } // Remember to delete ghost post // FIXME: replies may have ghosts, too. What to do with them? $this->_db->setQuery("SELECT m.id FROM #__kunena_messages AS m INNER JOIN #__kunena_messages_text AS t ON m.`id`=t.`mesid`\n\t\t\tWHERE `moved`=1;"); $ghostMessageID = $this->_db->loadResult(); if (KunenaError::checkDatabaseError()) { return false; } if (!empty($ghostMessageID)) { $this->_db->setQuery("UPDATE #__kunena_messages SET `hold`=2 WHERE `id`={$this->_db->Quote($ghostMessageID)} AND `moved`=1;"); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return false; } } // Check result to see if we need to abord and set error message // When done log the action $this->_Log('Delete', $MessageID, 0, '', 0, $mode); // Last but not least update forum stats CKunenaTools::reCountBoards(); return true; }