コード例 #1
0
ファイル: admin.kunena.php プロジェクト: vuchannguyen/hoctap
function deleteAttachment($id, $redirect, $message)
{
    $kunena_app =& JFactory::getApplication();
    $kunena_db =& JFactory::getDBO();
    if (!$id) {
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect($redirect);
        return;
    }
    require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php';
    $attachments = CKunenaAttachments::getInstance();
    $attachments->deleteAttachment($id);
    $kunena_app->enqueueMessage(JText::_($message));
    while (@ob_end_clean()) {
    }
    $kunena_app->redirect($redirect);
}
コード例 #2
0
 protected function _uploadFile($do)
 {
     require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php';
     $attachments = CKunenaAttachments::getInstance();
     return $attachments->upload();
 }
コード例 #3
0
 protected function saveEdit()
 {
     if (!$this->check()) {
         return false;
     }
     // Update rest of the information
     $this->setOption('allowed', null);
     $this->set('hold', CKunenaTools::isModerator($this->_my, $this->parent->catid) ? 0 : (int) $this->parent->review);
     $this->set('modified_by', (int) $this->_my->id);
     $this->set('modified_time', CKunenaTimeformat::internalTime());
     $anonymous = $this->getOption('anonymous');
     if ($anonymous) {
         if ($this->_my->id == $this->parent->userid && $this->parent->modified_by == $this->parent->userid) {
             // I am the author and previous modification was made by me => delete modification information to hide my personality
             $this->set('modified_by', 0);
             $this->set('modified_time', 0);
             $this->set('modified_reason', '');
         } else {
             if ($this->_my->id == $this->parent->userid) {
                 // I am the author, but somebody else has modified the message => leave modification information intact
                 $this->set('modified_by', null);
                 $this->set('modified_time', null);
                 $this->set('modified_reason', null);
             }
         }
         // Remove userid, email and ip address
         $this->set('userid', 0);
         $this->set('ip', '');
         $this->set('email', '');
     }
     // Activity integration
     $activity = KunenaFactory::getActivityIntegration();
     $activity->onBeforeEdit($this);
     if (!empty($this->errors)) {
         return false;
     }
     $mesvalues = array();
     $txtvalues = array();
     foreach ($this->message as $field => $value) {
         if ($field != 'message') {
             $mesvalues[] = "{$this->_db->nameQuote($field)}={$this->_db->quote($value)}";
         } else {
             $txtvalues[] = "{$this->_db->nameQuote($field)}={$this->_db->quote($value)}";
         }
     }
     if (!empty($mesvalues)) {
         $mesvalues = implode(', ', $mesvalues);
         $query = "UPDATE #__kunena_messages SET {$mesvalues} WHERE id={$this->_db->quote($this->parent->id)}";
         $this->_db->setQuery($query);
         $this->_db->query();
         $dberror = $this->checkDatabaseError();
         if ($dberror) {
             return $this->setError('-edit-', JText::_('COM_KUNENA_POST_ERROR_SAVE'));
         }
     }
     if (!empty($txtvalues)) {
         $txtvalues = implode(', ', $txtvalues);
         $query = "UPDATE #__kunena_messages_text SET {$txtvalues} WHERE mesid={$this->_db->quote($this->parent->id)}";
         $this->_db->setQuery($query);
         $this->_db->query();
         $dberror = $this->checkDatabaseError();
         if ($dberror) {
             return $this->setError('-edit-', JText::_('COM_KUNENA_POST_ERROR_SAVE'));
         }
     }
     $this->set('id', $id = $this->parent->id);
     // Add/delete attachments if there are any changes
     // TODO: find better way
     if ($this->getOption('attachments')) {
         require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php';
         $attachments = CKunenaAttachments::getInstance();
         $message = $this->get('message');
         // Delete attachments which weren't checked (= not listed in here)
         jimport('joomla.utilities.arrayhelper');
         $attachkeeplist = JRequest::getVar('attach-id', array(0), 'post', 'array');
         JArrayHelper::toInteger($attachkeeplist, array(0));
         $attachkeeplist = implode(',', $attachkeeplist);
         $query = "SELECT id FROM #__kunena_attachments WHERE mesid={$this->_db->Quote($id)} AND id NOT IN ({$attachkeeplist})";
         $this->_db->setQuery($query);
         $attachmentlist = $this->_db->loadResultArray();
         if (!KunenaError::checkDatabaseError()) {
             $attachments->deleteAttachment($attachmentlist);
         }
         $fileinfos = $attachments->multiupload($id, $message);
         foreach ($fileinfos as $fileinfo) {
             if (!$fileinfo['status']) {
                 $this->_app->enqueueMessage(JText::sprintf('COM_KUNENA_UPLOAD_FAILED', $fileinfo['name']) . ': ' . $fileinfo['error'], 'error');
             }
         }
         $this->_db->setQuery("UPDATE #__kunena_messages_text SET message={$this->_db->quote($message)} WHERE mesid={$this->_db->Quote($id)}");
         $this->_db->query();
     }
     // Get the event dispatcher
     $dispatcher = JDispatcher::getInstance();
     // Load the JXFinder plug-in group
     JPluginHelper::importPlugin('finder');
     // Fire after post save event
     $dispatcher->trigger('onAfterSaveKunenaPost', array($id));
     // Activity integration
     $activity = KunenaFactory::getActivityIntegration();
     $activity->onAfterEdit($this);
     return $id;
 }
コード例 #4
0
ファイル: post.php プロジェクト: redigy/Kunena-1.6
 function displayThreadHistory()
 {
     if (!$this->config->showhistory || $this->id == 0) {
         return;
     }
     //get all the messages for this thread
     $query = "SELECT m.*, t.* FROM #__kunena_messages AS m\n\t\t\tLEFT JOIN #__kunena_messages_text AS t ON m.id=t.mesid\n\t\t\tWHERE thread='{$this->msg_cat->thread}' AND hold='0'\n\t\t\tORDER BY time DESC";
     $this->_db->setQuery($query, 0, $this->config->historylimit);
     $this->messages = $this->_db->loadObjectList();
     if (KunenaError::checkDatabaseError()) {
         return;
     }
     $this->replycount = count($this->messages);
     //get attachments
     $mesids = array();
     foreach ($this->messages as $mes) {
         $mesids[] = $mes->id;
     }
     $mesids = implode(',', $mesids);
     require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php';
     $attachments = CKunenaAttachments::getInstance();
     $this->attachmentslist = $attachments->get($mesids);
     $this->subject = $this->msg_cat->subject;
     CKunenaTools::loadTemplate('/editor/history.php');
 }
コード例 #5
0
ファイル: view.php プロジェクト: vuchannguyen/hoctap
 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);
 }
コード例 #6
0
ファイル: kunena.parser.php プロジェクト: rich20/Kunena-1.6
    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;
    }
コード例 #7
0
 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;
 }