Example #1
1
 public function getHash($seed = '')
 {
     if (DiscussHelper::getJoomlaVersion() >= '2.5') {
         return JApplication::getHash($seed);
     }
     return JUtility::getHash($seed);
 }
	/**
	 * Test parseAttributes
	 *
	 * @param   string  $tag       tag to be parsed
	 * @param   array   $expected  resulting array of attribute values
	 *
	 * @return  void
	 *
	 * @dataProvider casesParseAttributes
	 * @covers  JUtility::parseAttributes
	 */
	public function testParseAttributes($tag, $expected)
	{
		$this->assertThat(
			JUtility::parseAttributes($tag),
			$this->equalTo($expected)
		);
	}
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
     $cid = JRequest::getInt("cid", 0);
     $post = JRequest::get('post');
     if ($cid > 0) {
         $club =& JTable::getInstance("Club", "Table");
         $club->load($cid);
         $club->bind($post);
         $params =& JComponentHelper::getParams('com_joomleague');
         if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") {
             $db = JFactory::getDBO();
             $user = JFactory::getUser();
             $query = "SELECT email\n                         FROM #__users \n                         WHERE usertype = 'Super Administrator' \n                            OR usertype = 'Administrator'";
             $db->setQuery($query);
             $to = $db->loadResultArray();
             $subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name));
             $message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name));
             $message .= $this->_getShowClubInfoLink();
             JUtility::sendMail('', '', $to, $subject, $message);
         }
     }
     $this->setRedirect($this->_getShowClubInfoLink());
 }
Example #4
0
 function sendEmail()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $post = JRequest::get('post');
     $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
     $model = $this->getModel('location');
     $location = $model->getData();
     $contact_name = $post['contact_name'];
     $contact_email = $post['contact_email'];
     $contact_message = $post['contact_message'];
     if ($contact_name == null || $contact_message == null) {
         echo JText::_('Please enter a name and message to send.');
         return false;
     } else {
         if (false) {
             return false;
         } else {
             JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name);
             echo JText::_('Message Sent');
             return true;
         }
     }
     return false;
 }
Example #5
0
    public function onAfterRoute()
    {
        $application = JFactory::getApplication();

        if($application->isSite())
        {
            switch(JRequest::getVar('option', null, 'method', 'cmd'))
            {
                case 'com_user':
                    JRequest::setVar('option', 'com_users', 'get');

                    switch(JRequest::getVar('view', null, 'method', 'cmd'))
                    {
                        case 'login':
                            if(!JFactory::getUser()->guest) {
                                JRequest::setVar('view', 'logout', 'get');
                            }

                            break;

                        case 'remind':
                            JRequest::setVar('view', 'remind', 'get');

                            break;

                        case 'register':
                            JRequest::setVar('view', 'user', 'get');
                            JRequest::setVar('layout', 'register', 'get');

                            break;

                        case 'user':
                            if(JRequest::getVar('task', null, 'get', 'cmd') == 'edit') {
                                JRequest::setVar('layout', 'form', 'get');
                            }
                    }

                    switch(JRequest::getVar('task', null, 'method', 'cmd'))
                    {
                        case 'login':
                            JRequest::setVar('view', 'login', 'get');
                            JRequest::setVar('action', 'login', 'post');
                            JRequest::setVar('password', JRequest::getVar('passwd', null, 'method', 'none'), 'post');

                            break;
                    }

                    break;
            }

            if(JRequest::getMethod() == 'POST')
            {
                $token = JUtility::getToken();

                if(JRequest::getVar($token, null, 'post', 'alnum') == 1) {
                    JRequest::setVar('_token', $token, 'post');
                }
            }
        }
    }
Example #6
0
 function onAfterInitialise()
 {
     $app = JFactory::getApplication();
     // No remember me for admin
     if ($app->isAdmin()) {
         return;
     }
     $user = JFactory::getUser();
     if ($user->get('guest')) {
         jimport('joomla.utilities.utility');
         $hash = JUtility::getHash('JLOGIN_REMEMBER');
         if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) {
             jimport('joomla.utilities.simplecrypt');
             //Create the encryption key, apply extra hardening using the user agent string
             $key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']);
             $crypt = new JSimpleCrypt($key);
             $str = $crypt->decrypt($str);
             $options = array();
             $options['silent'] = true;
             if (!$app->login(@unserialize($str), $options)) {
                 $config = JFactory::getConfig();
                 $cookie_domain = $config->get('cookie_domain', '');
                 $cookie_path = $config->get('cookie_path', '/');
                 // Clear the remember me cookie
                 setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
             }
         }
     }
 }
Example #7
0
 public function delete($id = null)
 {
     // Include dependencies
     jimport('joomla.application.component.controller');
     jimport('joomla.form.form');
     jimport('joomla.database.table');
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/controllers/categories.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_categories/models/forms/');
     // Fake parameters
     $_POST['task'] = 'trash';
     $_REQUEST['task'] = 'trash';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);
     $controller = new CategoriesControllerCategories();
     try {
         $controller->execute('trash');
     } catch (JException $e) {
         $success = false;
         $controller->set('messageType', 'error');
         $controller->set('message', $e->getMessage());
     }
     if ($controller->getError()) {
         $response = $this->getErrorResponse(400, $controller->getError());
     } elseif ('error' == $controller->get('messageType')) {
         $response = $this->getErrorResponse(400, $controller->get('message'));
     } else {
         $response = $this->getSuccessResponse(200, $controller->get('message'));
     }
     $this->plugin->setResponse($response);
 }
Example #8
0
 public function display()
 {
     $this->assign('sitebase', trim(JURI::root(), '/'));
     $this->assign('token', JUtility::getToken());
     $this->assign('container', $this->getModel()->getState()->container);
     return parent::display();
 }
Example #9
0
	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
		$this->enabled		= $this->state->params->get('enabled');

		// Check for errors. @todo this has to be queed up and converted to JSON
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		$r = new JObject;
		$r->token = JUtility::getToken(true);
		$r->items = array();
		foreach ($this->items as $i => $item) {
			$rItem = new JObject;
			$rItem->index = $i + 1 + $this->pagination->limitstart;
			$rItem->search_term = $item->search_term;
			if ($this->state->get('filter.results')) {
				$rItem->results = (int) $item->returns;
			} else {
				$rItem->results = JText::_('COM_SEARCH_NO_RESULTS');
			}
			$r->items[$i] = $rItem;
		}
		
		echo json_encode($r);
	}
Example #10
0
 function cria_html()
 {
     // adiciona a biblioteca juri
     jimport('joomla.environment.uri');
     // verifica se a urlbase foi adicionada
     if (!is_null($this->url_base)) {
         $u =& JURI::getInstance($this->url_base);
     } else {
         $u =& JURI::getInstance();
     }
     $links = '';
     $paginas_adm_select = '';
     $select = '';
     // loop nas páginas
     for ($i = 1; $i <= $this->total_paginas; $i++) {
         // adiciona a var na url
         $u->setVar($this->get_var_pagina, $i);
         // retorna o html tag a
         $class = $i == $this->pagina_atual ? ' class="atual"' : '';
         $links .= sprintf('<a href="%s"%s>%d</a> ', JRoute::_($u->toString()), $class, $i);
         // retorna o html select
         $selected = $i == $this->pagina_atual ? ' selected="selected"' : '';
         // cria o select para o site
         $select .= sprintf('<option value="%s" %s>Página %d</option> ', JRoute::_($u->toString()), $selected, $i);
         // cria o select para o adm
         $paginas_adm_select .= sprintf('<option value="%s" %s>Página %d</option> ', $i, $selected, $i);
     }
     // paginas para o adm
     $query = JRequest::get('post');
     unset($query[JUtility::getToken()], $query['funcao'], $query['method'], $query['class'], $query['pagina'], $query['programa'], $query['template'], $query['processID']);
     $u->setQuery($query);
     $u->setVar($this->get_var_pagina, '');
     $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){ eDesktop.dialog.load({programa: "%s", processID: "%s", pagina: "%s", query: "%s"+ $(this).val() }); });});</script>', $this->get_var_pagina, JRequest::getvar('programa'), JRequest::getvar('processID'), JRequest::getvar('pagina'), $u->getQuery());
     $paginas_adm_select = sprintf('<select name="%s" id="%s">%s</select>%s ', $this->get_var_pagina, $this->get_var_pagina, $paginas_adm_select, $js);
     $this->html['paginas.adm.select'] = $paginas_adm_select;
     // páginas para o site
     $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_pagina);
     $select = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_pagina, $this->get_var_pagina, $select, $js);
     $this->html['paginas.links'] = $links;
     $this->html['paginas.select'] = $select;
     // ordem para site
     $order = '';
     $this->order_atual = JRequest::getVar($this->get_var_order);
     if (count($this->orders)) {
         foreach ($this->orders as $k => $v) {
             $u->setVar($this->get_var_pagina, 1);
             $u->setVar($this->get_var_order, $k);
             $selected = $k == $this->order_atual ? ' selected="selected"' : '';
             $order .= sprintf('<option value="%s" %s>%s</option> ', JRoute::_($u->toString()), $selected, $v['label']);
         }
         $js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_order);
         $order = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_order, $this->get_var_order, $order, $js);
         //
         $this->html['order.select'] = $order;
     }
     foreach ($this->html as $k => $v) {
         $key = str_replace('.', '_', $k);
         $this->html[$key] = $v;
     }
 }
Example #11
0
 function display($tpl = null)
 {
     // Frontpage hack
     $this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'link' . DS . 'tmpl');
     // Only allow "component" template
     JRequest::setVar('tmpl', 'component');
     // JFactory
     $user =& JFactory::getUser();
     $config =& JFactory::getConfig();
     $doc =& JFactory::getDocument();
     $lingo =& JFactory::getLanguage();
     // Include styles
     $doc->addStyleSheet(LINKR_ASSETS . 'css/modal.css?' . LINKR_VERSION_INC);
     // Template override
     global $mainframe;
     $tmpl = $mainframe->getTemplate();
     if (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'linkr.css')) {
         $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/linkr.css');
     } elseif (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'css' . DS . 'linkr.css')) {
         $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/css/linkr.css');
     }
     // Editor name, request endpoint, document base
     $editor = JRequest::getString('e_name', 'text');
     $rUrl = JURI::base() . 'index.php?option=com_linkr&view=request&' . JUtility::getToken() . '=1';
     // Include scripts
     JHTML::_('behavior.mootools');
     $unc = LinkrHelper::getParam('compress', 1) ? '.js' : '-UCP.js';
     $doc->addScript(LINKR_ASSETS . 'js/helper' . $unc . '?' . LINKR_VERSION_INC);
     $doc->addScriptDeclaration('var Linkr=new LinkrAPI(' . '[' . implode(',', explode('.', LINKR_VERSION_READ)) . '],' . '"' . $rUrl . '",' . '"' . $editor . '",' . '"' . JURI::root() . '",' . '[' . '"' . JRequest::getWord('mode', 'squeezebox') . '",' . '"' . $lingo->getTag() . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('MISSING_TEXT', true)) . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('IMG_ANCHOR', true)) . '",' . '"' . LINKR_ASSETS . 'img/",' . $user->get('aid') . ']' . ');' . 'var LinkrHelper=Linkr;');
     // Frontend fix
     if (LinkrHelper::isSite()) {
         //$doc->setBase(LinkrHelper::getLinkrUrl($editor));
     }
     // References
     $this->assign('links', $this->get('Links'));
     $this->assign('tools', $this->get('ToolLinks'));
     // Localize text
     if ($text = $this->get('L18N')) {
         $l18n = array();
         foreach ($text as $k => $v) {
             $l18n[] = '["' . $k . '","' . $v . '"]';
         }
         $doc->addScriptDeclaration('Linkr.setL18N([' . implode(',', $l18n) . ']);');
     }
     // 3rd party javascript
     if ($js = $this->get('Scripts')) {
         $doc->addScriptDeclaration($js);
     }
     // Load single link
     $load = '';
     $inc = $this->get('IncludedLinks');
     if (!$this->tools['count'] && $this->links['count'] == 1) {
         $load = 'Linkr.__fr=function(){' . $inc[$this->links['name'][0]] . '};';
     } elseif (!$this->links['count'] && $this->tools['count'] == 1) {
         $load = 'Linkr.__fr=function(){' . $inc[$this->tools['name'][0]] . '};';
     }
     // Fire "onLoad" event
     $doc->addScriptDeclaration('window.addEvent("domready",function(){' . $load . 'Linkr.fireEvent("onLoad");' . '});');
     parent::display($tpl);
 }
Example #12
0
 function alreadyVoted($id)
 {
     $mainframe = JFactory::getApplication();
     $cookieName = JUtility::getHash($mainframe->getName() . 'poll' . $id);
     $voted = JRequest::getVar($cookieName, '0', 'COOKIE', 'INT');
     return $voted;
 }
Example #13
0
 /**
  * Show the form in the admin
  *
  * @return null
  */
 public function view()
 {
     $document = JFactory::getDocument();
     $model = JModel::getInstance('Form', 'FabrikFEModel');
     $viewType = $document->getType();
     $this->setPath('view', COM_FABRIK_FRONTEND . '/views');
     $viewLayout = JRequest::getCmd('layout', 'default');
     $view = $this->getView('form', $viewType, '');
     $view->setModel($model, true);
     $view->isMambot = $this->isMambot;
     // Set the layout
     $view->setLayout($viewLayout);
     // @TODO check for cached version
     JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_FORMS'), 'forms.png');
     if (in_array(JRequest::getCmd('format'), array('raw', 'csv', 'pdf'))) {
         $view->display();
     } else {
         $user = JFactory::getUser();
         $post = JRequest::get('post');
         $cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
         $cache = JFactory::getCache('com_fabrik', 'view');
         ob_start();
         $cache->get($view, 'display', $cacheid);
         $contents = ob_get_contents();
         ob_end_clean();
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         echo preg_replace($search, $replacement, $contents);
     }
     FabrikAdminHelper::addSubmenu(JRequest::getWord('view', 'lists'));
 }
Example #14
0
 public function parseLang($vars)
 {
     if (Mijosef::getConfig()->multilang == 0) {
         return;
     }
     if (empty($vars['lang'])) {
         $lang = JRequest::getWord('lang', '');
         if (empty($lang)) {
             return;
         }
         $vars['lang'] = $lang;
     }
     $languages = JLanguageHelper::getLanguages('sef');
     $lang_code = $languages[$vars['lang']]->lang_code;
     // if current language, don't bother
     if ($lang_code == JFactory::getLanguage()->getTag()) {
         //self::checkHomepage($vars['lang']);
         return;
     }
     // Create a cookie
     $conf = JFactory::getConfig();
     $cookie_domain = $conf->get('config.cookie_domain', '');
     $cookie_path = $conf->get('config.cookie_path', '/');
     setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
     // set the request var
     JRequest::setVar('language', $lang_code);
     // set current language
     jimport('joomla.language.language');
     $conf = JFactory::getConfig();
     $debug = $conf->get('debug_lang');
     $lang = JLanguage::getInstance($lang_code, $debug);
     JFactory::$language = $lang;
     self::$_lang = $vars['lang'];
 }
Example #15
0
 function sendOnPageLoad($max = 5)
 {
     $db = EasyBlogHelper::db();
     $config = EasyBlogHelper::getConfig();
     $sendHTML = $config->get('main_mailqueuehtmlformat', 0);
     // Delete existing mails that has already been sent.
     $query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_mailq') . ' WHERE ' . $db->nameQuote('status') . '=' . $db->Quote(1) . ' AND DATEDIFF(NOW(), `created`) >= 7';
     $db->setQuery($query);
     $db->Query();
     $query = 'SELECT `id` FROM `#__easyblog_mailq` WHERE `status` = 0';
     $query .= ' ORDER BY `created` ASC';
     $query .= ' LIMIT ' . $max;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!empty($result)) {
         foreach ($result as $mail) {
             $mailq = EasyBlogHelper::getTable('MailQueue', 'Table');
             $mailq->load($mail->id);
             // update the status to 1 == proccessed
             $mailq->status = 1;
             if ($mailq->store()) {
                 // Send emails out.
                 if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
                     $mail = JFactory::getMailer();
                     $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 } else {
                     JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 }
             }
         }
     }
 }
Example #16
0
 protected function _tokenValue($force = false)
 {
     if (empty($this->_token_value) || $force) {
         $this->_token_value = JUtility::getToken($force);
     }
     return parent::_tokenValue($force);
 }
Example #17
0
	public function display()
	{
		$state = $this->getModel()->getState();

		$folders = KFactory::get('com://admin/files.controller.folder')
			->container($state->container)
			->tree(true)
			->browse();

		$this->assign('folders', $folders);

		$config = KFactory::get('com://admin/files.model.configs')->getItem();

		// prepare an extensions array for fancyupload
		$extensions = $config->upload_extensions;

		$this->assign('allowed_extensions', $extensions);
		$this->assign('maxsize'           , $config->upload_maxsize);
		$this->assign('path'              , $state->container->relative_path);
		$this->assign('sitebase'          , ltrim(JURI::root(true), '/'));
		$this->assign('token'             , JUtility::getToken());
		$this->assign('session'           , JFactory::getSession());

		if (!$this->editor) {
			$this->assign('editor', '');
		}

		return parent::display();
	}
Example #18
0
	function display($tpl=null)
	{
		$r = new JObject();
		$r->token = JUtility::getToken(true);
		
		echo json_encode($r);
	}
Example #19
0
 /**
  * Method for logging out with Magento (Single Sign On)
  * 
  * @param string $username
  * @return bool|exit
  */
 public static function doSSOLogout($username = null)
 {
     // Abort if the input is not valid
     if (empty($username)) {
         return false;
     }
     // Get system variables
     $application = JFactory::getApplication();
     $session = JFactory::getSession();
     // Determine the application
     $application_name = $application->isAdmin() ? 'admin' : 'frontend';
     // Get the security token
     $token = method_exists('JSession', 'getFormToken') ? JSession::getFormToken() : JUtility::getToken();
     // Set the redirection URL
     if ($application_name == 'admin') {
         $redirect = JURI::current();
     } else {
         $redirect = MageBridgeUrlHelper::current();
     }
     // Construct the URL
     $arguments = array('sso=logout', 'app=' . $application_name, 'redirect=' . base64_encode($redirect), 'userhash=' . MageBridgeEncryptionHelper::encrypt($username), 'token=' . $token);
     $url = MageBridgeModelBridge::getInstance()->getMagentoBridgeUrl() . '?' . implode('&', $arguments);
     // Redirect the browser to Magento
     MageBridgeModelDebug::getInstance()->notice("SSO: Logout of '{$username}' from " . $application_name);
     $application->redirect($url);
     return true;
 }
Example #20
0
 protected function _actionRequest(KCommandContext $context)
 {
     if (!($email = KRequest::get('post.email', 'email'))) {
         $this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error');
         return false;
     }
     $user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem();
     if (!$user->id || $user->block) {
         $this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_USER'), 'error');
         return false;
     }
     $helper = $this->getService('com://site/users.helper.password');
     $token = $helper->getHash($helper->getRandom());
     $salt = $helper->getSalt($token);
     $user->activation = md5($token . $salt) . ':' . $salt;
     $user->save();
     $configuration = JFactory::getConfig();
     $site_name = $configuration->getValue('sitename');
     $site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT);
     $url = $site_url . JRoute::_('index.php?option=com_users&view=reset&layout=confirm');
     $from_email = $configuration->getValue('mailfrom');
     $from_name = $configuration->getValue('fromname');
     $subject = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TITLE', $site_name);
     $body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $site_name, $token, $url);
     if (!JUtility::sendMail($from_email, $from_name, $email, $subject, $body)) {
         $this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_CONFIRMATION_EMAIL'), 'error');
         return false;
     } else {
         $this->_redirect = 'index.php?option=com_users&view=reset&layout=confirm';
     }
 }
Example #21
0
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_categories', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
     // Fake parameters
     $_POST['task'] = 'apply';
     $_REQUEST['task'] = 'apply';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $context = 'category';
     // Clear userstate just in case
     $model = APIodel::getInstance('Category', 'CategoriesModel');
     $success = $model->save($data);
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (!$success) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_CATEGORIES_SAVE_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $model->get('state')->get($context . '.id');
         // Checkin category
         $model->checkin($response->id);
     }
     $this->plugin->setResponse($response);
 }
Example #22
0
 public function getOnClick()
 {
     $id = KRequest::get('get.id', 'int');
     $token = JUtility::getToken();
     $json = "{method:'post', url:'index.php?option=com_create&view=component&id={$id}', formelem:'adminForm', params:{action:'generate', _token:'{$token}'}}";
     return 'new KForm(' . $json . ').submit();';
 }
Example #23
0
 /**
  * Get a list of logged users.
  *
  * @param	JObject	The module parameters.
  * @return	mixed	An array of articles, or false on error.
  */
 public static function getList($params)
 {
     // Initialise variables
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $query = $db->getQuery(true);
     $query->select('s.time, s.client_id, u.id, u.name, u.username');
     $query->from('#__session AS s');
     $query->leftJoin('#__users AS u ON s.userid = u.id');
     $query->where('s.guest = 0');
     $db->setQuery($query, 0, $params->get('count', 5));
     $results = $db->loadObjectList();
     // Check for database errors
     if ($error = $db->getErrorMsg()) {
         JError::raiseError(500, $error);
         return false;
     }
     foreach ($results as $k => $result) {
         $results[$k]->logoutLink = '';
         if ($user->authorise('core.manage', 'com_users')) {
             $results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
             $results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JUtility::getToken() . '=1');
         }
         if ($params->get('name', 1) == 0) {
             $results[$k]->name = $results[$k]->username;
         }
     }
     return $results;
 }
Example #24
0
 public static function parseJdocTags($data)
 {
     $replace = array();
     $matches = array();
     if (preg_match_all('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data, $matches)) {
         $matches[0] = array_reverse($matches[0]);
         $matches[1] = array_reverse($matches[1]);
         $matches[2] = array_reverse($matches[2]);
         $count = count($matches[1]);
         for ($i = 0; $i < $count; $i++) {
             $attribs = JUtility::parseAttributes($matches[2][$i]);
             $type = $matches[1][$i];
             if ($type != 'modules') {
                 continue;
             }
             $name = isset($attribs['name']) ? $attribs['name'] : null;
             if (empty($name)) {
                 continue;
             }
             unset($attribs['name']);
             jimport('joomla.application.module.helper');
             $modules = JModuleHelper::getModules($name);
             $moduleHtml = null;
             if (!empty($modules)) {
                 foreach ($modules as $module) {
                     $moduleHtml .= JModuleHelper::renderModule($module, $attribs);
                 }
             }
             $data = str_replace($matches[0][$i], $moduleHtml, $data);
         }
     }
     return $data;
 }
Example #25
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
Example #26
0
 /**
  * Example prepare redSHOP Product method
  *
  * Method is called by the product view
  *
  * @param    object        The Product Template Data
  * @param    object        The product params
  * @param    object        The product object
  */
 public function afterUpdateStock($stockroom_data)
 {
     $redshopMail = new redshopMail();
     if ($stockroom_data['regular_stock'] || $stockroom_data['preorder_stock']) {
         $userData = $this->getNotifyUsers($stockroom_data);
         if (count($userData) > 0) {
             for ($u = 0; $u < count($userData); $u++) {
                 $productData = $this->getProductData($userData[$u]);
                 $productDetail = $productData['product_detail'];
                 $productName = $productData['product_name'];
                 $notify_template = $redshopMail->getMailtemplate(0, "notify_stock_mail");
                 if (count($notify_template) > 0) {
                     $message = $notify_template[0]->mail_body;
                     $mail_subject = $notify_template[0]->mail_subject;
                 } else {
                     return;
                 }
                 $message = str_replace("{stocknotify_intro_text}", JText::_('COM_REDSHOP_STOCK_NOTIFY_INTRO_TEXT'), $message);
                 $message = str_replace("{product_detail}", $productDetail, $message);
                 $mail_subject = str_replace("{product_name}", $productName, $mail_subject);
                 if ($userData[$u]->user_email) {
                     JUtility::sendMail(SHOP_NAME, SHOP_NAME, $userData[$u]->user_email, $mail_subject, $message, 1);
                 }
                 $this->deleteNotifiedUsers($userData[$u]);
             }
         }
     }
 }
Example #27
0
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_k2', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/item.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     // Fake parameters
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     // Clear userstate just in case
     $row = $this->save();
     if ($this->getError()) {
         $response = $this->getErrorResponse(400, $this->getError());
     } elseif (!$row->id) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_API_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $row->id;
     }
     $this->plugin->setResponse($response);
 }
Example #28
0
 function t3_init()
 {
     t3import('core.parameter');
     t3import('core.extendable');
     t3import('core.template');
     t3import('core.basetemplate');
     t3import('core.cache');
     t3import('core.head');
     t3import('core.hook');
     t3import('core.joomla.view');
     if (!class_exists('JModuleHelper', false)) {
         t3import('core.joomla.modulehelper');
     }
     t3import('core.joomla.pagination');
     //Load template language
     $this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
     $params = T3Common::get_template_based_params();
     //instance cache object.
     $devmode = $params ? $params->get('devmode', '0') == '1' : false;
     T3Cache::getInstance($devmode);
     //Check if enable T3 info mode. Enable by default (if not set)
     if ($params->get('infomode', 1) == 1) {
         if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp')) {
             JRequest::setVar('t3info', JRequest::getCmd('tp'));
         }
     }
     $key = T3Cache::getPageKey();
     $data = null;
     $user =& JFactory::getUser();
     if (!$devmode && JRequest::getCmd('cache') != 'no') {
         T3Cache::setCaching(true);
         JResponse::allowCache(true);
     }
     $data = T3Cache::get($key);
     if ($data) {
         if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
             $mainframe = JFactory::getApplication();
             $token = JUtility::getToken();
             $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
             $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
             $data = preg_replace($search, $replacement, $data);
             JResponse::setBody($data);
             echo JResponse::toString($mainframe->getCfg('gzip'));
             if (JDEBUG) {
                 global $_PROFILER;
                 $_PROFILER->mark('afterCache');
                 echo implode('', $_PROFILER->getBuffer());
             }
             $mainframe->close();
         }
     }
     //Preload template
     t3import('core.preload');
     $preload = T3Preload::getInstance();
     $preload->load();
     $doc =& JFactory::getDocument();
     $t3 = T3Template::getInstance($doc);
     $t3->_html = $data;
 }
Example #29
0
 /**
  * Plugin that loads module positions within content
  *
  * @param   string $context The context of the content being passed to the plugin.
  * @param   object &$article The article object.  Note $article->text is also available
  * @param   mixed &$params The article params
  * @param   integer $page The 'page' number
  *
  * @return  mixed   true if there is an error. Void otherwise.
  *
  * @since   1.6
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     // Don't run this plugin when the content is being indexed
     if ($context == 'com_finder.indexer') {
         return true;
     }
     // require_once( JURI::root(true).'/includes/domit/xml_saxy_lite_parser.php' );//xml_domit_lite_parser.php
     //$live_site = JURI::base();
     // Start IFRAME Replacement
     // define the regular expression for the bot
     $plugin = JPluginHelper::getPlugin('content', 'iframe');
     $pluginParams = new JRegistry($plugin->params);
     $regex = "#{iframe*(.*?)}(.*?){/iframe}#s";
     $plugin_enabled = $pluginParams->get('enabled', '1');
     if ($plugin_enabled == "0") {
         $article->text = preg_replace($regex, '', $article->text);
     } else {
         if (preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER) > 0) {
             $db = JFactory::getDBO();
             //Ket noi CSDL
             $url = JRequest::getCmd('src');
             //JRequest::getCmd
             foreach ($matches as $match) {
                 $params0 = JUtility::parseAttributes($match[1]);
                 $params0['src'] = @$params0['src'] ? $params0['src'] : $pluginParams->get('src', 'http://www.luyenkim.net');
                 if ($url != '') {
                     if (strpos($url, 'http://') == false) {
                         $params0['src'] = 'http://' . $url;
                     }
                 }
                 //$params0['src'] = filter_var($params0['src'], FILTER_SANITIZE_URL);
                 $params0['height'] = @$params0['height'] ? $params0['height'] : $pluginParams->get('height', '400');
                 $params0['width'] = @$params0['width'] ? $params0['width'] : $pluginParams->get('width', '100%');
                 $params0['marginheight'] = @$params0['marginheight'] ? $params0['marginheight'] : $pluginParams->get('marginheight', '0');
                 $params0['marginwidth'] = @$params0['marginwidth'] ? $params0['marginwidth'] : $pluginParams->get('marginwidth', '0');
                 $params0['scrolling'] = @$params0['scrolling'] ? $params0['scrolling'] : $pluginParams->get('scrolling', '0');
                 $params0['frameborder'] = @$params0['frameborder'] ? $params0['frameborder'] : $pluginParams->get('frameborder', '0');
                 $params0['align'] = @$params0['align'] ? $params0['align'] : $pluginParams->get('align', 'bottom');
                 $params0['name'] = @$params0['name'] ? $params0['name'] : $pluginParams->get('name', '');
                 $params0['noframes'] = @$params0['noframes'] ? $params0['noframes'] : $pluginParams->get('noframes', '');
                 if (@$match[2]) {
                     $url = $match[2];
                 } else {
                     $url = $params0['src'];
                 }
                 $url = strip_tags(rtrim(ltrim($url)));
                 $name = $params0['name'];
                 $noframes = $params0['noframes'];
                 unset($params0['src']);
                 unset($params0['name']);
                 unset($params0['noframes']);
                 $article->text = preg_replace($regex, JHTML::iframe($url, $name, $params0, $noframes), $article->text, 1);
                 unset($params0);
             }
         }
         // End IFRAME Replacement
     }
     //end of else enable
 }
Example #30
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState()
 {
     jimport('joomla.utilities.utility');
     $basename = JRequest::getString(JUtility::getHash($this->_context . '.basename'), '__SITE__', 'cookie');
     $this->setState('basename', $basename);
     $compressed = JRequest::getInt(JUtility::getHash($this->_context . '.compressed'), 1, 'cookie');
     $this->setState('compressed', $compressed);
 }