function apply() { $input = JFactory::$application->input; $filename = $input->getString('filename'); $type = $input->getString('type'); $filedata = $_POST['filedata']; $dev = $input->getString('dev'); $config['folder_admin'] = "language" . DS . substr($filename, 0, 5); $urldev = ''; if ($dev) { $urldev = "&dev=" . $dev; } if ($type == "SITE") { $jpath = JPATH_SITE; } elseif ($type == "ADMINISTRATOR") { $jpath = JPATH_ADMINISTRATOR; } $openfiledata = JFile::read($jpath . DS . $config['folder_admin'] . DS . $filename); $checkfiledata = JFile::write($jpath . DS . $config['folder_admin'] . DS . $filename, $filedata); JFile::write($jpath . DS . $config['folder_admin'] . DS . $filename . '.backup', $filedata); $app = JFactory::getApplication(); if ($checkfiledata) { $app->enqueueMessage('Saved successful'); } else { $app->enqueueMessage('Saved successful', 'error'); } $this->setRedirect('index.php?option=com_bookpro&view=language&filename=' . $filename . '&type=' . $type . $urldev); }
/** * Extract a ZIP compressed file to a given path * * @access public * @param string $archive Path to ZIP archive to extract * @param string $destination Path to extract archive into * @param array $options Extraction options [unused] * @return boolean True if successful * @since 1.5 */ function extract($archive, $destination, $options = array()) { // Initialize variables $this->_data = null; $this->_metadata = null; if (!($this->_data = JFile::read($archive))) { $this->set('error.message', 'Unable to read archive'); return JError::raiseWarning(100, $this->get('error.message')); } if (!$this->_getTarInfo($this->_data)) { return JError::raiseWarning(100, $this->get('error.message')); } for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) { $type = strtolower($this->_metadata[$i]['type']); if ($type == 'file' || $type == 'unix file') { $buffer = $this->_metadata[$i]['data']; $path = JPath::clean($destination . DS . $this->_metadata[$i]['name']); // Make sure the destination folder exists if (!JFolder::create(dirname($path))) { $this->set('error.message', 'Unable to create destination'); return JError::raiseWarning(100, $this->get('error.message')); } if (JFile::write($path, $buffer) === false) { $this->set('error.message', 'Unable to write entry'); return JError::raiseWarning(100, $this->get('error.message')); } } } return true; }
function language() { $app = JFactory::getApplication(); $code = JRequest::getString('code'); if (empty($code)) { $app->enqueueMessage(JText::_('Code not specified', true)); return; } $file = new stdClass(); $file->name = $code; $path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'language' . DS . $code . DS . $code . getBookingExtName() . '.ini'; $file->path = $path; jimport('joomla.filesystem.file'); $showLatest = true; $loadLatest = false; if (JFile::exists($path)) { $file->content = JFile::read($path); if (empty($file->content)) { $app->enqueueMessage('File not found : ' . $path); } } else { $loadLatest = true; $file->content = JFile::read(JPATH_COMPONENT_ADMINISTRATOR . DS . 'language' . 'en-GB' . DS . 'en-GB.' . getBookingExtName() . '.ini'); } $this->assignRef('file', $file); $tpl = "language"; return $tpl; }
/** * Check permissions on CSS file * and display the content via HTML_Joom_AdminCssEdit() * */ function displayCssEdit() { // error warning msg for CSS editor $msg = ''; jimport('joomla.filesystem.file'); $cssfile = $this->cssPath . 'joom_local.css.README'; $editExistingFile = file_exists($this->localCssFile); if ($editExistingFile) { $cssfile = $this->localCssFile; // test by trying to set permissions: Joom_Chmod($cssfile, 0766); if (!is_writable($cssfile)) { $msg = JText::_('JGA_CSS_WARNING_PERMS'); } } else { if (!is_writable($this->cssPath)) { $msg = JText::_('JGA_CSS_WARNING_PERMS'); } } if (!($content = JFile::read($cssfile))) { // output error, overwrite last error (this one is more important) $msg = JText::_('JGA_CSS_ERROR_READING') . $cssfile; } else { $content = htmlspecialchars($content, ENT_QUOTES, 'UTF-8'); } require_once JPATH_COMPONENT . DS . 'includes' . DS . 'html' . DS . 'admin.cssedit.html.php'; $htmladmincss = new HTML_Joom_AdminCssEdit($content, $this->localCssFile, $editExistingFile, $msg); }
/** * Fix Joomsef manifest files, to force upgrade method * */ protected function _fixManifest() { jimport('joomla.filesystem.file'); // fix original file $source = $this->parent->getPath('source'); $path = $source . DS . $this->_getElement() . '.xml'; $fileContent = JFile::read($path); if (!empty($fileContent)) { $fileContent = str_replace('type="sef_ext"', 'type="sef_ext" method="upgrade"', $fileContent); $defaults = array(); $remoteConfig = Sh404sefHelperUpdates::getRemoteConfig($forced = false); $remotes = empty($remoteConfig->config['joomsef_prefixes']) ? array() : $remoteConfig->config['joomsef_prefixes']; $prefixes = array_unique(array_merge($defaults, $remotes)); foreach ($prefixes as $prefix) { $fileContent = preg_replace('/function\\s*' . preg_quote($prefix) . '\\s*\\(\\s*\\)\\s*\\{/isU', 'function ' . $prefix . '() { return;', $fileContent); } // generic replace $defaultReplaces = array(); $remoteReplaces = empty($remoteConfig->config['joomsef_prefixes']) ? array() : $remoteConfig->config['joomsef_prefixes']; $replaces = array_unique(array_merge($defaultReplaces, $remoteReplaces)); foreach ($replaces as $replace) { $fileContent = preg_replace('/' . $replace['source'] . '/sU', $replace['target'], $fileContent); } // group="seo" is of no use for us, so leave it behind $written = JFile::write($path, $fileContent); } // fix in memory object, by killing it, thus prompting recreation $manifest =& $this->parent->getManifest(); $manifest = null; $manifest =& $this->parent->getManifest(); $this->manifest =& $manifest->document; }
function getItem() { global $mainframe; jimport('joomla.filesystem.path'); if (!$this->template) { return JError::raiseWarning(500, 'Template not specified'); } $tBaseDir = JPath::clean(JPATH_RSGALLERY2_SITE . '/templates'); if (!is_dir($tBaseDir . '/' . $this->template)) { return JError::raiseWarning(500, 'Template not found'); } $lang =& JFactory::getLanguage(); $lang->load('tpl_' . $this->template, JPATH_RSGALLERY2_SITE); $ini = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/params.ini'; $xml = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/templateDetails.xml'; $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $this->template); jimport('joomla.filesystem.file'); // Read the ini file if (JFile::exists($ini)) { $content = JFile::read($ini); } else { $content = null; } $params = new JParameter($content, $xml, 'template'); // Set FTP credentials, if given jimport('joomla.client.helper'); $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); $item = new stdClass(); $item->params = $params; $item->row = $row; $item->type = $this->_type; $item->template = $this->template; return $item; }
function __construct($options = array()) { static $expiredCacheCleaned; $this->profile_db = JFactory::getDBO(); $this->db = clone $this->profile_db; $this->_language = isset($options['language']) ? $options['language'] : 'en-GB'; $this->_lifetime = isset($options['lifetime']) ? $options['lifetime'] : 60; $this->_now = isset($options['now']) ? $options['now'] : time(); $config = JFactory::getConfig(); $this->_hash = $config->get('config.secret'); // if its not the first instance of the joomfish db cache then check if it should be cleaned and otherwise garbage collect if (!isset($expiredCacheCleaned)) { // check a file in the 'file' cache to check if we should remove all our db cache entries since cache manage doesn't handle anything other than file caches $conf = JFactory::getConfig(); $cachebase = $conf->get('cache_path', JPATH_ROOT . DS . 'cache'); $cachepath = $cachebase . DS . "falang-cache"; if (!JFolder::exists($cachepath)) { JFolder::create($cachepath); } $cachefile = $cachepath . DS . "cachetest.txt"; jimport("joomla.filesystem.file"); if (!JFile::exists($cachefile) || JFile::read($cachefile) != "valid") { // clean out the whole cache $this->cleanCache(); //sbou TODO uncomment write and solve problem JFile::write($cachefile, "valid"); } $this->gc(); } $expiredCacheCleaned = true; }
/** * * Disable JT3 infomode * * @return: Save setting to file params.ini */ public function disableInfoMode() { JSNFactory::localimport('libraries.joomlashine.database'); $template = JSNDatabase::getDefaultTemplate(); $client = JApplicationHelper::getClientInfo($template->client_id); $file = $client->path . '/templates/' . $template->element . '/params.ini'; $data = JFile::read($file); $data = explode("\n", $data); $params = array(); $needChange = false; foreach ($data as $val) { $spos = strpos($val, "="); $key = substr($val, 0, $spos); $value = substr($val, $spos + 1, strlen($val) - $spos); if ($key == 'infomode') { if ($value == '"1"') { $value = '"0"'; $needChange = true; } } $params[$key] = $value; } if ($needChange) { $data = array(); foreach ($params as $key => $val) { $data[] = $key . '=' . $val; } $data = implode("\n", $data); if (JFile::exists($file)) { @chmod($file, 0777); } JFile::write($file, $data); } }
/** * Entry point for CLI script * * @return void * * @since 3.0 */ public function doExecute() { ini_set("max_execution_time", 300); jimport('joomla.filesystem.archive'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $config = JFactory::getConfig(); $username = $config->get('user'); $password = $config->get('password'); $database = $config->get('db'); echo 'Exporting database... '; exec("mysqldump --user={$username} --password={$password} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$database} > " . JPATH_SITE . "/database-backup.sql"); $zipFilesArray = array(); $dirs = JFolder::folders(JPATH_SITE, '.', true, true); array_push($dirs, JPATH_SITE); echo 'Collecting files... '; foreach ($dirs as $dir) { $files = JFolder::files($dir, '.', false, true); foreach ($files as $file) { $data = JFile::read($file); $zipFilesArray[] = array('name' => str_replace(JPATH_SITE . '/', '', $file), 'data' => $data); } } $zip = JArchive::getAdapter('zip'); echo 'Creating zip... '; $archive = JPATH_SITE . '/backups/' . date('Ymd') . '-backup.zip'; $zip->create($archive, $zipFilesArray); echo 'Backup created ' . $archive . ' '; }
protected function getOptions() { $options = array(); if (defined('JMF_TPL_PATH')) { $path = JMF_TPL_PATH . DIRECTORY_SEPARATOR . 'tpl'; $files = JFolder::files($path, '.php'); if (is_array($files)) { $app = JFactory::getApplication(); $styleid = $app->input->get('id', null, 'int'); $file = JPath::clean(JMF_TPL_PATH . '/assets/style/assigns-' . $styleid . '.json'); if (!is_dir(dirname($file))) { JFolder::create(dirname($file)); } $assigns = new JRegistry(); // get current layout assigns settings if (JFile::exists($file)) { $assigns->loadString(JFile::read($file)); } else { $assigns->set(0, !empty($this->value) ? $this->value : 'default'); $data = $assigns->toString(); if (!@JFile::write($file, $data)) { $app->enqueueMessage(JText::sprintf('PLG_SYSTEM_JMFRAMEWORK_CAN_NOT_WRITE_TO_FILE', $file), 'error'); } } $arr_assigns = $assigns->toArray(); foreach ($files as $file) { $name = JFile::stripExt($file); $options[] = JHtml::_('select.option', $name, $name . ($name == $arr_assigns[0] ? ' [DEFAULT]' : '')); } } } return $options; }
/** * Main compiler code that compiles javascript files. * * @since 1.0 * @access public * @param bool Determines if the compiler should also minify the javascript codes * @return */ public function compile($section = 'site', $minify = false) { $compiler = $this->getCompiler(); // Create a master manifest containing all the scripts $manifest = new stdClass(); $manifest->adapter = 'EasyBlog'; $manifest->script = array(); // Get a list of all the js files in the "scripts" folder jimport('joomla.filesystem.folder'); // Read the dependencies file $dependenciesFile = EASYBLOG_SCRIPTS . '/dependencies.json'; $contents = JFile::read($dependenciesFile); $dependencies = json_decode($contents); // Nothing to compile so skip this altogether. if (!isset($dependencies->{$section})) { return; } // Set compiler options $options = array("static" => EASYBLOG_SCRIPTS . '/' . $section . '-' . $this->version . '.static', "optimized" => EASYBLOG_SCRIPTS . '/' . $section . '-' . $this->version . '.optimized', "minify" => $minify); $compiler->exclude = self::$exclusion; // Include everything in composer to speed up load time. // Doesn't matter if the static composer script is large. if ($section == 'composer') { $compiler->exclude = array(); } // Compiler scripts return $compiler->compile($dependencies->{$section}, $options); }
/** * Raw view display method, outputs one image * * @param string $tpl The name of the template file to parse * @return void * @since 1.5.5 */ public function display($tpl = null) { jimport('joomla.filesystem.file'); $type = JRequest::getWord('type', 'thumb'); $image = $this->get('Data'); $img = $this->_ambit->getImg($type . '_path', $image); if (!JFile::exists($img)) { $this->_mainframe->redirect(JRoute::_('index.php', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_IMAGE_NOT_EXIST'), 'error'); } $info = getimagesize($img); switch ($info[2]) { case 1: $mime = 'image/gif'; break; case 2: $mime = 'image/jpeg'; break; case 3: $mime = 'image/png'; break; default: JError::raiseError(404, JText::sprintf('COM_JOOMGALLERY_COMMON_MSG_MIME_NOT_ALLOWED', $info[2])); break; } // Set mime encoding $this->_doc->setMimeEncoding($mime); // Set header to specify the file name $disposition = 'inline'; JResponse::setHeader('Content-disposition', $disposition . '; filename=' . basename($img)); echo JFile::read($img); }
/** * @brief Valida si se debe instalar o no la librerai, esto sucede siempre y cuando * no encuentre libreria o la version sea menor a la que ya existe. * @return bool */ function isThereLibrary() { if (JFolder::exists(JPATH_SITE . DS . 'libraries' . DS . 'Amadeus')) { if (JFile::exists(JPATH_SITE . DS . 'libraries' . DS . 'Amadeus' . DS . 'Amadeus.php')) { require_once JPATH_SITE . DS . 'libraries' . DS . 'Amadeus' . DS . 'Amadeus.php'; $version = Amadeus::getVersion(); $mylib = JFile::read(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rotator' . DS . 'library' . DS . 'Amadeus' . DS . 'Amadeus.php'); preg_match('/[\'"](\\d+\\.\\d+\\.\\d+)[\'"]/', $mylib, $myversion); global $_version; $_version = '<h4>Requerimientos de Libreria:</h4>'; $_version .= "<span style='padding: 0 7px;'></span>Versión Actual : <b>" . $version . "</b><br />"; $_version .= "<span style='padding: 0 7px;'></span>Versión Requerida : <b>" . $myversion[1] . "</b>"; $myversion = explode('.', $myversion[1]); $version = explode('.', $version); if ($myversion[0] > $version[0]) { return true; } elseif ($myversion[0] == $version[0] && $myversion[1] > $version[1]) { return true; } elseif ($myversion[0] == $version[0] && $myversion[1] == $version[1] && $myversion[2] > $version[2]) { return true; } return false; } return true; } return true; }
public function _renderStatus() { $date = JFactory::getDate(); $jparam = new JConfig(); if (!JFile::exists(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'community.xml')) { return false; } if (JFile::exists($jparam->tmp_path . DS . 'jomsocialupdate.ini')) { $lastcheckdate = JFile::read($jparam->tmp_path . DS . 'jomsocialupdate.ini'); } else { $lastcheckdate = $date->toFormat(); } JFile::write($jparam->tmp_path . DS . 'jomsocialupdate.ini', $lastcheckdate); $dayInterval = 1; // days $currentdate = $date->toFormat(); $checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24; // Load language $lang = JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT . DS . 'administrator'); $button = $this->_getButton($checkVersion); $html = JResponse::getBody(); $html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html); // Load AJAX library for the back end. $jax = new JAX(rtrim(JURI::root(), '/') . '/plugins/system/pc_includes'); $jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php'); $jaxScript = $jax->getScript(); JResponse::setBody($html . $jaxScript); }
public function getInput() { $this->_templates = JPATH_ROOT . DS . 'modules' . DS . 'mod_rokfeaturetable' . DS . 'templates'; $this->_jtemplate = $this->_getCurrentTemplatePath(); $output = ""; jimport('joomla.filesystem.file'); if (JFolder::exists($this->_templates)) { $files = JFolder::files($this->_templates, "\\.txt", true, true); if (JFolder::exists($this->_jtemplate)) { $jfiles = JFolder::files($this->_jtemplate, "\\.txt", true, true); if (count($jfiles)) { $this->merge($files, $jfiles); } } if (count($files)) { $output = "<select id='templates'>\n"; $output .= "<option value='_select_' class='disabled' selected='selected'>Select a Template</option>"; foreach ($files as $file) { $title = JFile::stripExt(JFile::getName($file)); $title = str_replace("-", " ", str_replace("_", " ", $title)); $title = ucwords($title); $output .= "<option value='" . JFile::read($file) . "'>" . $title . "</option>"; } $output .= "</select>\n"; $output .= "<span id='import-button' class='action-import'><span>import</span></span>\n"; } } else { $output = "Templates folder was not found."; } return $output; }
/** * Checks an extension with a given MD5 checksum file. * * @param string $path Path to md5 file * @param array $extensionPaths Indexed array: First folder in md5 file path as key - extension path as value * * @return array Array of errors */ function checkMD5File($path, $extensionPaths) { jimport('joomla.filesystem.file'); $lines = explode("\n", JFile::read($path)); $errors = array(); $errors[0] = 0; //counter.. foreach ($lines as $line) { if (!trim($line)) { continue; } list($md5, $file) = explode(' ', $line); $parts = explode(DS, $file); if (!array_key_exists($parts[0], $extensionPaths)) { continue; } $path = $extensionPaths[$parts[0]] . DS . substr($file, strlen($parts[0]) + 1); echo JDEBUG ? $path . '...' : ''; $errors[0]++; if (!JFile::exists($path)) { $errors[] = sprintf(jgettext('File not found: %s'), $path); echo JDEBUG ? 'not found<br />' : ''; continue; } if (md5_file($path) != $md5) { $errors[] = sprintf(jgettext('MD5 check failed on file: %s'), $path); echo JDEBUG ? 'md5 check failed<br />' : ''; continue; } echo JDEBUG ? 'OK<br />' : ''; } //foreach return $errors; }
function fetchElement($name, $value, &$node, $control_name) { $db =& JFactory::getDBO(); $db->setQuery($node->attributes('sql')); $name = $node->attributes('name'); if (JRequest::getVar("option") == "com_templates" && JRequest::getVar("task") == "edit") { $sql = "select template from #__templates_menu where client_id=0"; $db->setQuery($sql); $db->query(); $template = $db->loadResult(); $template_path = JPATH_SITE . DS . "templates" . DS . $template . DS . "params.ini"; $template_params = new JParameter(JFile::read($template_path)); $duration = $template_params->get('s5_duration') == "" ? "500" : $template_params->get('s5_duration'); $hide_delay = $template_params->get('s5_hide_delay') == "" ? "500" : $template_params->get('s5_hide_delay'); $opacity = $template_params->get('s5_opacity') == "" ? "100" : $template_params->get('s5_opacity'); $maxdepth = $template_params->get('s5_maxdepth') == "" ? "10" : $template_params->get('s5_maxdepth'); if ($name == "s5_duration") { return '<input type="text" class="text_area" value="' . $duration . '" id="paramss5_duration" name="params[s5_duration]">'; } elseif ($name == "s5_hide_delay") { return '<input type="text" class="text_area" value="' . $hide_delay . '" id="paramss5_hide_delay" name="params[s5_hide_delay]">'; } elseif ($name == "s5_opacity") { return '<input type="text" class="text_area" value="' . $opacity . '" id="paramss5_opacity" name="params[s5_opacity]">'; } elseif ($name == "s5_maxdepth") { return '<input type="text" class="text_area" value="' . $maxdepth . '" id="paramss5_maxdepth" name="params[s5_maxdepth]">'; } } }
function __construct() { $this->aclname = $className = get_class($this); //Load ACL Params, if not already loaded if (!$this->aclparams) { $aclxmlpath = dirname(__FILE__) . DS . strtolower($className) . DS . strtolower($className) . '.xml'; if (JFile::exists($aclxmlpath)) { $this->aclparams = new XiptParameter('', $aclxmlpath); } else { $this->aclparams = new XiptParameter('', ''); } } //Load Core Params if defined for current ACL, if not already loaded if (!$this->coreparams) { $corexmlpath = dirname(__FILE__) . DS . strtolower($className) . DS . 'coreparams.xml'; if (JFile::exists($corexmlpath)) { $corexmlpath = dirname(__FILE__) . DS . strtolower($className) . DS . 'coreparams.xml'; } else { $corexmlpath = dirname(__FILE__) . DS . 'coreparams.xml'; } } //load core params $coreinipath = dirname(__FILE__) . DS . 'coreparams.ini'; $iniData = JFile::read($coreinipath); XiptError::assert(JFile::exists($corexmlpath), $corexmlpath . XiptText::_("FILE_DOES_NOT_EXIST"), XiptError::ERROR); XiptError::assert(JFile::exists($coreinipath), $coreinipath . XiptText::_("FILE_DOES_NOT_EXIST"), XiptError::ERROR); $this->coreparams = new XiptParameter($iniData, $corexmlpath); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected * @return void */ protected function setUp() { parent::setUp(); $_SERVER['HTTP_HOST'] = 'mydomain.com'; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0'; $_SERVER['REQUEST_URI'] = '/index.php'; $_SERVER['SCRIPT_NAME'] = '/index.php'; $this->options = new JRegistry; $this->http = $this->getMock('JHttp', array('head', 'get', 'delete', 'trace', 'post', 'put', 'patch'), array($this->options)); $this->input = new JInput; $this->oauth = new JOAuth2Client($this->options, $this->http, $this->input); $this->auth = new JGoogleAuthOauth2($this->options, $this->oauth); $this->xml = new SimpleXMLElement(JFile::read(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'photo.txt')); $this->object = new JGoogleDataPicasaPhoto($this->xml, $this->options, $this->auth); $this->object->setOption('clientid', '01234567891011.apps.googleusercontent.com'); $this->object->setOption('clientsecret', 'jeDs8rKw_jDJW8MMf-ff8ejs'); $this->object->setOption('redirecturi', 'http://localhost/oauth'); $token['access_token'] = 'accessvalue'; $token['refresh_token'] = 'refreshvalue'; $token['created'] = time() - 1800; $token['expires_in'] = 3600; $this->oauth->setToken($token); }
public function check($file) { // init vars $status = array('state' => true, 'extensions' => array()); $groups = $this->app->path->path($file); // get the content from file if ($groups && ($groups = json_decode(JFile::read($groups)))) { // iterate over the groups foreach ($groups as $group => $dependencies) { foreach ($dependencies as $name => $dependency) { if ($group == 'plugins') { // get plugin $folder = isset($dependency->folder) ? $dependency->folder : 'system'; $plugin = JPluginHelper::getPlugin($folder, strtolower($name)); // if plugin disable, skip it if (empty($plugin)) { continue; } } $version = $dependency->version; $manifest = $this->app->path->path('root:' . $dependency->manifest); if ($version && is_file($manifest) && is_readable($manifest) && ($xml = simplexml_load_file($manifest))) { // check if the extension is outdated if (version_compare($version, (string) $xml->version, 'g')) { $status['state'] = false; $status['extensions'][] = array('dependency' => $dependency, 'installed' => $xml); } } } } } return $status; }
private function _renderStatus() { $date = JFactory::getDate(); $jparam = new JConfig(); if (!JFile::exists(JPATH_ROOT . '/administrator/components/com_community/community.xml')) { return false; } if (JFile::exists(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini')) { $lastcheckdate = JFile::read(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini'); } else { $lastcheckdate = $date->format('Y-m-d H:i:s'); } JFile::write(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini', $lastcheckdate); $dayInterval = 1; // days $currentdate = $date->format('Y-m-d H:i:s'); $checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24; // Load language $lang = JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT . '/administrator'); $button = $this->_getButton($checkVersion); $html = JResponse::getBody(); $html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html); // Load AJAX library for the back end. $jaxScript = ''; $noHTML = JRequest::getInt('no_html', 0); $format = JRequest::getWord('format', 'html'); if (!$noHTML && $format == 'html') { require_once AZRUL_SYSTEM_PATH . '/pc_includes/ajax.php'; $jax = new JAX(AZRUL_SYSTEM_LIVE . '/pc_includes'); $jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php'); $jaxScript = $jax->getScript(); } JResponse::setBody($html . $jaxScript); }
/** * Retrieves a list of countries from the manifest file. * * @since 1.0 * @access public * @return Array An array of countries. * * @author Jason Rey <*****@*****.**> */ public static function getCountries($source = 'regions') { static $countries = array(); if (!isset($countries[$source])) { $data = new stdClass(); if ($source === 'file') { $file = JPATH_ADMINISTRATOR . '/components/com_easysocial/defaults/countries.json'; $contents = JFile::read($file); $json = FD::json(); $data = $json->decode($contents); $data = (array) $data; // Sort by alphabet asort($data); $data = (object) $data; } if ($source === 'regions') { $countries = FD::model('Regions')->getRegions(array('type' => SOCIAL_REGION_TYPE_COUNTRY, 'state' => SOCIAL_STATE_PUBLISHED, 'ordering' => 'ordering')); foreach ($countries as $country) { $data->{$country->code} = $country->name; } } $countries[$source] = $data; } return $countries[$source]; }
/** * Class constructor * * @param object $template Current template instance */ public function __construct($template = null) { // merge the base theme information $this->maxgrid = T3_BASE_MAX_GRID; $this->widthprefix = T3_BASE_WIDTH_PREFIX; $this->nonrspprefix = T3_BASE_NONRSP_WIDTH_PREFIX; $this->spancls = T3_BASE_WIDTH_REGEX; $this->responcls = T3_BASE_RSP_IN_CLASS; $this->rowfluidcls = T3_BASE_ROW_FLUID_PREFIX; $this->defdv = T3_BASE_DEFAULT_DEVICE; $this->devices = json_decode(T3_BASE_DEVICES, true); $this->maxcol = json_decode(T3_BASE_DV_MAXCOL, true); $this->minspan = json_decode(T3_BASE_DV_MINWIDTH, true); $this->prefixes = json_decode(T3_BASE_DV_PREFIX, true); // layout settings $this->_layoutsettings = new JRegistry(); if ($template) { $this->_tpl = $template; $this->_extend(array($template)); // merge layout setting $layout = JFactory::getApplication()->input->getCmd('t3layout', ''); if (empty($layout)) { $layout = $template->params->get('mainlayout', 'default'); } $fconfig = T3Path::getPath('etc/layout/' . $layout . '.ini'); if (is_file($fconfig)) { jimport('joomla.filesystem.file'); $this->_layoutsettings->loadString(JFile::read($fconfig), 'INI', array('processSections' => true)); } } JDispatcher::getInstance()->trigger('onT3TplInit', array($this)); }
/** * return the javascript to create an instance of the class defined in formJavascriptClass * @param object parameters * @param object table model * @param array [0] => string table's form id to contain plugin * @return bool */ function loadJavascriptInstance($params, $model, $args) { $form_id = $args[0]; $js = trim($params->get('table_js_code')); if ($js !== '') { FabrikHelperHTML::addScriptDeclaration($js); } $this->jsInstance = ''; //script $script = $params->get('table_js_file'); if ($script == '-1') { return; } $className = substr($script, 0, strlen($script) - 3); $document =& JFactory::getDocument(); $id =& $model->getTable()->id; $container = 'oTable'; if (JRequest::getVar('tmpl') != 'component') { FabrikHelperHTML::script($script, 'components/com_fabrik/plugins/table/tablejs/scripts/'); } else { // included scripts in the head don't work in mocha window // read in the class and insert it into the body as an inline script $class = JFile::read(JPATH_BASE . "/components/com_fabrik/plugins/table/tablejs/scripts/{$script}"); // $$$ rob dont want/need to delay the loading of the class //FabrikHelperHTML::addScriptDeclaration($class); $document =& JFactory::getDocument(); $document->addScriptDeclaration($class); } $this->jsInstance = "new {$className}({$container}{$id})"; return true; }
/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter repeat group counter * * @return string */ public function elementJavascript($repeatCounter) { if (!$this->isEditable()) { return; } FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/colourpicker/images/', 'image', 'form', false); $params = $this->getParams(); $element = $this->getElement(); $id = $this->getHTMLId($repeatCounter); $data = $this->_form->_data; $value = $this->getValue($data, $repeatCounter); $vars = explode(",", $value); $vars = array_pad($vars, 3, 0); $opts = $this->getElementJSOptions($repeatCounter); $c = new stdClass(); // 14/06/2011 changed over to color param object from ind colour settings $c->red = (int) $vars[0]; $c->green = (int) $vars[1]; $c->blue = (int) $vars[2]; $opts->colour = $c; $swatch = $params->get('colourpicker-swatch', 'default.js'); $swatchFile = JPATH_SITE . '/plugins/fabrik_element/colourpicker/swatches/' . $swatch; $opts->swatch = json_decode(JFile::read($swatchFile)); $opts->closeImage = FabrikHelperHTML::image("close.gif", 'form', @$this->tmpl, array(), true); $opts->handleImage = FabrikHelperHTML::image("handle.gif", 'form', @$this->tmpl, array(), true); $opts->trackImage = FabrikHelperHTML::image("track.gif", 'form', @$this->tmpl, array(), true); $opts = json_encode($opts); return "new ColourPicker('{$id}', {$opts})"; }
/** * Constructor. * * @param string $element Element name * @param string $scope Scope name * @param string $basePath The base path */ public function __construct($element, $scope, $basePath = '') { $this->_element = $element; $this->_scope = $scope; $this->basePath = $basePath; parent::__construct($this->group, $this->name, $element, $scope); //-- Read the files in /options folder $options = JFolder::files($this->basePath . DS . 'tmpl' . DS . 'options'); foreach ($options as $fName) { $fContents = JFile::read($this->basePath . DS . 'tmpl' . DS . 'options' . DS . $fName); $key = JFile::stripExt($fName); $this->fieldsOptions[$key] = $fContents; } //foreach $this->keys['##ECR_OPTIONS##'] = '__ECR_KEY__'; /* //# $this->keys['##ECR_VIEW1_TMPL1_TDS##'] = '##ECR_KEY##'; // $this->patterns['##ECR_VIEW1_TMPL1_THS##'] = ' <th>'.NL // ." <?php echo JHTML::_('grid.sort', '##ECR_KEY##', // * '##ECR_KEY##', \$this->lists['order_Dir'], \$this->lists['order']);?>".NL // .' </th>'.NL; // $this->patterns['##ECR_VIEW1_TMPL1_TDS##'] = ' <td>'.NL // .' <php echo $row->##ECR_KEY##; ?>'.NL // .' </td>'.NL; * */ }
function language() { $this->setLayout('default'); $code = JRequest::getString('code'); if (empty($code)) { acymailing::display('Code not specified', 'error'); return; } $file = null; $file->name = $code; $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini'; $file->path = $path; jimport('joomla.filesystem.file'); $showLatest = true; $loadLatest = false; if (JFile::exists($path)) { $file->content = JFile::read($path); if (empty($file->content)) { acymailing::display('File not found : ' . $path, 'error'); } } else { $loadLatest = true; acymailing::display(JText::_('LOAD_ENGLISH_1') . '<br/>' . JText::_('LOAD_ENGLISH_2') . '<br/>' . JText::_('LOAD_ENGLISH_3'), 'info'); $file->content = JFile::read(JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'en-GB' . DS . 'en-GB.com_acymailing.ini'); } if ($loadLatest or JRequest::getString('task') == 'latest') { $doc =& JFactory::getDocument(); $doc->addScript(ACYMAILING_UPDATEURL . 'languageload&code=' . JRequest::getString('code')); $showLatest = false; } elseif (JRequest::getString('task') == 'save') { $showLatest = false; } $this->assignRef('showLatest', $showLatest); $this->assignRef('file', $file); }
function _fileData() { $file = JRequest::getVar('file', '', 'files', 'array'); // Checks if (strlen($file['name']) < 5) { $this->setError(JText::_('INVALID_CSV')); return false; } jimport('joomla.filesystem.file'); $format = strtolower(JFile::getExt($file['name'])); if ($format != 'csv') { $this->setError(JText::_('INVALID_CSV')); return false; } // See administrator >> components >> com_media >> helpers >> media.php $xss = JFile::read($file['tmp_name'], false, 256); $tags = array('abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--'); foreach ($tags as $t) { if (stristr($xss, '<' . $t . ' ') || stristr($xss, '<' . $t . '>')) { $this->setError(JText::_('INVALID_CSV')); return false; } } return JFile::read($file['tmp_name'], false); }
/** * Load entity from ORM table * * @access public * @param int $id * @return Object& */ public function loadEntity($id) { try { // Load htaccess file, finding it $targetHtaccess = null; // Try to check for an active htaccess file if (JFile::exists(JPATH_ROOT . '/.htaccess')) { $targetHtaccess = JPATH_ROOT . '/.htaccess'; } elseif (JFile::exists(JPATH_ROOT . '/htaccess.txt')) { // Fallback on txt dummy version $targetHtaccess = JPATH_ROOT . '/htaccess.txt'; $this->setState('htaccess_version', 'textual'); } else { throw new JMapException(JText::_('COM_JMAP_HTACCESS_NOTFOUND'), 'error'); } // htaccess found! if ($targetHtaccess !== false) { // If file permissions ko if (!($htaccessContents = JFile::read($targetHtaccess))) { throw new JMapException(JText::_('COM_JMAP_ERROR_READING_HTACCESS'), 'error'); } } } catch (JMapException $e) { $this->setError($e); return false; } catch (Exception $e) { $jmapException = new JMapException($e->getMessage(), 'error'); $this->setError($jmapException); return false; } return $htaccessContents; }
/** * Simple catching functionn * * @param string $file * @param string $url * @param array $args * @param int $time default is 900/60 = 15 min * @param mixed $onError string function or array(object, method ) * @return string */ private function Cache($file, $time = 900, $onerror = '') { // check joomla cache dir writable $dir = basename(dirname(__FILE__)); if (is_writable(JPATH_CACHE)) { // check cache dir or create cache dir if (!file_exists(JPATH_CACHE . '/' . $dir)) { mkdir(JPATH_CACHE . '/' . $dir . '/', 0755); } $cache_file = JPATH_CACHE . '/' . $dir . '/' . $this->moduleID . '-' . $file; // check cache file, if not then write cache file if (!file_exists($cache_file)) { $data = $this->getData(); JFile::write($cache_file, $data); } elseif (filesize($cache_file) == 0 || filemtime($cache_file) + (int) $time < time()) { $data = $this->getData(); JFile::write($cache_file, $data); } $data = JFile::read($cache_file); $params['file'] = $cache_file; $params['data'] = $data; if (!empty($onerror)) { call_user_func($onerror, $params); } return $data; } else { return $this->getData(); } }