public function compileLess($inputFile, $outputFile) { if (!class_exists('lessc')) { require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php'; } // Load the cache. $cacheDir = JPATH_CACHE . '/kunena'; if (!is_dir($cacheDir)) { KunenaFolder::create($cacheDir); } $cacheFile = "{$cacheDir}/kunena.bootstrap.{$inputFile}.cache"; if (is_file($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = KPATH_MEDIA . '/less/bootstrap/' . $inputFile; } $outputFile = KPATH_MEDIA . '/css/joomla25/' . $outputFile; $less = new lessc(); //$less->setVariables($this->style_variables); $newCache = $less->cachedCompile($cache); if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) { $cache = serialize($newCache); KunenaFile::write($cacheFile, $cache); KunenaFile::write($outputFile, $newCache['compiled']); } }
/** * Create index.html file into the given folder, if it doesn't exist. * * @param $folder */ static function createIndex($folder) { // Make sure we have an index.html file in the current folder if (!KunenaFile::exists($folder.'/index.html')) { $contents = '<html><body></body></html>'; KunenaFile::write($folder.'/index.html', $contents); } }
/** * Method to determine if script owns the path. * * @param string $path Path to check ownership. * * @return boolean True if the php script owns the path passed. */ public static function isOwner($path) { if (!self::$owner) { $dir = JFactory::getConfig()->get('tmp_path'); $tmp = 'jj'.md5(mt_rand()); $test = $dir . '/' . $tmp; // Create the test file $content = 'test'; $success = KunenaFile::write($test, $content, false); if (!$success) { return false; } self::$owner = fileowner($test); // Delete the test file KunenaFile::delete($test); } // Test ownership return (self::$owner == fileowner($path)); }
function compileLess($inputFile, $outputFile) { if (!class_exists('lessc')) { require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php'; } // Load the cache. $cacheDir = JPATH_CACHE . '/kunena'; if (!is_dir($cacheDir)) { KunenaFolder::create($cacheDir); } $cacheFile = "{$cacheDir}/kunena.{$this->name}.{$inputFile}.cache"; if (is_file($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = JPATH_SITE . '/' . $this->getFile($inputFile, false, 'less'); } $outputDir = KPATH_MEDIA . "/cache/{$this->name}/css"; if (!is_dir($outputDir)) { KunenaFolder::create($outputDir); } $outputFile = "{$outputDir}/{$outputFile}"; $less = new lessc(); $class = $this; $less->registerFunction('url', function ($arg) use($class) { list($type, $q, $values) = $arg; $value = reset($values); return "url({$q}{$class->getFile($value, true, 'media', 'media/kunena')}{$q})"; }); $less->setVariables($this->style_variables); $newCache = $less->cachedCompile($cache); if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) { $cache = serialize($newCache); KunenaFile::write($cacheFile, $cache); KunenaFile::write($outputFile, $newCache['compiled']); } }
/** * Method to save param.ini file on filesystem. * * @param string $template The name of the template. * * * @since 3.0.0 */ protected function _saveParamFile($template) { $params = $this->app->input->get('jform', array(), 'post', 'array'); // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); $ftp = JClientHelper::getCredentials('ftp'); $file = KPATH_SITE . '/template/' . $template . '/params.ini'; if (count($params)) { $registry = new JRegistry(); $registry->loadArray($params); $txt = $registry->toString('INI'); $return = KunenaFile::write($file, $txt); if (!$return) { $this->app->enqueueMessage(JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_OPERATION_FAILED') . ': ' . JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_FAILED_WRITE_FILE', $file)); $this->app->redirect(KunenaRoute::_($this->baseurl, false)); } } }