private function executeRunner($app) { $main = new RecacheRunner(); $input = $app->input; $jcplugin = strtolower($input->getWord('jotcacheplugin')); $jcparams = $input->get->get('jcparams', array(), 'array'); $states = $input->post->get('jcstates', array(), 'array'); $jcstates = array(); if (count($states) > 0) { foreach ($states as $key => $value) { $curState = $app->getUserState('jotcache.' . $jcplugin . '.' . $key, null); $newState = $states[$key]; if ($curState !== $newState) { $jcstates[$key] = $newState; $app->setUserState('jotcache.' . $jcplugin . '.' . $key, $newState); } else { $jcstates[$key] = $curState; } } } $starturl = JURI::root(); if (substr($starturl, -1) == '/') { $starturl = substr($starturl, 0, strlen($starturl) - 1); } $main->doExecute($starturl, $jcplugin, $jcparams, $jcstates); }
function runRecache() { $params = JComponentHelper::getParams("com_jotcache"); $timeout = (int) $params->get('recachetimeout', 300); register_shutdown_function(array($this, 'recacheShutdown')); ini_set('max_execution_time', $timeout); $scopeAllow = array('none', 'chck', 'sel', 'all', 'direct'); $scope = JRequest::getWord('scope', ''); if (in_array($scope, $scopeAllow, TRUE)) { $this->_sql = $this->_db->getQuery(true); switch ($scope) { case 'none': return; case 'chck': $this->_sql->update($this->_db->quoteName('#__jotcache'))->set($this->_db->quoteName('recache') . ' = ' . $this->_db->quote(1))->set($this->_db->quoteName('recache_chck') . ' = ' . $this->_db->quote(0))->where("recache_chck='1'"); $sql = $this->_db->setQuery($this->_sql); $sql->query(); break; case 'sel': $search = JRequest::getString('search'); $com = JRequest::getCmd('com'); $view = JRequest::getCmd('pview'); $mark = JRequest::getInt('mark'); $params = JComponentHelper::getParams("com_jotcache"); $mode = (bool) $params->get('mode'); if ($com) { $this->_sql->where("com='{$com}'"); } if ($view) { $part = $this->_db->quoteName('view'); $this->_sql->where("{$part}='{$view}'"); } if ($mark) { $this->_sql->where("mark='{$mark}'"); } if ($search) { if ($mode) { $this->_sql->where('LOWER(uri) LIKE ' . $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false)); } else { $this->_sql->where('LOWER(title) LIKE ' . $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false)); } } break; default: break; } if ($scope != 'direct') { $this->_sql->update($this->_db->quoteName('#__jotcache'))->set($this->_db->quoteName('recache') . ' = ' . $this->_db->quote(1)); $sql = $this->_db->setQuery($this->_sql); $sql->query(); } $this->controlRecache(1); define('JOTCACHE_RECACHE_BROWSER', true); $main = new RecacheRunner(); $jcplugin = strtolower(JRequest::getWord('jotcacheplugin')); $jcparams = JRequest::getVar('jcparams', array(), 'get', 'array'); $states = JRequest::getVar('jcstates', array(), 'post', 'array'); $jcstates = array(); if (count($states) > 0) { $app = JFactory::getApplication(); foreach ($states as $key => $value) { $cur_state = $app->getUserState('jotcache.' . $jcplugin . '.' . $key, null); $new_state = $states[$key]; if ($cur_state !== $new_state) { $jcstates[$key] = $new_state; $app->setUserState('jotcache.' . $jcplugin . '.' . $key, $new_state); } else { $jcstates[$key] = $cur_state; } } } $starturl = JURI::root(); if (substr($starturl, -1) == '/') { $starturl = substr($starturl, 0, strlen($starturl) - 1); } $main->doExecute($starturl, $jcplugin, $jcparams, $jcstates); } }