Example #1
0
 function uninstall()
 {
     if (count(JError::getErrors()) > 0) {
         echo "Error condition - Uninstallation not successfull! You have to manually remove com_jotcache from '.._extensions' table as well as to drop '.._jotcache' and '.._jotcache_exclude' tables";
     } else {
         echo "Uninstallation successfull!";
     }
 }
	/**
	 * Test JError::getErrors
	 *
	 * @return  void
	 */
	public function testGetErrors()
	{
		JErrorInspector::manipulateStack(array('value1', 'value2', 'value3'));

		$this->assertThat(
			JError::getErrors(),
			$this->equalTo(array('value1', 'value2', 'value3')),
			'Somehow a basic getter did not manage to return the static value'
		);

		JErrorInspector::manipulateStack(array());
	}
Example #3
0
 function display($tpl = null)
 {
     // Initialize variables
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $app =& JFactory::getApplication();
     $errors =& JError::getErrors();
     $titulo = JText::_('.~ JOOPOA - Usuários ~.');
     // Set page title
     $document->setTitle($title);
     $this->assign('titulo', $titulo);
     parent::display($tpl);
 }
Example #4
0
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     // Initialize variables
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $app =& JFactory::getApplication();
     $titulo = JText::_('.~ JOOPOA - Listar ~.');
     // Set page title
     $document->setTitle($title);
     $errors =& JError::getErrors();
     $this->assign('sobre', "Informações adicionais sobre o JOOPOA!!!");
     $this->assign('titulo', $titulo);
     parent::display($tpl);
 }
Example #5
0
 function display($tpl = null)
 {
     // Initialize variables
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $app =& JFactory::getApplication();
     $errors =& JError::getErrors();
     $titulo = JText::_('.~ JOOPOA - WS - Sobre ~.');
     $params =& JComponentHelper::getParams('com_joopoa');
     // Set page title
     $document->setTitle($title);
     $this->assign('sobre', "Informações adicionais sobre o JOOPOA - WS!!!");
     $this->assign('titulo', $titulo);
     $this->assign('paramsTable', $params->render());
     parent::display($tpl);
 }
Example #6
0
 public function save($coupon = null)
 {
     global $aecConfig;
     $this->confirmed = 1;
     $this->loadPlanObject();
     $add =& $this;
     $exchange = $silent = null;
     $this->triggerMIs('before_invoice_confirm', $exchange, $add, $silent);
     if (empty($this->userid)) {
         if (!empty($aecConfig->cfg['skip_registration'])) {
             if (!$this->reCaptchaCheck()) {
                 return false;
             }
         }
         $dbtmpl = new configTemplate();
         $dbtmpl->loadDefault();
         if (!empty($dbtmpl->settings['tos'])) {
             $tos = aecGetParam('tos', 0, true, array('bool'));
             if (!$tos) {
                 $this->confirmed = 0;
                 return $this->confirm();
             }
         }
         if (!empty($this->plan)) {
             if (!isset($this->plan->params['override_activation'])) {
                 $this->plan->params['override_activation'] = false;
             }
             if (!isset($this->plan->params['override_regmail'])) {
                 $this->plan->params['override_regmail'] = false;
             }
             $this->userid = aecRegistration::saveUserRegistration($this->passthrough, false, $this->plan->params['override_activation'], $this->plan->params['override_regmail']);
         } else {
             $this->userid = aecRegistration::saveUserRegistration($this->passthrough);
         }
         if (!$this->userid) {
             $errors = JError::getErrors();
             aecErrorAlert(JText::_('COM_USERS_REGISTRATION_SAVE_FAILED'));
         }
     }
     $this->loadMetaUser(true);
     $this->metaUser->setTempAuth();
     if (!empty($this->plan)) {
         if ($this->verifyMIForms($this->plan) === false) {
             $this->confirmed = 0;
             return $this->confirm();
         }
     } elseif (!empty($this->cart)) {
         $check = true;
         foreach ($this->cart as $ci) {
             if ($this->verifyMIForms($ci['obj']) === false) {
                 $check = false;
             }
         }
         if (!$check) {
             $this->confirmed = 0;
             return $this->confirm();
         }
     }
     return $this->checkout(0, null, $coupon);
 }
Example #7
0
 function display($tpl = null)
 {
     $config =& JFactory::getConfig();
     $user =& JFactory::getUser();
     $model =& $this->getModel();
     $formModel =& $this->_formView->getModel();
     //Get the active menu item
     $usersConfig =& JComponentHelper::getParams('com_fabrik');
     $model->setId($usersConfig->get('packageid', JRequest::getInt('packageid', 0)));
     $package =& $model->getPackage();
     $model->_lastTask = JRequest::getVar('task', '');
     $model->_senderBlock = JRequest::getVar('fabrik_senderBlock', '');
     //@TODO: not sure if this is used?
     $model->_lastTaskStatus = JRequest::getVar('taskstatus', '');
     /** @var string any data created by the lasttask - e.g. data to create a new table row with */
     $model->_lastTaskData = JRequest::getVar('taskData', '');
     // TODO: query table/forms to find out which blocks are releated to the block that has updated itself
     $model->_updateBlocks = JRequest::getVar('fbUpdateBlocks', array());
     $model->loadTables();
     $package =& $model->getPackage();
     $usedForms = array();
     if ($package->tables != '') {
         $tableids = explode(",", $package->tables);
         foreach ($tableids as $i) {
             if ($i === '') {
                 continue;
             }
             //in PHP5 objects are assigned by reference as default -
             //cloning object doesnt deep clone other oject references either??
             //this copy method might be intensive
             $tableView = clone $this->_tableView;
             $tableView->setId($i);
             $tableView->_isMambot = true;
             $tableModel =& $tableView->getModel();
             $tableModel->setId($i);
             $tableModel->_packageId = $this->_id;
             $tableModel->_postMethod = 'ajax';
             $table =& $tableModel->getTable();
             $this->blocks[$table->label] = $tableView->display();
             $table = $tableModel->getTable();
             $formModel =& $tableModel->getForm();
             $formModel->_editable = 1;
             $formView = clone $this->_formView;
             //used to buffer output
             $formView->_isMambot = true;
             $formView->setId($table->form_id);
             $formModel->_postMethod = 'ajax';
             $formModel->_packageId = $this->_id;
             $usedForms[] = $formModel->_id;
             $formView->setModel($formModel, true);
             $this->blocks['form_' . $formModel->_id] = $formView->display();
             //creating a read only view
             $formModel->_editable = 0;
             $formView->setModel($formModel, true);
             $orgiView = JRequest::getVar('view', 'form');
             $view = JRequest::setVar('view', 'details');
             $this->blocks[$table->label . ' details'] = $formView->display();
             JRequest::setVar('view', $orgiView);
         }
     }
     // see if we have any forms that dont record to the database that need to be added to blocks[]
     // can occur when redering a form in a module with use ajax turned on
     if ($package->forms != '') {
         $formids = explode(",", $package->forms);
         foreach ($formids as $fid) {
             if (!array_key_exists('form_' . $fid, $this->blocks)) {
                 $formModel->_editable = 1;
                 $formView = clone $this->_formView;
                 //used to buffer output
                 $formView->_isMambot = true;
                 $formView->setId($fid);
                 $formModel->_postMethod = 'ajax';
                 $formModel->_packageId = $this->_id;
                 $usedForms[] = $formModel->_id;
                 $formView->setModel($formModel, true);
                 $this->blocks['form_' . $formModel->_id] = $formView->display();
             }
         }
     }
     $model->render();
     $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views';
     $tmpl = JRequest::getVar('layout', 'default');
     //$this->blocks = $model->_blocks;
     $this->_setPath('template', $this->_basePath . DS . 'package' . DS . 'tmpl' . DS . $tmpl);
     if (!isset($package->template)) {
         $package->template = 'default';
         $tmpl = JRequest::getVar('layout', $package->template);
     } else {
         //set by table module in ajax mode
         $tmpl = $package->template;
     }
     $this->_includeCSS($tmpl);
     $this->_basePath = COM_FABRIK_FRONTEND . DS . 'views';
     $this->_setPath('template', $this->_basePath . DS . 'package' . DS . 'tmpl' . DS . $tmpl);
     $liveTmplPath = JURI::root() . '/components/com_fabrik/views/package/tmpl/' . $tmpl . '/';
     FabrikHelperHTML::mootools();
     FabrikHelperHTML::mocha();
     // check for a custom js file and include it if it exists
     $aJsPath = JPATH_SITE . DS . "components" . DS . "com_fabrik" . DS . "views" . DS . "package" . DS . "tmpl" . DS . $tmpl . DS . "javascript.js";
     if (file_exists($aJsPath)) {
         FabrikHelperHTML::script("javascript.js", 'components/com_fabrik/views/package/tmpl/' . $tmpl . '/', true);
     }
     //ensure we don't have an incorrect version of mootools loaded
     FabrikHelperHTML::cleanMootools();
     if ($this->_isMambot) {
         $res = $this->loadTemplate();
         if (JError::isError($res)) {
             print_r(JError::getErrors());
         } else {
             return $res;
         }
     } else {
         parent::display();
     }
 }
Example #8
0
 /**
  * copy a table
  */
 public function doCopy()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $this->setRedirect('index.php?option=com_fabrik&c=table');
     $cid = JRequest::getVar('cid', null, 'post', 'array');
     $model =& JModel::getInstance('table', 'FabrikModel');
     $n = count($cid);
     if ($n > 0) {
         foreach ($cid as $id) {
             $model->setId($id);
             $table =& $model->getTable();
             $ok = $model->copy();
             if (JError::isError($ok)) {
                 JRequest::set($origRequest);
                 return JError::getErrors();
             }
         }
     } else {
         return JError::raiseWarning(500, JText::_('NO ITEMS SELECTED'));
     }
     JRequest::set($origRequest);
     $this->setMessage(JText::sprintf('ITEMS COPIED', $n));
 }
Example #9
0
 /**
  * Install dependency package.
  *
  * @return  string
  */
 public function install()
 {
     // Get dependency declaration
     $extension = (object) $_GET;
     // Get product edition
     $edition = $this->getEdition();
     // Get Joomla version
     $JVersion = new JVersion();
     // Get download link
     $url = $this->getLink($extension, $JVersion);
     // Finalize upload
     if (isset($_FILES['package'])) {
         if (!JFile::upload($_FILES['package']['tmp_name'], $this->config->get('tmp_path') . '/' . $_FILES['package']['name'])) {
             throw new Exception('FAIL:' . JText::_('JSN_EXTFW_INSTALLER_PACKAGE_SAVING_FAILED') . '|' . $url);
         }
         $this->input->set('package', $_FILES['package']['name']);
     }
     if ($this->input->getString('package')) {
         // Initialize dependency package path
         $file = $this->config->get('tmp_path') . '/' . $this->input->getString('package');
         $path = substr($file, 0, -4);
         if (!is_file($file)) {
             // Check temporary directory existen
             if (!$this->config->get('ftp_enable') and (!is_dir($this->config->get('tmp_path')) or !is_writable($this->config->get('tmp_path')))) {
                 throw new Exception('FAIL:' . JText::_('JSN_EXTFW_INSTALLER_TEMPORARY_DIRECTORY_NOT_WRITABLE') . '|' . $url);
             } else {
                 throw new Exception('FAIL:' . JText::sprintf('JSN_EXTFW_INSTALLER_PACKAGE_NOT_FOUND', $this->input->getString('package')) . '|' . $url);
             }
         }
         $extension->source = $path;
         // Extract dependency package
         if (!JArchive::extract($file, $path)) {
             throw new Exception('FAIL:' . JText::_('JSN_EXTFW_INSTALLER_EXTRACT_PACKAGE_FAIL') . '|' . $url);
         }
         // Switch off debug mode to catch JInstaller error message manually
         $config = JFactory::getConfig();
         $debug = $config->get('debug');
         $config->set('debug', version_compare($JVersion->RELEASE, '3.0', '<') ? false : true);
         // Get JSN Installer
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/subinstall.php';
         $installer = $this->input->getCmd('option') . 'InstallerScript';
         $installer = new $installer();
         try {
             $installer->installExtension($extension);
         } catch (Exception $e) {
             throw $e;
         }
         // Clean-up temporary folder and file
         JFolder::delete($extension->source);
         JFile::delete("{$extension->source}.zip");
         // Restore debug settings
         $config->set('debug', $debug);
         // Check if installation success
         $messages = JFactory::getApplication()->getMessageQueue();
         if (class_exists('JError')) {
             $messages = array_merge(JError::getErrors(), $messages);
         }
         foreach ($messages as $message) {
             if (is_array($message) and @$message['type'] == 'error' or is_object($message) and (!method_exists($message, 'get') or $message->get('level') == E_ERROR)) {
                 $errors[is_array($message) ? $message['message'] : $message->getMessage()] = 1;
             }
         }
         if (@count($errors)) {
             throw new Exception('<ul><li>' . implode('</li><li>', array_keys($errors)) . '</li></ul>');
         }
     } else {
         throw new Exception('FAIL:' . JText::_('JSN_EXTFW_INSTALLER_MISSING_PACKAGE_NAME') . '|' . $url);
     }
     return 'SUCCESS';
 }
Example #10
0
	function login($username, $password) {
		$app = JFactory::getApplication();
		// Populate the data array:
		$data = array();
		$data['return'] = base64_decode(JRequest::getVar('return', '', 'POST', 'BASE64'));
		// Set the return URL if empty.
		if (empty($data['return'])) {
			$data['return'] = 'index.php?option=com_users&view=profile';
		}
		// Get the log in options.
		$options = array();
		$options['remember'] = JRequest::getBool('remember', false);
		$options['return'] = $data['return'];
		// Get the log in credentials.
		$credentials = array();
		$credentials['username'] = $username;
		$credentials['password'] = $password;
		// Perform the log in.
		$error = $app->login($credentials, $options);
		if (JOOMLA16 || JOOMLA17) {
			$plugin = JPluginHelper::getPlugin('user', 'oseuser');
			if (!empty($plugin)) {
				$pluginParams = oseJSON::decode($plugin->params);
				$loginRedirect = $pluginParams->loginRedirect;
				$redmenuid = $pluginParams->redmenuid;
				$sefroutemethod = $pluginParams->sefroutemethod;
			} else {
				$loginRedirect = false;
			}
		} else {
			$plugin = JPluginHelper::getPlugin('user', 'oseuser');
			if (!empty($plugin)) {
				$pluginParams = new JParameter($plugin->params);
				$loginRedirect = $pluginParams->get('loginRedirect');
				$redmenuid = $pluginParams->get('redmenuid');
				$sefroutemethod = $pluginParams->get('sefroutemethod');
			} else {
				$loginRedirect = false;
			}
		}
		$user = JFactory::getUser();
		$db = JFactory::getDBO();
		$query = " SELECT a.menuid" . " FROM `#__menu` as m" . " LEFT JOIN `#__osemsc_acl` as a ON a.menuid = m.id" . " LEFT JOIN `#__osemsc_member` as b ON b.msc_id = a.id"
				. " WHERE b.member_id={$user->id} AND b.status = 1 ORDER BY a.menuid DESC LIMIT 1";
		$db->setQuery($query);
		$menu = $db->loadObject();
		if (!empty($menu)) {
			$redmenuid = $menu->menuid;
		}
		if ($loginRedirect && !empty($redmenuid)) {
			$db = JFactory::getDBO();
			$query = "SELECT * FROM `#__menu` WHERE `id` = " . (int) $redmenuid;
			$db->setQuery($query);
			$menu = $db->loadObject();
			switch ($sefroutemethod) {
			default:
			case 0:
				$return = ($menu->link == 'index.php?Itemid=') ? 'index.php' : $menu->link . "&Itemid=" . $menu->id;
				break;
			case 1:
				$return = ($menu->link == 'index.php?Itemid=') ? JRoute::_(JURI::root() . 'index.php') : JRoute::_($menu->link . "&Itemid=" . $menu->id);
				break;
			case 2:
				$return = JRoute::_($menu->alias);
				break;
			}
		} else {
			$session = JFactory::getSession();
			$return = $session->get('oseReturnUrl', base64_encode(JURI::root() . 'index.php?option=com_osemsc&view=login'));
			$return = base64_decode($return);
		}
		$result = array();
		// Check if the log in succeeded.
		$user_id = intval(JUserHelper::getUserId($username));
		$user = JFactory::getUser($user_id);
		if ($user->get('block')) {
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('LOGIN_DENIED_YOUR_ACCOUNT_HAS_EITHER_BEEN_BLOCKED_OR_YOU_HAVE_NOT_ACTIVATED_IT_YET');
			$result['returnUrl'] = $return;
			return $result;
		}
		if ($error) {
			if (!JError::isError($error)) {
				$result['success'] = true;
				$result['returnUrl'] = $return;
				return $result;
			} else {
				$errors = JError::getErrors();
				$result['success'] = false;
				$result['title'] = JText::_('Error');
				$result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError();
				$result['returnUrl'] = $return;
				return $result;
			}
		} else {
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError();
			$result['returnUrl'] = $return;
			return $result;
		}
	}
Example #11
0
 /**
  * Action to handle install extension request.
  *
  * @param   string  $id  Identified name of the extension to be installed.
  *
  * @return  void
  */
 public function installExtensionAction($id = null)
 {
     JSNTplHelper::isDisabledFunction('set_time_limit') or set_time_limit(0);
     // Get necessary variables
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $tmpPath = $config->get('tmp_path');
     if (empty($id)) {
         $id = $this->request->getString('id');
     }
     // Disable debug system
     $config->set('debug', 0);
     // Path to sample data file
     $xmlFiles = glob("{$tmpPath}/{$this->template['name']}_sampledata/*.xml");
     if (empty($xmlFiles)) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_SAMPLE_DATA_PACKAGE'));
     }
     // Load XML document
     $xml = simplexml_load_file(current($xmlFiles));
     $extensions = $xml->xpath("//extension[@identifiedname=\"{$id}\"]");
     if (!empty($extensions)) {
         $extension = current($extensions);
         $name = (string) $extension['name'];
         $type = (string) $extension['type'];
         switch ($type) {
             case 'component':
                 $name = 'com_' . $name;
                 break;
             case 'module':
                 $name = 'mod_' . $name;
                 break;
         }
         $this->_cleanExtensionAssets($name);
         // Install JSN Extension Framework first if not already installed
         if ($type == 'component') {
             // Get details about JSN Extension Framework
             $extfw = $xml->xpath('//extension[@identifiedname="ext_framework"]');
             if (!empty($extfw)) {
                 $extfw = current($extfw);
                 if ($this->_getExtensionState((string) $extfw['name'], (string) $extfw['version']) != 'installed') {
                     // Install JSN Extension Framework
                     try {
                         $this->installExtensionAction('ext_framework');
                     } catch (Exception $e) {
                         throw $e;
                     }
                 }
             }
         }
     }
     // Download package from lightcart
     try {
         $packageFile = JSNTplApiLightcart::downloadPackage($id, 'FREE', null, null, "{$tmpPath}/{$this->template['name']}_sampledata/");
     } catch (Exception $e) {
         throw $e;
     }
     if (!is_file($packageFile)) {
         throw new Exception("Package file not found: {$packageFile}");
     }
     // Load extension installation library
     jimport('joomla.installer.helper');
     // Rebuild menu structure
     $this->_rebuildMenus();
     // Extract downloaded package
     $unpackedInfo = JInstallerHelper::unpack($packageFile);
     $installer = JInstaller::getInstance();
     if (empty($unpackedInfo) or !isset($unpackedInfo['dir'])) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_EXTENSION_PACKAGE_FILE'));
     }
     // Install extracted package
     $installResult = $installer->install($unpackedInfo['dir']);
     if ($installResult === false) {
         foreach (JError::getErrors() as $error) {
             throw $error;
         }
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $unpackedInfo['dir']);
     $this->_activeExtension(array('type' => $type, 'name' => $name));
     // Rebuild menu structure
     $this->_rebuildMenus();
 }
Example #12
0
File: debug.php Project: akksi/jcg
 /**
  * Show the debug info
  *
  */
 function __destruct()
 {
     global $_PROFILER;
     // Do not render if debugging is not enabled
     if (!JDEBUG) {
         return;
     }
     if (!$_PROFILER instanceof JProfiler) {
         return;
     }
     // Load the language
     $this->loadLanguage();
     // Capture output
     $contents = ob_get_contents();
     ob_end_clean();
     // No debug for Safari and Chrome redirection
     if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
         echo $contents;
         return;
     }
     $document = JFactory::getDocument();
     $doctype = $document->getType();
     // Only render for HTML output
     if ($doctype !== 'html') {
         echo $contents;
         return;
     }
     // If the user is not allowed to view the output then end here
     $filterGroups = (array) $this->params->get('filter_groups', null);
     if (!empty($filterGroups)) {
         $userGroups = JFactory::getUser()->get('groups');
         if (!array_intersect($filterGroups, array_keys($userGroups))) {
             echo $contents;
             return;
         }
     }
     // Load language file
     $this->loadLanguage('plg_system_debug');
     $profiler =& $_PROFILER;
     ob_start();
     echo '<div id="system-debug" class="profiler">';
     $errors = JError::getErrors();
     if (!empty($errors)) {
         echo '<h4>' . JText::_('PLG_DEBUG_ERRORS') . '</h4><ol>';
         while ($error = JError::getError(true)) {
             echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('PLG_DEBUG_INFO') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('PLG_DEBUG_BACKTRACE') . '</h4>' . JError::renderBacktrace($error) . '</li>';
         }
         echo '</ol>';
     }
     if ($this->params->get('profile', 1)) {
         echo '<h4>' . JText::_('PLG_DEBUG_PROFILE_INFORMATION') . '</h4>';
         foreach ($profiler->getBuffer() as $mark) {
             echo '<div>' . $mark . '</div>';
         }
     }
     if ($this->params->get('memory', 1)) {
         echo '<h4>' . JText::_('PLG_DEBUG_MEMORY_USAGE') . '</h4>';
         $bytes = $profiler->getMemory();
         echo JHtml::_('number.bytes', $bytes);
         echo ' (' . number_format($bytes) . ' Bytes)';
     }
     if ($this->params->get('queries', 1)) {
         $newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i';
         $db = JFactory::getDbo();
         echo '<h4>' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $db->getTicker()) . '</h4>';
         if ($log = $db->getLog()) {
             echo '<ol>';
             $selectQueryTypeTicker = array();
             $otherQueryTypeTicker = array();
             foreach ($log as $k => $sql) {
                 // Start Query Type Ticker Additions
                 $fromStart = stripos($sql, 'from');
                 $whereStart = stripos($sql, 'where', $fromStart);
                 if ($whereStart === false) {
                     $whereStart = stripos($sql, 'order by', $fromStart);
                 }
                 if ($whereStart === false) {
                     $whereStart = strlen($sql) - 1;
                 }
                 $fromString = substr($sql, 0, $whereStart);
                 $fromString = str_replace("\t", " ", $fromString);
                 $fromString = str_replace("\n", " ", $fromString);
                 $fromString = trim($fromString);
                 // Initialize the select/other query type counts the first time:
                 if (!isset($selectQueryTypeTicker[$fromString])) {
                     $selectQueryTypeTicker[$fromString] = 0;
                 }
                 if (!isset($otherQueryTypeTicker[$fromString])) {
                     $otherQueryTypeTicker[$fromString] = 0;
                 }
                 // Increment the count:
                 if (stripos($sql, 'select') === 0) {
                     $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1;
                     unset($otherQueryTypeTicker[$fromString]);
                 } else {
                     $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1;
                     unset($selectQueryTypeTicker[$fromString]);
                 }
                 // Finish Query Type Ticker Additions
                 $text = htmlspecialchars($sql, ENT_QUOTES);
                 $text = preg_replace($newlineKeywords, '<br />&#160;&#160;\\0', $text);
                 echo '<li>' . $text . '</li>';
             }
             echo '</ol>';
             if ($this->params->get('query_types', 1)) {
                 // Get the totals for the query types:
                 $totalSelectQueryTypes = count($selectQueryTypeTicker);
                 $totalOtherQueryTypes = count($otherQueryTypeTicker);
                 $totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes;
                 echo '<h4>' . JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '</h4>';
                 if ($totalSelectQueryTypes) {
                     echo '<h5>' . JText::sprintf('PLG_DEBUG_SELECT_QUERIES') . '</h5>';
                     arsort($selectQueryTypeTicker);
                     echo '<ol>';
                     foreach ($selectQueryTypeTicker as $table => $occurrences) {
                         echo '<li>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences) . '</li>';
                     }
                     echo '</ol>';
                 }
                 if ($totalOtherQueryTypes) {
                     echo '<h5>' . JText::sprintf('PLG_DEBUG_OTHER_QUERIES') . '</h5>';
                     arsort($otherQueryTypeTicker);
                     echo '<ol>';
                     foreach ($otherQueryTypeTicker as $table => $occurrences) {
                         echo '<li>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences) . '</li>';
                     }
                     echo '</ol>';
                 }
             }
         }
     }
     // Show language debug only if enabled
     if (JFactory::getApplication()->getCfg('debug_lang')) {
         $lang = JFactory::getLanguage();
         if ($this->params->get('language_errorfiles', 1)) {
             echo '<h4>' . JText::_('PLG_DEBUG_LANGUAGE_FILES_IN_ERROR') . '</h4>';
             $errorfiles = $lang->getErrorFiles();
             if (count($errorfiles)) {
                 echo '<ul>';
                 foreach ($errorfiles as $file => $error) {
                     echo "<li>{$error}</li>";
                 }
                 echo '</ul>';
             } else {
                 echo '<pre>' . JText::_('JNONE') . '</pre>';
             }
         }
         if ($this->params->get('language_files', 1)) {
             echo '<h4>' . JText::_('PLG_DEBUG_LANGUAGE_FILES_LOADED') . '</h4>';
             echo '<ul>';
             $extensions = $lang->getPaths();
             foreach ($extensions as $extension => $files) {
                 foreach ($files as $file => $status) {
                     echo "<li>{$file} {$status}</li>";
                 }
             }
             echo '</ul>';
         }
         if ($this->params->get('language_strings')) {
             $stripFirst = $this->params->get('strip-first');
             $stripPref = $this->params->get('strip-prefix');
             $stripSuff = $this->params->get('strip-suffix');
             echo '<h4>' . JText::_('PLG_DEBUG_UNTRANSLATED_STRINGS') . '</h4>';
             echo '<pre>';
             $orphans = $lang->getOrphans();
             if (count($orphans)) {
                 ksort($orphans, SORT_STRING);
                 $guesses = array();
                 foreach ($orphans as $key => $occurance) {
                     if (is_array($occurance) and isset($occurance[0])) {
                         $info =& $occurance[0];
                         $file = @$info['file'];
                         if (!isset($guesses[$file])) {
                             $guesses[$file] = array();
                         }
                         // Prepare the key
                         if (($pos = strpos($info['string'], '=')) > 0) {
                             $parts = explode('=', $info['string']);
                             $key = $parts[0];
                             $guess = $parts[1];
                         } else {
                             $guess = str_replace('_', ' ', $info['string']);
                             if ($stripFirst) {
                                 $parts = explode(' ', $guess);
                                 if (count($parts) > 1) {
                                     array_shift($parts);
                                     $guess = implode(' ', $parts);
                                 }
                             }
                             $guess = trim($guess);
                             if ($stripPref) {
                                 $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess));
                             }
                             if ($stripSuff) {
                                 $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess));
                             }
                         }
                         $key = trim(strtoupper($key));
                         $key = preg_replace('#\\s+#', '_', $key);
                         $key = preg_replace('#\\W#', '', $key);
                         // Prepare the text
                         $guesses[$file][] = $key . '="' . $guess . '"';
                     }
                 }
                 foreach ($guesses as $file => $keys) {
                     echo "\n\n# " . ($file ? $file : JText::_('PLG_DEBUG_UNKNOWN_FILE')) . "\n\n";
                     echo implode("\n", $keys);
                 }
             } else {
                 echo JText::_('JNONE');
             }
             echo '</pre>';
         }
     }
     echo '</div>';
     $debug = ob_get_clean();
     $body = JResponse::getBody();
     $body = str_replace('</body>', $debug . '</body>', $body);
     echo str_replace('</body>', $debug . '</body>', $contents);
 }
Example #13
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterRender()
 {
     global $_PROFILER;
     // Do not render if debugging is not enabled
     if (!JDEBUG) {
         return;
     }
     $document =& JFactory::getDocument();
     $doctype = $document->getType();
     // Only render for HTML output
     if ($doctype !== 'html') {
         return;
     }
     // If the user is not allowed to view the output then end here
     $filterGroups = (array) $this->params->get('filter_groups', null);
     if (!empty($filterGroups)) {
         $userGroups = JFactory::getUser()->get('groups');
         if (!array_intersect($filterGroups, array_keys($userGroups))) {
             return;
         }
     }
     $profiler =& $_PROFILER;
     ob_start();
     echo '<div id="system-debug" class="profiler">';
     $errors = JError::getErrors();
     if (!empty($errors)) {
         echo '<h4>' . JText::_('Errors') . '</h4><ol>';
         while ($error = JError::getError(true)) {
             echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('Info') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('Backtrace') . '</h4>' . JError::renderBacktrace($error) . '</li>';
         }
         echo '</ol>';
     }
     if ($this->params->get('profile', 1)) {
         echo '<h4>' . JText::_('Debug_Profile_Information') . '</h4>';
         foreach ($profiler->getBuffer() as $mark) {
             echo '<div>' . $mark . '</div>';
         }
     }
     if ($this->params->get('memory', 1)) {
         echo '<h4>' . JText::_('Debug_Memory_Usage') . '</h4>';
         echo number_format($profiler->getMemory());
     }
     if ($this->params->get('queries', 1)) {
         $newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i';
         $db =& JFactory::getDbo();
         echo '<h4>' . JText::sprintf('Debug_Queries_logged', $db->getTicker()) . '</h4>';
         if ($log = $db->getLog()) {
             echo '<ol>';
             foreach ($log as $k => $sql) {
                 $text = preg_replace($newlineKeywords, '<br />&nbsp;&nbsp;\\0', $sql);
                 echo '<li>' . $text . '</li>';
             }
             echo '</ol>';
         }
     }
     $lang =& JFactory::getLanguage();
     if ($this->params->get('language_files', 1)) {
         echo '<h4>' . JText::_('Debug_Language_Files_Loaded') . '</h4>';
         echo '<ul>';
         $extensions = $lang->getPaths();
         foreach ($extensions as $extension => $files) {
             foreach ($files as $file => $status) {
                 echo "<li>{$file} {$status}</li>";
             }
         }
         echo '</ul>';
     }
     if ($this->params->get('language_strings')) {
         $stripFirst = $this->params->get('strip-first');
         $stripPref = $this->params->get('strip-prefix');
         $stripSuff = $this->params->get('strip-suffix');
         echo '<h4>' . JText::_('Debug_Untranslated_Strings') . '</h4>';
         echo '<pre>';
         $orphans = $lang->getOrphans();
         if (count($orphans)) {
             ksort($orphans, SORT_STRING);
             $guesses = array();
             foreach ($orphans as $key => $occurance) {
                 if (is_array($occurance) and isset($occurance[0])) {
                     $info =& $occurance[0];
                     $file = @$info['file'];
                     if (!isset($guesses[$file])) {
                         $guesses[$file] = array();
                     }
                     // Prepare the key
                     if (($pos = strpos($info['string'], '=')) > 0) {
                         $parts = explode('=', $info['string']);
                         $key = $parts[0];
                         $guess = $parts[1];
                     } else {
                         $guess = str_replace('_', ' ', $info['string']);
                         if ($stripFirst) {
                             $parts = explode(' ', $guess);
                             if (count($parts) > 1) {
                                 array_shift($parts);
                                 $guess = implode(' ', $parts);
                             }
                         }
                         $guess = trim($guess);
                         if ($stripPref) {
                             $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess));
                         }
                         if ($stripSuff) {
                             $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess));
                         }
                     }
                     $key = trim(strtoupper($key));
                     $key = preg_replace('#\\s+#', '_', $key);
                     $key = preg_replace('#\\W#', '', $key);
                     // Prepare the text
                     $guesses[$file][] = $key . '=' . $guess;
                 }
             }
             foreach ($guesses as $file => $keys) {
                 echo "\n\n# " . ($file ? $file : JText::_('Debug_Unknown_file')) . "\n\n";
                 echo implode("\n", $keys);
             }
         } else {
             echo JText::_('JNone');
         }
         echo '</pre>';
     }
     echo '</div>';
     $debug = ob_get_clean();
     $body = JResponse::getBody();
     $body = str_replace('</body>', $debug . '</body>', $body);
     JResponse::setBody($body);
 }
Example #14
0
/**
 * Write XML sitemap file
 * 
 * @param   string $file          content that should be written in the sitemap file
 * @param   string $location      full path to the sitemap file that is being written
 * @param   string $option        the name of the component
 * @param   string $sitemap_url   url of the sitemap file
 * @return  nothing 
 */
function writeXML($file, $location, $option, $sitemap_url)
{
    $app =& JFactory::getApplication();
    $buffer = pack("CCC", 0xef, 0xbb, 0xbf);
    $buffer .= utf8_encode($file);
    if (JFile::write($location, $buffer)) {
        $app->enqueueMessage("Success, wrote {$location}");
    } else {
        $errors[] = JError::getErrors();
        foreach ($errors as $error) {
            $app->enqueueMessage($error->message, 'error');
        }
        $app->enqueueMessage("{$location} is not writable", 'error');
    }
    return;
}
Example #15
0
 /**
  * Install downloaded update package.
  *
  * @param   string  $path  Path to downloaded update package.
  *
  * @return  void
  */
 public function install($path)
 {
     $config = JFactory::getConfig();
     // Initialize update package path
     $path = $config->get('tmp_path') . '/' . $path;
     if (!is_file($path)) {
         throw new Exception(JText::_('JSN_EXTFW_PACKAGE_FILE_NOT_FOUND') . ': ' . $path);
     }
     // Extract update package
     if (!JArchive::extract($path, substr($path, 0, -4))) {
         throw new Exception(JText::_('JSN_EXTFW_UPDATE_EXTRACT_PACKAGE_FAIL'));
     }
     $path = substr($path, 0, -4);
     // Do any preparation needed before installing update package
     try {
         $this->beforeInstall($path);
     } catch (Exception $e) {
         throw $e;
     }
     // Get Joomla version object
     $JVersion = new JVersion();
     // Switch off debug mode to catch JInstaller error message manually
     $config = JFactory::getConfig();
     $debug = $config->get('debug');
     $config->set('debug', version_compare($JVersion->RELEASE, '3.0', '<') ? false : true);
     // Install update package
     $installer = JInstaller::getInstance();
     try {
         $installer->update($path);
     } catch (Exception $e) {
         throw $e;
     }
     // Restore debug settings
     $config->set('debug', $debug);
     // Check if installation success
     $messages = JFactory::getApplication()->getMessageQueue();
     if (class_exists('JError')) {
         $messages = array_merge(JError::getErrors(), $messages);
     }
     foreach ($messages as $message) {
         if (is_array($message) and @$message['type'] == 'error' or is_object($message) and (!method_exists($message, 'get') or $message->get('level') == E_ERROR)) {
             $errors[is_array($message) ? $message['message'] : $message->getMessage()] = 1;
         }
     }
     if (@count($errors)) {
         throw new JException('<ul><li>' . implode('</li><li>', array_keys($errors)) . '</li></ul>');
     }
     // Do any extra work needed after installing update package
     try {
         $this->afterInstall($path);
     } catch (Exception $e) {
         throw $e;
     }
     // Complete AJAX based update package installation task
     jexit('DONE');
 }
function _sendStatus()
{
    $msg = array();
    /** @var JException $error */
    foreach (JError::getErrors() as $error) {
        if ($error->get('level')) {
            $msg[] = $error->get('message');
        }
    }
    if (count($msg)) {
        $msg = '<p>' . implode('</p><p>', $msg) . '</p>';
    } else {
        $msg = 'ok';
    }
    echo $msg;
    jexit();
}
Example #17
0
    static function uninstall()
    {
        JError::setErrorHandling(E_ERROR, 'Message');
        $db = JFactory::getDBO();
        $lang = JFactory::getLanguage();
        $lang->load('com_mobilejoomla');
        $addons_installer = JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/packages/install.addons.php';
        if (JFile::exists($addons_installer)) {
            include $addons_installer;
        }
        //uninstall plugins
        if (function_exists('MJAddonUninstallPlugins')) {
            MJAddonUninstallPlugins();
        }
        if (!self::UninstallPlugin('system', 'mobilebot')) {
            JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . ' Mobile Joomla Plugin.');
        }
        if (!self::UninstallPlugin('quickicon', 'mjcpanel')) {
            JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . ' Quickicon - Mobile Joomla! CPanel Icon.');
        }
        $checkers = array('simple', 'always', 'domains');
        foreach ($checkers as $plugin) {
            if (!self::UninstallPlugin('mobile', $plugin)) {
                JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . ' Mobile - ' . ucfirst($plugin) . '.');
            }
        }
        //uninstall amdd
        if (self::getExtensionId('plugin', 'amdd', 'mobile') !== null) {
            if (!self::UninstallPlugin('mobile', 'amdd')) {
                JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . ' Mobile - AMDD.');
            }
            self::clear_amdd_db();
        }
        //uninstall scientia
        if (self::getExtensionId('plugin', 'scientia', 'mobile') !== null) {
            if (self::isJoomla15()) {
                $scientia_helper = JPATH_ROOT . '/plugins/mobile/scientia/scientia_helper.php';
                if (file_exists($scientia_helper)) {
                    include_once $scientia_helper;
                    ScientiaHelper::disablePlugin();
                    ScientiaHelper::dropDatabase();
                }
            }
            if (!self::UninstallPlugin('mobile', 'scientia')) {
                JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . ' Mobile - ScientiaMobile.');
            }
        }
        //uninstall templates
        if (function_exists('MJAddonUninstallTemplates')) {
            MJAddonUninstallTemplates();
        }
        $templateslist = array('mobile_smartphone', 'mobile_wap', 'mobile_imode', 'mobile_iphone');
        foreach ($templateslist as $t) {
            if (!self::UninstallTemplate($t)) {
                JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . " Mobile Joomla '{$t}' template.");
            }
        }
        //uninstall modules from previous MJ releases
        $moduleslist = array('mod_mj_pda_menu', 'mod_mj_wap_menu', 'mod_mj_imode_menu', 'mod_mj_iphone_menu');
        foreach ($moduleslist as $m) {
            if (JFolder::exists(JPATH_SITE . '/modules/' . $m)) {
                if (!self::UninstallModule($m)) {
                    JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . " Mobile Joomla '{$m}' module.");
                }
            }
        }
        if (function_exists('MJAddonUninstallModules')) {
            MJAddonUninstallModules();
        }
        $moduleslist = array('mod_mj_menu', 'mod_mj_markupchooser', 'mod_mj_header');
        if (version_compare(JVERSION, '2.5', '<')) {
            $moduleslist[] = 'mod_mj_adminicon';
        }
        foreach ($moduleslist as $m) {
            if (!self::UninstallModule($m)) {
                JError::raiseError(0, JText::_('COM_MJ__CANNOT_UNINSTALL') . " Mobile Joomla '{$m}' module.");
            }
        }
        // remove extmanager tables
        $db = JFactory::getDBO();
        $query = "DROP TABLE IF EXISTS `#__mj_modules`, `#__mj_plugins`";
        $db->setQuery($query);
        $db->query();
        self::cleanPluginsCache();
        //Show uninstall status
        $msg = '';
        $count = 0;
        /** @var JException $error */
        foreach (JError::getErrors() as $error) {
            if ($error->get('level') & E_ERROR) {
                $count++;
            }
        }
        if ($count == 0) {
            $msg .= '<b>' . str_replace('[VER]', self::MJ_publicVersion(), JText::_('COM_MJ__UNINSTALL_OK')) . '</b>';
        }
        ?>
<link rel="stylesheet" type="text/css"
      href="http://www.mobilejoomla.com/checker.php?v=<?php 
        echo urlencode(self::MJ_version());
        ?>
&amp;s=2&amp;j=<?php 
        echo urlencode(JVERSION);
        ?>
"/>
<a href="http://www.mobilejoomla.com/" id="mjupdate" target="_blank"></a>
<?php 
        echo $msg;
        return true;
    }
Example #18
0
 /**
  * Show the debug info
  *
  * @since  1.6
  */
 public function __destruct()
 {
     // Do not render if debugging or language debug is not enabled
     if (!JDEBUG && !JFactory::getApplication()->getCfg('debug_lang')) {
         return;
     }
     // Load the language
     $this->loadLanguage();
     // Capture output
     $contents = ob_get_contents();
     if ($contents) {
         ob_end_clean();
     }
     // No debug for Safari and Chrome redirection
     if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
         echo $contents;
         return;
     }
     // Only render for HTML output
     if ('html' !== JFactory::getDocument()->getType()) {
         echo $contents;
         return;
     }
     // If the user is not allowed to view the output then end here
     $filterGroups = (array) $this->params->get('filter_groups', null);
     if (!empty($filterGroups)) {
         $userGroups = JFactory::getUser()->get('groups');
         if (!array_intersect($filterGroups, $userGroups)) {
             echo $contents;
             return;
         }
     }
     // Load language file
     $this->loadLanguage('plg_system_debug');
     $html = '';
     // Some "mousewheel protecting" JS
     $html .= "<script>function toggleContainer(name) {\n\t\t\tvar e = document.getElementById(name);// MooTools might not be available ;)\n\t\t\te.style.display = (e.style.display == 'none') ? 'block' : 'none';\n\t\t}</script>";
     $html .= '<div id="system-debug" class="profiler">';
     $html .= '<h1>' . JText::_('PLG_DEBUG_TITLE') . '</h1>';
     if (JDEBUG) {
         if (JError::getErrors()) {
             $html .= $this->display('errors');
         }
         $html .= $this->display('session');
         if ($this->params->get('profile', 1)) {
             $html .= $this->display('profile_information');
         }
         if ($this->params->get('memory', 1)) {
             $html .= $this->display('memory_usage');
         }
         if ($this->params->get('queries', 1)) {
             $html .= $this->display('queries');
         }
     }
     if (JFactory::getApplication()->getCfg('debug_lang')) {
         if ($this->params->get('language_errorfiles', 1)) {
             $languageErrors = JFactory::getLanguage()->getErrorFiles();
             $html .= $this->display('language_files_in_error', $languageErrors);
         }
         if ($this->params->get('language_files', 1)) {
             $html .= $this->display('language_files_loaded');
         }
         if ($this->params->get('language_strings')) {
             $html .= $this->display('untranslated_strings');
         }
     }
     $html .= '</div>';
     echo str_replace('</body>', $html . '</body>', $contents);
 }
Example #19
0
 /**
  * Start process to install template update
  *
  * @return  void
  */
 public function installPackageAction()
 {
     // Initialize variables
     $joomlaConfig = JFactory::getConfig();
     $packageFile = $joomlaConfig->get('tmp_path') . '/jsn-' . $this->template['id'] . '.zip';
     $packagePath = substr($packageFile, 0, -4);
     $templatePath = JPATH_ROOT . '/templates/' . $this->template['name'];
     // Checking downloaded template package
     if (!is_file($packageFile)) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_PACKAGE_FILE_NOT_FOUND'));
     }
     // Check if template is copied to another name
     if ($xml = simplexml_load_file($packagePath . '/template/templateDetails.xml')) {
         if (strcasecmp($this->template['name'], trim((string) $xml->name)) != 0) {
             // Update templateDetails.xml with new name
             $content = str_replace((string) $xml->name, $this->template['name'], JFile::read($packagePath . '/template/templateDetails.xml'));
             JFile::write($packagePath . '/template/templateDetails.xml', $content);
         }
     }
     // Get list of files to be updated
     try {
         $update = JSNTplHelper::getFilesBeingUpdated($this->template['name'], $packageFile);
         if (!$update) {
             throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_PACKAGE_FILE_NOT_FOUND'));
         }
     } catch (Exception $e) {
         throw $e;
     }
     // Include template checksum and manifest files
     in_array('template.checksum', $update['edit']) or $update['edit'][] = 'template.checksum';
     in_array('templateDetails.xml', $update['edit']) or $update['edit'][] = 'templateDetails.xml';
     // Import necessary libraries
     jimport('joomla.filesystem.file');
     jimport('joomla.installer.helper');
     // Update the template
     foreach ($update as $action => $files) {
         foreach ($files as $file) {
             if ($action != 'add') {
                 JFile::delete($templatePath . '/' . $file);
             }
             if ($action != 'delete' and JFolder::create(dirname($templatePath . '/' . $file))) {
                 JFile::copy($packagePath . '/template/' . $file, $templatePath . '/' . $file);
             }
         }
     }
     // Move backup file to template directory
     $source = $joomlaConfig->get('tmp_path') . '/' . $this->template['name'] . '_modified_files.zip';
     $target = $templatePath . '/backups/' . date('y-m-d_H-i-s') . '_modified_files.zip';
     if (is_readable($source)) {
         JFile::copy($source, $target);
         // Remove backup file in temporary directory
         filesize($source) != filesize($target) or JFile::delete($source);
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $packagePath);
     // Check if update success
     $messages = JFactory::getApplication()->getMessageQueue();
     if (class_exists('JError')) {
         $messages = array_merge(JError::getErrors(), $messages);
     }
     foreach ($messages as $message) {
         if (is_array($message) and @$message['type'] == 'error' or is_object($message) and (!method_exists($message, 'get') or $message->get('level') == E_ERROR)) {
             $msg = str_replace(JPATH_ROOT, '', is_array($message) ? $message['message'] : $message->getMessage());
             $errors[$msg] = 1;
         }
     }
     if (@count($errors)) {
         throw new Exception('<ul><li>' . implode('</li><li>', array_keys($errors)) . '</li></ul>');
     }
     // Update template version in manifest cache
     $manifest = JSNTplHelper::getManifest($this->template['name'], true);
     $template = JTable::getInstance('extension');
     $template->load(array('type' => 'template', 'element' => $this->template['name']));
     if ($template->extension_id) {
         // Decode manifest cache
         $template->manifest_cache = json_decode($template->manifest_cache);
         // Set new template version
         $template->manifest_cache->version = (string) $manifest->version;
         // Re-encode manifest cache
         $template->manifest_cache = json_encode($template->manifest_cache);
         // Store new data
         $template->store();
     }
     // Update template version in template definition file
     $content = preg_replace('/\\$JoomlaShine_Template_Version = \'[^\']+\';/i', '$JoomlaShine_Template_Version = \'' . (string) $manifest->version . '\';', JFile::read($templatePath . '/template.defines.php'));
     JFile::write($templatePath . '/template.defines.php', $content);
     // Clear backup state
     JFactory::getApplication()->setUserState('jsn-tplfw-backup-done', 0);
     // Clean up compressed files
     $this->_cleanCache();
 }
Example #20
0
 /**
  * Install downloaded package to joomla system
  *
  * @return  void
  */
 public function installAction()
 {
     JSNTplHelper::isDisabledFunction('set_time_limit') or set_time_limit(0);
     $config = JFactory::getConfig();
     $config->set('debug', 0);
     if (!is_file($packageFile = $this->session->get($this->template['id'] . '.upgradePackage'))) {
         throw new Exception("Package file not found: {$packageFile}");
     }
     // Load extension installation library
     jimport('joomla.installer.helper');
     $language = JFactory::getLanguage();
     $language->load('lib_joomla', JPATH_SITE);
     // Unpack downloaded upgrade package
     $unpackedInfo = JInstallerHelper::unpack($packageFile);
     if (empty($unpackedInfo) or !isset($unpackedInfo['dir'])) {
         throw new Exception(JText::_('JSN_TPLFW_ERROR_CANNOT_EXTRACT_TEMPLATE_PACKAGE_FILE'));
     }
     // Check if template is copied to another name
     if ($xml = simplexml_load_file($unpackedInfo['dir'] . '/template/templateDetails.xml')) {
         if (strcasecmp($this->template['name'], trim((string) $xml->name)) != 0) {
             // Update templateDetails.xml with new name
             $content = str_replace((string) $xml->name, $this->template['name'], JFile::read($unpackedInfo['dir'] . '/template/templateDetails.xml'));
             JFile::write($unpackedInfo['dir'] . '/template/templateDetails.xml', $content);
         }
     }
     // Upgrade now
     $installer = JInstaller::getInstance();
     $installer->setUpgrade(true);
     $installResult = $installer->install($unpackedInfo['dir']);
     if ($installResult === false) {
         foreach (JError::getErrors() as $error) {
             throw $error;
         }
     }
     // Clean up temporary data
     JInstallerHelper::cleanupInstall($packageFile, $unpackedInfo['dir']);
     // Retrieve style id of installed package
     $q = $this->dbo->getQuery(true);
     $q->select('id');
     $q->from('#__template_styles');
     $q->where('template = ' . $q->quote($this->template['name']));
     $this->dbo->setQuery($q);
     $styleId = $this->dbo->loadResult();
     $q = $this->dbo->getQuery(true);
     $q->update('#__template_styles');
     $q->set('home = 0');
     $q->where('client_id = 0');
     $this->dbo->setQuery($q);
     $this->dbo->{$this->queryMethod}();
     $q = $this->dbo->getQuery(true);
     $q->update('#__template_styles');
     $q->set('home = 1');
     $q->where('id = ' . (int) $styleId);
     $this->dbo->setQuery($q);
     $this->dbo->{$this->queryMethod}();
     $this->setResponse(array('styleId' => $styleId));
 }
Example #21
0
 /**
  * Show the debug info
  */
 public function __destruct()
 {
     if (!App::isAdmin() && !App::isSite()) {
         return;
     }
     // Do not render if debugging or language debug is not enabled
     if (!Config::get('debug') && !Config::get('debug_lang')) {
         return;
     }
     // Load the language
     $this->loadLanguage();
     // Capture output
     // [!] zooley Nov 03, 2014 - PHP 5.4 changed behavior for ob_end_clean().
     //     ob_end_clean(), called in JError, clears and stops buffering.
     //     On error, pages, there will be no buller to get so ob_get_contents()
     //     will be false.
     $contents = ob_get_contents();
     if ($contents) {
         ob_end_clean();
     } else {
         return;
     }
     // No debug for Safari and Chrome redirection
     if (isset($_SERVER['HTTP_USER_AGENT']) && strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
         echo $contents;
         return;
     }
     // Only render for HTML output
     if ('html' !== Document::getType()) {
         echo $contents;
         return;
     }
     // If the user is not allowed to view the output then end here
     $filterGroups = (array) $this->params->get('filter_groups', null);
     if (!empty($filterGroups)) {
         $userGroups = User::get('groups');
         if (!array_intersect($filterGroups, $userGroups)) {
             echo $contents;
             return;
         }
     } else {
         $filterUsers = $this->params->get('filter_users', null);
         if (!empty($filterUsers)) {
             $filterUsers = explode(',', $filterUsers);
             $filterUsers = array_map('trim', $filterUsers);
             if (!in_array(\User::get('username'), $filterUsers)) {
                 echo $contents;
                 return;
             }
         }
     }
     // Load language file
     $this->loadLanguage('plg_system_debug');
     $html = '';
     // Some "mousewheel protecting" JS
     $html .= '<div id="system-debug" class="' . $this->params->get('theme', 'dark') . ' profiler">';
     $html .= '<div class="debug-head" id="debug-head">';
     $html .= '<h1>' . Lang::txt('PLG_DEBUG_TITLE') . '</h1>';
     $html .= '<a class="debug-close-btn" href="javascript:" onclick="Debugger.close();"><span class="icon-remove">' . Lang::txt('PLG_DEBUG_CLOSE') . '</span></a>';
     if (Config::get('debug')) {
         if ($this->params->get('memory', 1)) {
             $html .= '<span class="debug-indicator"><span class="icon-memory text" data-hint="' . Lang::txt('PLG_DEBUG_MEMORY_USAGE') . '">' . $this->displayMemoryUsage() . '</span></span>';
         }
         if (\JError::getErrors()) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-errors" onclick="Debugger.toggleContainer(this, \'debug-errors\');"><span class="text">' . Lang::txt('PLG_DEBUG_ERRORS') . '</span><span class="badge">' . count(\JError::getErrors()) . '</span></a>';
         }
         $dumper = \Hubzero\Debug\Dumper::getInstance();
         if ($dumper->hasMessages()) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-console" onclick="Debugger.toggleContainer(this, \'debug-debug\');"><span class="text">' . Lang::txt('PLG_DEBUG_CONSOLE') . '</span>';
             $html .= '<span class="badge">' . count($dumper->messages()) . '</span>';
             $html .= '</a>';
         }
         $html .= '<a href="javascript:" class="debug-tab debug-tab-request" onclick="Debugger.toggleContainer(this, \'debug-request\');"><span class="text">' . Lang::txt('PLG_DEBUG_REQUEST_DATA') . '</span></a>';
         $html .= '<a href="javascript:" class="debug-tab debug-tab-session" onclick="Debugger.toggleContainer(this, \'debug-session\');"><span class="text">' . Lang::txt('PLG_DEBUG_SESSION') . '</span></a>';
         if ($this->params->get('profile', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-timeline" onclick="Debugger.toggleContainer(this, \'debug-profile_information\');"><span class="text">' . Lang::txt('PLG_DEBUG_PROFILE_TIMELINE') . '</span></a>';
         }
         if ($this->params->get('queries', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-database" onclick="Debugger.toggleContainer(this, \'debug-queries\');"><span class="text">' . Lang::txt('PLG_DEBUG_QUERIES') . '</span><span class="badge">' . \App::get('db')->getCount() . '</span></a>';
         }
     }
     if (Config::get('debug_lang')) {
         if ($this->params->get('language_errorfiles', 1)) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-errors" onclick="Debugger.toggleContainer(this, \'debug-language_files_in_error\');"><span class="text">' . Lang::txt('PLG_DEBUG_LANGUAGE_FILE_ERRORS') . '</span>';
             $html .= '<span class="badge">' . count(\Lang::getErrorFiles()) . '</span>';
             $html .= '</a>';
         }
         if ($this->params->get('language_files', 1)) {
             $total = 0;
             foreach (\Lang::getPaths() as $extension => $files) {
                 $total += count($files);
             }
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-files" onclick="Debugger.toggleContainer(this, \'debug-language_files_loaded\');"><span class="text">' . Lang::txt('PLG_DEBUG_LANGUAGE_FILES_LOADED') . '</span>';
             $html .= '<span class="badge">' . $total . '</span>';
             $html .= '</a>';
         }
         if ($this->params->get('language_strings')) {
             $html .= '<a href="javascript:" class="debug-tab debug-tab-lang-untranslated" onclick="Debugger.toggleContainer(this, \'debug-untranslated_strings\');"><span class="text">' . Lang::txt('PLG_DEBUG_UNTRANSLATED') . '</span>';
             $html .= '<span class="badge">' . count(\Lang::getOrphans()) . '</span>';
             $html .= '</a>';
         }
     }
     $html .= '</div>';
     $html .= '<div class="debug-body" id="debug-body">';
     if (Config::get('debug')) {
         if ($dumper->hasMessages()) {
             $html .= $this->display('debug');
         }
         $html .= $this->display('request');
         $html .= $this->display('session');
         if ($this->params->get('profile', 1)) {
             $html .= $this->display('profile_information');
         }
         if ($this->params->get('memory', 1)) {
             $html .= $this->display('memory_usage');
         }
         if ($this->params->get('queries', 1)) {
             $html .= $this->display('queries');
         }
     }
     if (Config::get('debug_lang')) {
         if ($this->params->get('language_errorfiles', 1)) {
             $languageErrors = Lang::getErrorFiles();
             $html .= $this->display('language_files_in_error', $languageErrors);
         }
         if ($this->params->get('language_files', 1)) {
             $html .= $this->display('language_files_loaded');
         }
         if ($this->params->get('language_strings')) {
             $html .= $this->display('untranslated_strings');
         }
     }
     $html .= '</div>';
     $html .= '</div>';
     $html .= "<script type=\"text/javascript\">\n\t\tif (!document.getElementsByClassName) {\n\t\t\tdocument.getElementsByClassName = (function() {\n\t\t\t\tfunction traverse (node, callback) {\n\t\t\t\t\tcallback(node);\n\t\t\t\t\tfor (var i=0;i < node.childNodes.length; i++) {\n\t\t\t\t\t\ttraverse(node.childNodes[i],callback);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn function (name) {\n\t\t\t\t\tvar result = [];\n\t\t\t\t\ttraverse(document.body,function(node) {\n\t\t\t\t\t\tif (node.className && (' ' + node.className + ' ').indexOf(' ' + name + ' ') > -1) {\n\t\t\t\t\t\t\tresult.push(node);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\tDebugger = {\n\t\t\ttoggleShortFull: function(id) {\n\t\t\t\tvar d = document.getElementById('debug-' + id + '-short');\n\t\t\t\tif (!Debugger.hasClass(d, 'open')) {\n\t\t\t\t\tDebugger.addClass(d, 'open');\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.removeClass(d, 'open');\n\t\t\t\t}\n\n\t\t\t\tvar g = document.getElementById('debug-' + id + '-full');\n\t\t\t\tif (!Debugger.hasClass(g, 'open')) {\n\t\t\t\t\tDebugger.addClass(g, 'open');\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.removeClass(g, 'open');\n\t\t\t\t}\n\t\t\t},\n\t\t\tclose: function() {\n\t\t\t\tvar d = document.getElementById('system-debug');\n\t\t\t\tif (Debugger.hasClass(d, 'open')) {\n\t\t\t\t\tDebugger.removeClass(d, 'open');\n\t\t\t\t}\n\n\t\t\t\tDebugger.deactivate();\n\t\t\t},\n\t\t\tdeactivate: function() {\n\t\t\t\tvar items = document.getElementsByClassName('debug-tab');\n\t\t\t\tfor (var i=0;i<items.length;i++)\n\t\t\t\t{\n\t\t\t\t\tif (Debugger.hasClass(items[i], 'active')) {\n\t\t\t\t\t\tDebugger.removeClass(items[i], 'active');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar items = document.getElementsByClassName('debug-container');\n\t\t\t\tfor (var i=0;i<items.length;i++)\n\t\t\t\t{\n\t\t\t\t\tif (Debugger.hasClass(items[i], 'open')) {\n\t\t\t\t\t\tDebugger.removeClass(items[i], 'open');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\ttoggleContainer: function(el, name) {\n\t\t\t\tif (!Debugger.hasClass(el, 'active')) {\n\t\t\t\t\tvar d = document.getElementById('system-debug');\n\t\t\t\t\tif (!Debugger.hasClass(d, 'open')) {\n\t\t\t\t\t\tDebugger.addClass(d, 'open');\n\t\t\t\t\t}\n\n\t\t\t\t\tDebugger.deactivate();\n\t\t\t\t\tDebugger.addClass(el, 'active');\n\n\t\t\t\t\tvar e = document.getElementById(name);\n\t\t\t\t\tif (e) {\n\t\t\t\t\t\tDebugger.toggleClass(e, 'open');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tDebugger.close();\n\t\t\t\t}\n\t\t\t},\n\t\t\thasClass: function(elem, className) {\n\t\t\t\treturn new RegExp(' ' + className + ' ').test(' ' + elem.className + ' ');\n\t\t\t},\n\t\t\taddClass: function(elem, className) {\n\t\t\t\tif (!Debugger.hasClass(elem, className)) {\n\t\t\t\t\telem.className += ' ' + className;\n\t\t\t\t}\n\t\t\t},\n\t\t\tremoveClass: function(elem, className) {\n\t\t\t\tvar newClass = ' ' + elem.className.replace( /[\\t\\r\\n]/g, ' ') + ' ';\n\t\t\t\tif (Debugger.hasClass(elem, className)) {\n\t\t\t\t\twhile (newClass.indexOf(' ' + className + ' ') >= 0 ) {\n\t\t\t\t\t\tnewClass = newClass.replace(' ' + className + ' ', ' ');\n\t\t\t\t\t}\n\t\t\t\t\telem.className = newClass.replace(/^\\s+|\\s+\$/g, '');\n\t\t\t\t}\n\t\t\t},\n\t\t\ttoggleClass: function(elem, className) {\n\t\t\t\tvar newClass = ' ' + elem.className.replace( /[\\t\\r\\n]/g, ' ') + ' ';\n\t\t\t\tif (Debugger.hasClass(elem, className)) {\n\t\t\t\t\twhile (newClass.indexOf(' ' + className + ' ') >= 0 ) {\n\t\t\t\t\t\tnewClass = newClass.replace(' ' + className + ' ', ' ');\n\t\t\t\t\t}\n\t\t\t\t\telem.className = newClass.replace(/^\\s+|\\s+\$/g, '');\n\t\t\t\t} else {\n\t\t\t\t\telem.className += ' ' + className;\n\t\t\t\t}\n\t\t\t},\n\t\t\taddEvent: function(obj, type, fn) {\n\t\t\t\tif (obj.attachEvent) {\n\t\t\t\t\tobj['e'+type+fn] = fn;\n\t\t\t\t\tobj[type+fn] = function() {\n\t\t\t\t\t\tobj['e'+type+fn]( window.event );\n\t\t\t\t\t};\n\t\t\t\t\tobj.attachEvent('on' + type, obj[type+fn]);\n\t\t\t\t} else {\n\t\t\t\t\tobj.addEventListener( type, fn, false );\n\t\t\t\t}\n\t\t\t},\n\t\t\tremoveEvent: function( obj, type, fn ) {\n\t\t\t\tif (obj.detachEvent) {\n\t\t\t\t\tobj.detachEvent('on' + type, obj[type+fn]);\n\t\t\t\t\tobj[type+fn] = null;\n\t\t\t\t} else {\n\t\t\t\t\tobj.removeEventListener(type, fn, false);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tFunction.prototype.bindD = function(obj) {\n\t\t\tvar _method = this;\n\t\t\treturn function() {\n\t\t\t\treturn _method.apply(obj, arguments);\n\t\t\t};\n\t\t}\n\n\t\tfunction debugDrag(id) {\n\t\t\tthis.id = 'id';\n\t\t\tthis.direction = 'y';\n\t\t}\n\t\tdebugDrag.prototype = {\n\t\t\tinit: function(settings) {\n\t\t\t\tfor (var i in settings)\n\t\t\t\t{\n\t\t\t\t\tthis[i] = settings[i];\n\n\t\t\t\t\tfor (var j in settings[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tthis[i][j] = settings[i][j];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.elem = (this.id.tagName==undefined) ? document.getElementById(this.id) : this.id;\n\t\t\t\tthis.container = this.elem.parentNode;\n\t\t\t\tthis.elem.onmousedown = this._mouseDown.bindD(this);\n\t\t\t},\n\n\t\t\t_mouseDown: function(e) {\n\t\t\t\te = e || window.event;\n\n\t\t\t\tthis.elem.onselectstart=function() {return false};\n\n\t\t\t\tthis._event_docMouseMove = this._docMouseMove.bindD(this);\n\t\t\t\tthis._event_docMouseUp = this._docMouseUp.bindD(this);\n\n\t\t\t\tif (this.onstart) this.onstart();\n\n\t\t\t\tthis.x = e.clientX || e.PageX;\n\t\t\t\tthis.y = e.clientY || e.PageY;\n\n\t\t\t\t//this.left = parseInt(this._getstyle(this.elem, 'left'));\n\t\t\t\t//this.top = parseInt(this._getstyle(this.elem, 'top'));\n\t\t\t\tthis.top = parseInt(this._getstyle(this.container, 'height'));\n\n\t\t\t\tDebugger.addEvent(document, 'mousemove', this._event_docMouseMove);\n\t\t\t\tDebugger.addEvent(document, 'mouseup', this._event_docMouseUp);\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t_getstyle: function(elem, prop) {\n\t\t\t\tif (document.defaultView) {\n\t\t\t\t\treturn document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop);\n\t\t\t\t} else if (elem.currentStyle) {\n\t\t\t\t\tvar prop = prop.replace(/-(\\w)/gi, function(\$0,\$1)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn \$1.toUpperCase();\n\t\t\t\t\t});\n\t\t\t\t\treturn elem.currentStyle[prop];\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t_docMouseMove: function(e) {\n\t\t\t\tthis.setValuesClick(e);\n\t\t\t\tif (this.ondrag) this.ondrag();\n\t\t\t},\n\n\t\t\t_docMouseUp: function(e) {\n\t\t\t\tDebugger.removeEvent(document, 'mousemove', this._event_docMouseMove);\n\n\t\t\t\tif (this.onstop) this.onstop();\n\n\t\t\t\tDebugger.removeEvent(document, 'mouseup', this._event_docMouseUp);\n\t\t\t},\n\n\t\t\tsetValuesClick: function(e) {\n\t\t\t\tif (!Debugger.hasClass(this.container, 'open')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.mouseX = e.clientX || e.PageX;\n\t\t\t\tthis.mouseY = e.clientY || e.pageY;\n\n\t\t\t\tthis.Y = this.top + this.y - this.mouseY - parseInt(this._getstyle(document.getElementById('debug-head'), 'height')); //this.top + this.mouseY - this.y;\n\n\t\t\t\t//this.container.style.height = (this.Y + 6) +'px';\n\t\t\t\tdocument.getElementById('debug-body').style.height = (this.Y + 6) +'px';\n\t\t\t},\n\n\t\t\t_limit: function(val, mn, mx) {\n\t\t\t\treturn Math.min(Math.max(val, Math.min(mn, mx)), Math.max(mn, mx));\n\t\t\t}\n\t\t}\n\t\tvar dragBar = new debugDrag();\n\t\tdragBar.init({id:'debug-head'});\n\t\t</script>";
     echo str_replace('</body>', $html . '</body>', $contents);
 }
Example #22
0
 function display($tpl = null)
 {
     global $mainframe, $option;
     // Initialize variables
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $image = '';
     $menu =& JSite::getMenu();
     $item = $menu->getActive();
     if ($item) {
         $params =& $menu->getParams($item->id);
     } else {
         $params =& $menu->getParams(null);
     }
     $type = !$user->get('guest') ? 'logout' : 'login';
     // Set some default page parameters if not set
     $params->def('page_title', 1);
     if (!$item) {
         $params->def('header_login', '');
         $params->def('header_logout', '');
     }
     $params->def('pageclass_sfx', '');
     $params->def('login', 'index.php');
     $params->def('logout', 'index.php');
     $params->def('description_login', 1);
     $params->def('description_logout', 1);
     $params->def('description_login_text', JText::_('LOGIN_DESCRIPTION'));
     $params->def('description_logout_text', JText::_('LOGOUT_DESCRIPTION'));
     $params->def('image_login', 'key.jpg');
     $params->def('image_logout', 'key.jpg');
     $params->def('image_login_align', 'right');
     $params->def('image_logout_align', 'right');
     $usersConfig =& JComponentHelper::getParams('com_users');
     $params->def('registration', $usersConfig->get('allowUserRegistration'));
     if (!$user->get('guest')) {
         $title = JText::_('Logout');
         // pathway item
         $pathway->addItem($title, '');
         // Set page title
         $document->setTitle($title);
     } else {
         $title = JText::_('Login');
         // pathway item
         $pathway->addItem($title, '');
         // Set page title
         $document->setTitle($title);
     }
     // Build login image if enabled
     if ($params->get('image_' . $type) != -1) {
         $image = 'images/stories/' . $params->get('image_' . $type);
         $image = '<img src="' . $image . '" align="' . $params->get('image_' . $type . '_align') . '" hspace="10" alt="" />';
     }
     // Get the return URL
     if (!($url = JRequest::getVar('return', '', 'method', 'base64'))) {
         $url = base64_encode($params->get($type));
     }
     $errors =& JError::getErrors();
     $this->assign('image', $image);
     $this->assign('type', $type);
     $this->assign('return', $url);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Example #23
0
function writeXML($file, $location, $option, $sitemap_url)
{
    global $mainframe;
    // Write $somecontent to our opened file.
    $buffer = pack("CCC", 0xef, 0xbb, 0xbf);
    $buffer .= utf8_encode($file);
    //$buffer .=$file;
    if (JFile::write($location, $buffer)) {
        $mainframe->enqueueMessage("Success, wrote {$location}");
    } else {
        $errors[] = JError::getErrors();
        foreach ($errors as $error) {
            $mainframe->enqueueMessage($error->message, error);
        }
        $mainframe->enqueueMessage("{$location} is not writable", error);
    }
    return;
}
Example #24
0
function getOkMessageJson($cart)
{
    $errors = JError::getErrors();
    if (count($errors)) {
        return getMessageJson();
    } else {
        return json_encode($cart);
    }
}
Example #25
0
 function installUpdate()
 {
     if (!file_exists($this->versions_path)) {
         $params =& $this->params;
         RokUpdater::updateVersion($params->get('update_name'), $params->get('update_slug'), $params->get('current_version'), $this->details_url);
     }
     // read version file
     jimport('joomla/filesystem.file');
     $version = json_decode(JFile::read($this->versions_path));
     $this->current_version = $version->current_version;
     $alldetails = $this->_decodeJSONData($this->details_path);
     foreach ($alldetails as $key => $details) {
         if ($key == $version->slug) {
             foreach ($details->versions as $newversion) {
                 if (version_compare($this->current_version, $newversion->minimum_version, '>=')) {
                     $details->download_url = $newversion->download_url;
                     $details->version = $newversion->version;
                     $details->md5 = $newversion->md5;
                 }
             }
             $file_path = $this->tmp_path . DS . basename($details->download_url);
             $result = RokUpdater::downloadFile($details->download_url, $file_path);
             if (is_object($result)) {
                 HTML_RokError::showError('Download Failed: ' . $result->message . '(' . $result->number . ')</p>');
                 return false;
             }
             if (md5_file($file_path) != $details->md5) {
                 HTML_RokError::showError('MD5 Mismatch: The MD5 hash for the downloaded file does not match the anticipated value.</p>');
                 return false;
             }
             $extractor = $this->extractor;
             $install_path = $this->tmp_path;
             // Temporary folder to extract the archive into
             $tmpdir = uniqid('install_');
             $install_path = $install_path . DS . $tmpdir;
             switch ($extractor) {
                 case ROKUPDATER_EXTRACTOR_16:
                     RokUpdater::import('joomla.filesystem.archive');
                     if (!JArchive::extract($file_path, $install_path)) {
                         HTML_RokError::showError('Failed to extract archive!');
                         return false;
                     }
                     break;
                 case ROKUPDATER_EXTRACTOR_15:
                     jimport('joomla.filesystem.archive');
                     if (!JArchive::extract($file_path, $install_path)) {
                         HTML_RokError::showError('Failed to extract archive!');
                         return false;
                     }
                     break;
                 case ROKUPDATER_EXTRACTOR_PEAR:
                     jimport('pear.archive_tar.Archive_Tar');
                     $extractor = new Archive_Tar($install_path);
                     if (!$extractor->extract(JPATH_SITE)) {
                         HTML_RokError::showError('Failed to extract archive!');
                         return false;
                     }
                     break;
             }
             jimport('joomla.installer.installer');
             jimport('joomla.installer.helper');
             jimport('joomla.filesystem.folder');
             jimport('joomla.filesystem.file');
             // Get an installer instance
             $installer =& RokStarInstaller::getInstance();
             // Run the installer and catch any output
             ob_start();
             $ret = $installer->install($install_path);
             $output = ob_get_clean();
             $errors = JError::getErrors();
             JFolder::delete($install_path);
             JFile::delete($file_path);
             RokUpdater::updateVersion($details->name, $version->slug, $details->version, $this->details_url);
             return $ret;
         }
     }
 }
Example #26
0
 /**
  * Show the debug info.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function onAfterRespond()
 {
     // Do not render if debugging or language debug is not enabled.
     if (!JDEBUG && !$this->debugLang) {
         return;
     }
     // User has to be authorised to see the debug information.
     if (!$this->isAuthorisedDisplayDebug()) {
         return;
     }
     // Only render for HTML output.
     if (JFactory::getDocument()->getType() !== 'html') {
         return;
     }
     // Capture output.
     $contents = ob_get_contents();
     if ($contents) {
         ob_end_clean();
     }
     // No debug for Safari and Chrome redirection.
     if (strstr(strtolower(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
         echo $contents;
         return;
     }
     // Load language.
     $this->loadLanguage();
     $html = array();
     // Some "mousewheel protecting" JS.
     $html[] = "<script>function toggleContainer(name)\n\t\t{\n\t\t\tvar e = document.getElementById(name);// MooTools might not be available ;)\n\t\t\te.style.display = (e.style.display == 'none') ? 'block' : 'none';\n\t\t}</script>";
     $html[] = '<div id="system-debug" class="profiler">';
     $html[] = '<h1>' . JText::_('PLG_DEBUG_TITLE') . '</h1>';
     if (JDEBUG) {
         if (JError::getErrors()) {
             $html[] = $this->display('errors');
         }
         $html[] = $this->display('session');
         if ($this->params->get('profile', 1)) {
             $html[] = $this->display('profile_information');
         }
         if ($this->params->get('memory', 1)) {
             $html[] = $this->display('memory_usage');
         }
         if ($this->params->get('queries', 1)) {
             $html[] = $this->display('queries');
         }
         if ($this->params->get('logs', 1) && !empty($this->logEntries)) {
             $html[] = $this->display('logs');
         }
     }
     if ($this->debugLang) {
         if ($this->params->get('language_errorfiles', 1)) {
             $languageErrors = JFactory::getLanguage()->getErrorFiles();
             $html[] = $this->display('language_files_in_error', $languageErrors);
         }
         if ($this->params->get('language_files', 1)) {
             $html[] = $this->display('language_files_loaded');
         }
         if ($this->params->get('language_strings')) {
             $html[] = $this->display('untranslated_strings');
         }
     }
     $html[] = '</div>';
     echo str_replace('</body>', implode('', $html) . '</body>', $contents);
 }
Example #27
0
 /**
  * copy a Form
  */
 function copy()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $this->setRedirect('index.php?option=com_fabrik&c=form');
     $cid = JRequest::getVar('cid', null, 'post', 'array');
     $db =& JFactory::getDBO();
     $rule =& JTable::getInstance('form', 'Table');
     $user =& JFactory::getUser();
     $n = count($cid);
     $model =& JModel::getInstance('form', 'FabrikModel');
     if ($n > 0) {
         foreach ($cid as $id) {
             $model->setId($id);
             $form =& $model->getForm();
             if ($form->record_in_database == 1) {
                 $ok = $model->getTableModel()->copy();
             } else {
                 $ok = $model->copy();
             }
             if (JError::isError($ok)) {
                 JRequest::set($origRequest);
                 return JError::getErrors();
             }
         }
     } else {
         return JError::raiseWarning(500, JText::_('NO ITEMS SELECTED'));
     }
     $this->setMessage(JText::sprintf('Items copied', $n));
 }