public static function replace($tmp, $text) { $config = DiscussHelper::getConfig(); $pattern = '@(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))@'; preg_match_all($pattern, $tmp, $matches); $targetBlank = $config->get('main_link_new_window') ? ' target="_blank"' : ''; if (!isset($matches[0]) || !is_array($matches[0])) { return; } // to avoid infinite loop, unique the matches $links = $matches[0]; foreach ($links as &$link) { $link = JString::strtolower($link); } $uniques = array_unique($links); foreach ($uniques as $match) { $matchProtocol = $match; if (stristr($matchProtocol, 'http://') === false && stristr($matchProtocol, 'https://') === false && stristr($matchProtocol, 'ftp://') === false) { $matchProtocol = 'http://' . $matchProtocol; } $text = JString::str_ireplace($match, '<a href="' . $matchProtocol . '"' . $targetBlank . '>' . $match . '</a>', $text); } $text = JString::str_ireplace('"', '"', $text); return $text; }
function display($tmpl = null) { $document = JFactory::getDocument(); $config = DiscussHelper::getConfig(); $doc = JFactory::getDocument(); DiscussHelper::setPageTitle(JText::_('COM_EASYDISCUSS_MEMBERS_TITLE')); $this->setPathway(JText::_('COM_EASYDISCUSS_BREADCRUMBS_MEMBERS')); $model = $this->getModel('Users'); $userQuery = JRequest::getString('userQuery', ''); $result = $model->getData($userQuery); $pagination = $model->getPagination(); $sort = JRequest::getString('sort', 'latest'); $filteractive = JRequest::getString('filter', 'allposts'); $users = DiscussHelper::formatUsers($result); $sort = JRequest::getCmd('sort', 'name'); $uids = $config->get('main_exclude_members'); if (!empty($uids)) { // Remove white space $uids = str_replace(' ', '', $uids); $excludeId = explode(',', $uids); $temp = array(); foreach ($users as $user) { if (!in_array($user->id, $excludeId)) { $temp[] = $user; } } $users = $temp; } $theme = new DiscussThemes(); $theme->set('users', $users); $theme->set('pagination', $pagination); $theme->set('sort', $sort); $theme->set('userQuery', $userQuery); echo $theme->fetch('users.php'); }
/** * Displays the user's points achievement history * * @since 2.0 * @access public */ public function history($tmpl = null) { $app = JFactory::getApplication(); $id = JRequest::getInt('id'); if (!$id) { DiscussHelper::setMessageQueue(JText::_('Unable to locate the id of the user.'), DISCUSS_QUEUE_ERROR); $app->redirect('index.php?option=com_easydiscuss'); $app->close(); } $model = DiscussHelper::getModel('Points', true); $history = $model->getPointsHistory($id); foreach ($history as $item) { $date = DiscussDateHelper::dateWithOffSet($item->created); $item->created = $date->toFormat('%A, %b %e %Y'); $points = DiscussHelper::getHelper('Points')->getPoints($item->command); if ($points) { if ($points[0]->rule_limit < 0) { $item->class = 'badge-important'; $item->points = $points[0]->rule_limit; } else { $item->class = 'badge-info'; $item->points = '+' . $points[0]->rule_limit; } } else { $item->class = 'badge-info'; $item->points = '+'; } } $theme = new DiscussThemes(); $theme->set('history', $history); echo $theme->fetch('points.history.php'); }
public function store($updateNulls = false) { if (empty($this->created) || $this->created == '0000-00-00 00:00:00') { $this->created = DiscussHelper::getDate()->toMySQL(); } return parent::store(); }
function process() { $view = new EasyDiscussView(); $date = DiscussHelper::getDate(); $now = $date->toMySQL(); $modelSubscribe = $view->getModel('Subscribe'); $subscribers = $modelSubscribe->getSiteSubscribers($this->interval, $now); $total = count($subscribers); if (empty($total)) { return false; } foreach ($subscribers as $subscriber) { $notify = DiscussHelper::getNotification(); $data = array(); $rows = $modelSubscribe->getCreatedPostByInterval($subscriber->sent_out, $now); $posts = array(); if ($rows) { foreach ($rows as $row) { $row['categorylink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=categorie&layout=listings&category_id=' . $row['category_id'], false, true); $row['link'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row['id'], false, true); $row['userlink'] = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=profile&id=' . $row['user_id'], false, true); $category = DiscussHelper::getTable('Category'); $creator = DiscussHelper::getTable('Profile'); $category->load($row['category_id']); $creator->load($row['user_id']); $row['category'] = $category->getTitle(); $row['avatar'] = $creator->getAvatar(); $row['name'] = $creator->getName(); $row['date'] = DiscussDateHelper::toFormat($row['created'], '%b %e, %Y'); $row['message'] = DiscussHelper::parseContent($row['content']); $posts[] = $row; } } $data['post'] = $posts; $data['total'] = count($data['post']); $data['unsubscribeLink'] = DiscussHelper::getUnsubscribeLink($subscriber, true, true); $subject = $date->toMySQL(); switch (strtoupper($this->interval)) { case 'DAILY': $subject = $date->toFormat('%F'); $data['interval'] = JText::_('today'); break; case 'WEEKLY': $subject = $date->toFormat('%V'); $data['interval'] = JText::_('this week'); break; case 'MONTHLY': $subject = $date->toFormat('%B'); $data['interval'] = JText::_('this month'); break; } if (!empty($data['post'])) { $notify->addQueue($subscriber->email, JText::sprintf('COM_EASYDISCUSS_YOUR_' . $this->interval . '_SUBSCRIPTION', $subject), '', 'email.subscription.site.interval.php', $data); } $subscribe = DiscussHelper::getTable('Subscribe'); $subscribe->load($subscriber->id); $subscribe->sent_out = $now; $subscribe->store(); } }
private static function isLock($post_id) { $db = DiscussHelper::getDBO(); $query = 'SELECT `islock` FROM `#__discuss_posts` WHERE `id` = ' . $db->quote($post_id); $db->setQuery($query); return $db->loadResult(); }
public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.reports', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $mainframe = JFactory::getApplication(); $filter_state = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_state', 'filter_state', '*', 'word'); $search = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.search', 'search', '', 'string'); $search = trim(JString::strtolower($search)); $order = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_order', 'filter_order', 'a.id', 'cmd'); $orderDirection = $mainframe->getUserStateFromRequest('com_easydiscuss.reports.filter_order_Dir', 'filter_order_Dir', '', 'word'); $reportModel = $this->getModel('reports'); $reports = $reportModel->getReports(); $pagination = $reportModel->getPagination(); $this->assignRef('reports', $reports); $this->assignRef('pagination', $pagination); $this->assign('state', $this->getFilterState($filter_state)); $this->assign('search', $search); $this->assign('order', $order); $this->assign('orderDirection', $orderDirection); parent::display($tpl); }
/** * Remove a location from a post. * * @since 3.0 * @access public */ public function removeLocation($id) { $ajax = new Disjax(); $post = DiscussHelper::getTable('Post'); $state = $post->load($id); $my = JFactory::getUser(); if (!$id || !$state) { echo JText::_('COM_EASYDISCUSS_INVALID_ID'); return $ajax->send(); } if ($post->user_id != $my->id && !DiscussHelper::isModerator($post->category_id)) { echo JText::_('COM_EASYDISCUSS_NOT_ALLOWED_TO_REMOVE_LOCATION_FOR_POST'); return $ajax->send(); } // Update the address, latitude and longitude of the post. $post->address = ''; $post->latitude = ''; $post->longitude = ''; $post->store(); $content = JText::_('COM_EASYDISCUSS_LOCATION_IS_REMOVED'); $options = new stdClass(); $options->content = $content; $options->title = JText::_('COM_EASYDISCUSS_DELETE_LOCATION_TITLE'); $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE'); $button->action = 'disjax.closedlg();'; $buttons[] = $button; $options->buttons = $buttons; $ajax->script('discuss.location.removeHTML("' . $id . '");'); $ajax->dialog($options); return $ajax->send(); }
public function getCustomFieldsAcl() { $db = DiscussHelper::getDBO(); $query = 'SELECT * FROM ' . $db->nameQuote('#__discuss_customfields_acl') . ' ORDER BY ' . $db->nameQuote('id'); $db->setQuery($query); return $db->loadObjectList(); }
public static function add($userObj, $entityObj, $interval = null, $data) { if (!$userObj instanceof JUser) { return false; } if ($entityObj instanceof DiscussPost) { $type = 'post'; } elseif ($entityObj instanceof DiscussCategory) { $type = 'category'; } else { // $type = 'site' return false; } $email = isset($data['poster_email']) ? $data['poster_email'] : ''; $name = isset($data['poster_name']) ? $data['poster_name'] : ''; $subscribe = DiscussHelper::getTable('Subscribe'); if (empty($userObj->id)) { $subscribe->userid = 0; $subscribe->member = 0; $subscribe->email = $email; $subscribe->fullname = $name; } else { $subscribe->userid = $userObj->id; $subscribe->member = 1; $subscribe->email = $userObj->email; $subscribe->fullname = $userObj->name; } $subscribe->type = $type; $subscribe->cid = $entityObj->id; $subscribe->interval = $interval; return $subscribe->store(); }
/** * Open an IMAP stream to a mailbox. * Return true on success, return false on error. */ public function connect($username = '', $password = '') { $config = DiscussHelper::getConfig(); if (!$this->initiated) { $this->init(); } if (!$this->enabled || !function_exists('imap_open') || !function_exists('imap_fetchheader') || !function_exists('imap_body')) { $this->setError('PHP IMAP not available.'); return false; } /* * Connect to mailbox */ // if( !empty($username) && !empty($password) ) // { echo JText::sprintf('COM_EASYDISCUSS_CONNECTING_TO', $username); $this->stream = imap_open($this->mailbox_params, $username, $password); // } // else // { // $this->stream = imap_open( $this->mailbox_params, $this->username, $this->password ); // } if ($this->stream === false) { $this->setError(imap_errors()); return false; } return true; }
public function display($tpl = null) { $id = JRequest::getInt('id', 0); $badge = DiscussHelper::getTable('Badges'); $badge->load($id); if (!$badge->created) { $date = DiscussHelper::getHelper('Date')->dateWithOffset(DiscussHelper::getDate()->toMySQL()); $badge->created = $date->toMySQL(); } // There could be some errors here. if (JRequest::getMethod() == 'POST') { $badge->bind(JRequest::get('post')); // Description might contain html codes $description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $badge->description = $description; } $jConfig = DiscussHelper::getJConfig(); $editor = JFactory::getEditor($jConfig->get('editor')); $model = $this->getModel('Badges'); $rules = $model->getRules(); $badges = $this->getBadges(); $this->assign('editor', $editor); $this->assign('badges', $badges); $this->assign('rules', $rules); $this->assign('badge', $badge); parent::display($tpl); }
public function delete($id) { $ajax = new Disjax(); $user = JFactory::getUser(); // @rule: Do not allow empty id or guests to delete files. if (empty($id) || empty($user->id)) { return false; } $attachment = DiscussHelper::getTable('Attachments'); $attachment->load($id); // Ensure that only post owner or admin can delete it. if (!$attachment->deleteable()) { return false; } // Ensure that only post owner or admin can delete it. if (!$attachment->delete()) { return false; } $theme = new DiscussThemes(); $content = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETED_SUCCESSFULLY'); $options = new stdClass(); $options->content = $content; $options->title = JText::_('COM_EASYDISCUSS_ATTACHMENT_DELETE_CONFIRMATION_TITLE'); $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_BUTTON_CLOSE'); $button->action = 'disjax.closedlg();'; $buttons[] = $button; $options->buttons = $buttons; $ajax->script('EasyDiscuss.$("#attachment-' . $attachment->id . '" ).trigger("itemRemoved").remove();'); $ajax->dialog($options); $ajax->send(); }
public function get($key, $default = null) { if (DiscussHelper::getJoomlaVersion() >= '3.0') { return $this->config->get($key, $default); } return $this->config->getValue($key, $default); }
/** * Test if a specific rule / command already exists on the system. * * @access public * @param string $command The command name to test for. * @return boolean True if exists, false otherwise. **/ public function exists($command) { $db = DiscussHelper::getDBO(); $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote($this->_tbl) . ' ' . 'WHERE ' . $db->nameQuote('command') . '=' . $db->Quote($command); $db->setQuery($query); return $db->loadResult() > 0; }
public static function getButtonHTML($row, $position = 'vertical') { $config = DiscussHelper::getConfig(); if (!$config->get('integration_digg')) { return ''; } $dataURL = DiscussRouter::getRoutedURL('index.php?option=com_easydiscuss&view=post&id=' . $row->id, false, true); $dataURL = urlencode($dataURL); $html = ''; if ($position == 'horizontal') { $class = 'DiggCompact'; } else { $class = 'DiggMedium'; } $html = '<script type="text/javascript">(function() { var s = document.createElement(\'SCRIPT\'), s1 = document.getElementsByTagName(\'SCRIPT\')[0]; s.type = \'text/javascript\'; s.async = true; s.src = \'http://widgets.digg.com/buttons.js\'; s1.parentNode.insertBefore(s, s1); })(); </script> <!-- Wide Button --> <div class="social-button digg-share"><a class="DiggThisButton ' . $class . '" href="https://digg.com/submit?url=' . $dataURL . '&title=' . $row->title . '"></a></div>'; return $html; }
function remove() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $mails = JRequest::getVar('cid', '', 'POST'); $message = ''; $type = 'success'; if (empty($mails)) { $message = JText::_('COM_EASYDISCUSS_NO_MAIL_ID_PROVIDED'); $type = 'error'; } else { $table = DiscussHelper::getTable('MailQueue'); foreach ($mails as $id) { $table->load($id); if (!$table->delete()) { DiscussHelper::setMessageQueue(JText::_('COM_EASYDISCUSS_SPOOLS_DELETE_ERROR'), DISCUSS_QUEUE_ERROR); $this->setRedirect('index.php?option=com_easydiscuss&view=spools'); return; } } $message = JText::_('COM_EASYDISCUSS_SPOOLS_EMAILS_DELETED'); } DiscussHelper::setMessageQueue($message, $type); $this->setRedirect('index.php?option=com_easydiscuss&view=spools'); }
public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.spools', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $mainframe = JFactory::getApplication(); $filter_state = $mainframe->getUserStateFromRequest('com_easydiscuss.spools.filter_state', 'filter_state', '*', 'word'); $search = $mainframe->getUserStateFromRequest('com_easydiscuss.spools.search', 'search', '', 'string'); $search = trim(JString::strtolower($search)); $order = $mainframe->getUserStateFromRequest('com_easydiscuss.spools.filter_order', 'filter_order', 'created', 'cmd'); $orderDirection = $mainframe->getUserStateFromRequest('com_easydiscuss.spools.filter_order_Dir', 'filter_order_Dir', 'asc', 'word'); $mails = $this->get('Data'); $pagination = $this->get('Pagination'); $this->assign('mails', $mails); $this->assign('pagination', $pagination); $this->assign('state', JHTML::_('grid.state', $filter_state, JText::_('COM_EASYDISCUSS_SENT'), JText::_('COM_EASYDISCUSS_PENDING'))); $this->assign('search', $search); $this->assign('order', $order); $this->assign('orderDirection', $orderDirection); parent::display($tpl); }
public function store($updateNulls = false) { if (empty($this->email) && $this->userid) { $user = JFactory::getUser($this->userid); $this->fullname = $user->email(); } if (empty($this->fullname) && $this->userid) { $profile = DiscussHelper::getTable('Profile'); $profile->load($this->userid); $this->fullname = $profile->getName(); } if (empty($this->member)) { $this->member = $this->userid ? 1 : 0; } if (empty($this->interval)) { $this->interval = 'instant'; } if (empty($this->created)) { $this->created = DiscussHelper::getDate()->toMySQL(); } if (empty($this->sent_out)) { $this->sent_out = DiscussHelper::getDate()->toMySQL(); } return parent::store($updateNulls); }
public function compile() { $config = DiscussHelper::getConfig(); $less = DiscussHelper::getHelper('less'); // Force compile $less->compileMode = 'force'; $name = JRequest::getCmd('name', null, 'GET'); $type = JRequest::getCmd('type', null, 'GET'); $result = new stdClass(); if (isset($name) && isset($type)) { switch ($type) { case "admin": $result = $less->compileAdminStylesheet($name); break; case "site": $result = $less->compileSiteStylesheet($name); break; case "module": $result = $less->compileModuleStylesheet($name); break; default: $result->failed = true; $result->message = "Stylesheet type is invalid."; } } else { $result->failed = true; $result->message = "Insufficient parameters provided."; } header('Content-type: text/javascript; UTF-8'); echo json_encode($result); exit; }
public function getAllRuleItems() { $db = DiscussHelper::getDBO(); $query = 'select * from `#__discuss_category_acl_item` order by id'; $db->setQuery($query); return $db->loadObjectList(); }
public function save() { JRequest::checkToken('request') or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $ids = isset($post['id']) ? $post['id'] : ''; $starts = isset($post['start']) ? $post['start'] : ''; $ends = isset($post['end']) ? $post['end'] : ''; $titles = isset($post['title']) ? $post['title'] : ''; $removal = isset($post['itemRemove']) ? $post['itemRemove'] : ''; $model = DiscussHelper::getModel('Ranks', true); if (!empty($removal)) { $rids = explode(',', $removal); $model->removeRanks($rids); } if (!empty($ids)) { if (count($ids) > 0) { for ($i = 0; $i < count($ids); $i++) { $data = array(); $data['id'] = $ids[$i]; $data['start'] = $starts[$i]; $data['end'] = $ends[$i]; $data['title'] = $titles[$i]; $ranks = DiscussHelper::getTable('Ranks'); $ranks->bind($data); $ranks->store(); } } //end if } //end if $message = JText::_('COM_EASYDISCUSS_RANKING_SUCCESSFULLY_UPDATED'); DiscussHelper::setMessageQueue($message, DISCUSS_QUEUE_SUCCESS); $mainframe->redirect('index.php?option=com_easydiscuss&view=ranks'); }
public function getTotalUsers($badgeId) { $db = DiscussHelper::getDBO(); $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__discuss_badges_users') . ' ' . 'WHERE ' . $db->nameQuote('badge_id') . '=' . $db->Quote($badgeId); $db->setQuery($query); return $db->loadResult(); }
public function display($tpl = null) { // Initialise variables $mainframe = JFactory::getApplication(); $tagId = JRequest::getVar('tagid', ''); $tag = JTable::getInstance('Tags', 'Discuss'); $tag->load($tagId); $tag->title = JString::trim($tag->title); $tag->alias = JString::trim($tag->alias); $this->tag = $tag; // Generate All tags for merging selections $tagsModel = $this->getModel('Tags'); $tags = $tagsModel->getData(false); $tagList = array(); array_push($tagList, JHTML::_('select.option', 0, 'Select tag', 'value', 'text', false)); if (!empty($tags)) { foreach ($tags as $item) { if ($item->id != $tagId) { $tagList[] = JHtml::_('select.option', $item->id, $item->title); } } } // Set default values for new entries. if (empty($tag->created)) { $date = DiscussHelper::getDate(); $date->setOffSet($mainframe->getCfg('offset')); $tag->created = $date->toFormat(); $tag->published = true; } $this->assignRef('tag', $tag); $this->assignRef('tagList', $tagList); parent::display($tpl); }
public function getnews() { $ajax = DiscussHelper::getHelper('Ajax'); $news = DiscussHelper::getRecentNews(); ob_start(); if (!$news) { echo '<li class="empty">' . JText::_('COM_EASYDISCUSS_NO_NEWS_ITEM') . '</li>'; } else { foreach ($news as $newsItem) { $dates = explode('/', $newsItem->date); ?> <li> <span class="updates-news"> <a href="javascript:void(0);"><?php echo $newsItem->title; ?> </a> <span><?php echo $newsItem->desc; ?> </span> </span> <span class="si-date"><span><?php echo $dates[0]; ?> </span>may</span> <span class="clear"></span> </li> <?php } } $output = ob_get_contents(); ob_end_clean(); $ajax->success($output); }
public function display($tpl = null) { // @rule: Test for user access if on 1.6 and above if (DiscussHelper::getJoomlaVersion() >= '1.6') { if (!JFactory::getUser()->authorise('discuss.manage.tags', 'com_easydiscuss')) { JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error'); JFactory::getApplication()->close(); } } // Initialise variables $mainframe = JFactory::getApplication(); $filter_state = $mainframe->getUserStateFromRequest('com_easydiscuss.tags.filter_state', 'filter_state', '*', 'word'); $search = $mainframe->getUserStateFromRequest('com_easydiscuss.tags.search', 'search', '', 'string'); $search = trim(JString::strtolower($search)); $order = $mainframe->getUserStateFromRequest('com_easydiscuss.tags.filter_order', 'filter_order', 'id', 'cmd'); $orderDirection = $mainframe->getUserStateFromRequest('com_easydiscuss.tags.filter_order_Dir', 'filter_order_Dir', '', 'word'); // Get data from the model $tags = $this->get('Data'); $model = $this->getModel('tags'); for ($i = 0; $i < count($tags); $i++) { $tag = $tags[$i]; $tag->count = $model->getUsedCount($tag->id); $tag->title = JString::trim($tag->title); $tag->alias = JString::trim($tag->alias); } $pagination = $this->get('Pagination'); $this->assignRef('tags', $tags); $this->assignRef('pagination', $pagination); $this->assign('state', JHTML::_('grid.state', $filter_state)); $this->assign('search', $search); $this->assign('order', $order); $this->assign('orderDirection', $orderDirection); parent::display($tpl); }
/** * Generates a random captcha image * **/ function display($cachable = false, $urlparams = false) { // @TODO: Run some cleaning query here to clear the database. JTable::addIncludePath(DISCUSS_TABLES); $id = JRequest::getInt('captcha-id', ''); $captcha = DiscussHelper::getTable('Captcha'); // clearing the oudated keys. $captcha->clear(); // load the captcha records. $captcha->load($id); if (!$captcha->id) { return false; } // @task: Generate a very random integer and take only 5 chars max. $hash = JString::substr(md5(rand(0, 9999)), 0, 5); $captcha->response = $hash; $captcha->store(); // Captcha width and height $width = 100; $height = 20; $image = ImageCreate($width, $height); $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $gray = ImageColorAllocate($image, 204, 204, 204); ImageFill($image, 0, 0, $white); ImageString($image, 5, 30, 3, $hash, $black); ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray); imageline($image, 0, $height / 2, $width, $height / 2, $gray); imageline($image, $width / 2, 0, $width / 2, $height, $gray); header('Content-type: image/jpeg'); ImageJpeg($image); ImageDestroy($image); exit; }
protected function getInput() { $mainframe = JFactory::getApplication(); $doc = JFactory::getDocument(); $db = DiscussHelper::getDBO(); $options = array(); $attr = ''; $tagsList = array(); // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // To avoid user's confusion, readonly="true" should imply disabled="true". if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') { $attr .= ' disabled="disabled"'; } $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $query = 'SELECT `id`, `title` FROM `#__discuss_tags`'; $query .= ' WHERE `published` = ' . $db->Quote('1'); $db->setQuery($query); $data = $db->loadObjectList(); if (count($data) > 0) { $optgroup = JHTML::_('select.optgroup', 'Select tag', 'id', 'title'); array_push($tagsList, $optgroup); foreach ($data as $row) { $opt = new stdClass(); $opt->id = $row->id; $opt->title = '(' . $row->id . ') ' . $row->title; array_push($tagsList, $opt); } } $html = JHTML::_('select.genericlist', $tagsList, $this->name, trim($attr), 'id', 'title', $this->value); return $html; }
public function setOffset($offset) { if (DiscussHelper::getJoomlaVersion() >= '3.0') { $tz = new DateTimeZone($offset); return $this->date->setTimezone($tz); } return $this->date->setOffset($offset); }
public function getSuffix($alias = null) { $db = DiscussHelper::getDBO(); $query = 'SELECT `suffix` FROM ' . $db->nameQuote('#__discuss_post_types') . ' WHERE ' . $db->nameQuote('alias') . '=' . $db->quote($alias) . ' AND ' . $db->nameQuote('published') . '=' . $db->quote(1); $db->setQuery($query); $result = $db->loadResult(); return $result; }