Example #1
1
 /**
  * Downloads a package
  *
  * @param string $url    URL of file to download
  * @param string $target Download target filename [optional]
  *
  * @return mixed Path to downloaded package or boolean false on failure
  *
  * @since   11.1
  */
 public static function downloadPackage($url, $target = false)
 {
     $config = JFactory::getConfig();
     // Capture PHP errors
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // Set user agent
     $version = new JVersion();
     ini_set('user_agent', $version->getUserAgent('Installer'));
     $http = JHttpFactory::getHttp();
     $response = $http->get($url);
     if (200 != $response->code) {
         JLog::add(JText::_('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT'), JLog::WARNING, 'jerror');
         return false;
     }
     if ($response->headers['wrapper_data']['Content-Disposition']) {
         $contentfilename = explode("\"", $response->headers['wrapper_data']['Content-Disposition']);
         $target = $contentfilename[1];
     }
     // Set the target path if not given
     if (!$target) {
         $target = $config->get('tmp_path') . '/' . self::getFilenameFromURL($url);
     } else {
         $target = $config->get('tmp_path') . '/' . basename($target);
     }
     // Write buffer to file
     JFile::write($target, $response->body);
     // Restore error tracking to what it was before
     ini_set('track_errors', $track_errors);
     // Bump the max execution time because not using built in php zip libs are slow
     @set_time_limit(ini_get('max_execution_time'));
     // Return the name of the downloaded package
     return basename($target);
 }
Example #2
0
 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);
 }
Example #3
0
    /**
     * Applies the back-end protection, creating an appropriate .htaccess and
     * .htpasswd file in the administrator directory.
     *
     * @return bool
     */
    public function protect()
    {
        JLoader::import('joomla.filesystem.file');
        $cryptpw = $this->apacheEncryptPassword();
        $htpasswd = $this->username . ':' . $cryptpw . "\n";
        $status = JFile::write(JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . '.htpasswd', $htpasswd);
        if (!$status) {
            return false;
        }
        $path = rtrim(JPATH_ADMINISTRATOR, '/\\') . DIRECTORY_SEPARATOR;
        $htaccess = <<<ENDHTACCESS
AuthUserFile "{$path}.htpasswd"
AuthName "Restricted Area"
AuthType Basic
require valid-user

RewriteEngine On
RewriteRule \\.htpasswd\$ - [F,L]
ENDHTACCESS;
        $status = JFile::write(JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . '.htaccess', $htaccess);
        if (!$status || !is_file($path . '/.htpasswd')) {
            JFile::delete(JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . '.htpasswd');
            return false;
        }
        return true;
    }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
 /**
  * Uninstall Kunena, run from Joomla installer.
  */
 public function uninstall()
 {
     // Put back file that was removed during installation.
     $contents = '';
     JFile::write(KPATH_ADMIN . '/install.php', $contents);
     // Uninstall all plugins.
     $this->uninstallPlugin('kunena', 'alphauserpoints');
     $this->uninstallPlugin('kunena', 'community');
     $this->uninstallPlugin('kunena', 'comprofiler');
     $this->uninstallPlugin('kunena', 'gravatar');
     $this->uninstallPlugin('kunena', 'joomla');
     $this->uninstallPlugin('kunena', 'kunena');
     $this->uninstallPlugin('kunena', 'uddeim');
     $this->uninstallPlugin('finder', 'kunena');
     // Uninstall menu module.
     $this->uninstallModule('mod_kunenamenu');
     // Remove all Kunena related menu items, including aliases
     if (class_exists('KunenaMenuFix')) {
         $items = KunenaMenuFix::getAll();
         foreach ($items as $item) {
             KunenaMenuFix::delete($item->id);
         }
     }
     $this->deleteMenu();
     return true;
 }
Example #7
0
 /**
  * Constructor
  *
  * @param 	object 	An optional KConfig object with configuration options
  */
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     foreach (array('enabled' => true, 'levels' => 3, 'limit' => 0, 'offset' => 0, 'sort' => 'path_sort_ordering') as $key => $val) {
         $this->_request->{$key} = $val;
     }
     //Set model recurse
     //if(KRequest::method() == 'GET') KRequest::set('get.recurse', true);
     //Set other model states
     //KRequest::set('get.enabled', true);
     $this->registerCallback(array('before.read', 'before.browse'), array($this, 'setOrdering'));
     if ($this->isDispatched()) {
         $this->registerCallback('after.read', array($this, 'setCanonical'));
     }
     $cache = JPATH_ROOT . '/cache/com_' . $this->getIdentifier()->package . '/maintenance.txt';
     if (!JFile::exists($cache)) {
         if (KFactory::get('admin::com.ninjaboard.controller.maintenance')->topics() && KFactory::get('admin::com.ninjaboard.controller.maintenance')->forums()) {
             JFile::write($cache, date('r'));
         }
     }
     $user = KFactory::get('lib.joomla.user');
     // User specific maintenance
     if (!$user->guest) {
         $cache = JPATH_ROOT . '/cache/com_' . $this->getIdentifier()->package . '/maintenance.' . $user->id . '.txt';
         if (!JFile::exists($cache)) {
             if (KFactory::get('admin::com.ninjaboard.controller.maintenance')->logtopicreads()) {
                 JFile::write($cache, date('r'));
             }
         }
     }
 }
Example #8
0
 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;
 }
Example #9
0
 public function map(&$file, $index, &$contents)
 {
     // Store the file to a temporary location
     $file['tmp_name'] = $this->tmp . '/' . md5($file['name']);
     JFile::write($file['tmp_name'], $file['data']);
     // Load up media manager now
     $mm = EB::mediamanager();
     $result = $mm->upload($file, 'user:'******'name'];
     $url = $this->absoluteUrl . '/' . $file['name'];
     // Get the properties from media manager result
     if (is_object($result) && property_exists($result, 'title')) {
         $title = $result->title;
         $url = $result->url;
     }
     // Once the attachment is already uploaded, we want to delete the temporary file now
     JFile::delete($file['tmp_name']);
     // Check if a file id is provided in the email
     if (isset($file['id']) && !empty($file['id'])) {
         $fileId = $file['id'];
         $fileId = str_replace('<', '', $fileId);
         $fileId = str_replace('>', '', $fileId);
         $patterns = array('/<div><img[^>]*src="[A-Za-z0-9:^>]*' . $fileId . '"[^>]*\\/><\\/div>/si', '/<img[^>]*src="[A-Za-z0-9:^>]*' . $fileId . '"[^>]*\\/>/si');
         $replace = array('', '');
         $contents = preg_replace($patterns, $replace, $contents);
     }
     // Now we need to insert the pdf links into the content
     $template = EB::template();
     $template->set('title', $title);
     $template->set('url', $url);
     $output = $template->output('site/mailpublishing/template.pdf');
     $contents .= $output;
 }
Example #10
0
 /**
  * Function that will merge & minify the provided files
  *
  * @param   array   $files      - array with relative paths to js files
  * @param   string  $cachePath  - where to save the new merged & minified file
  *
  * @return string
  */
 public static function shrink(array $files, $cachePath)
 {
     $times = array();
     $md5 = md5(json_encode($files));
     $url = $cachePath . '/' . $md5 . '.min.js';
     $minFile = JPATH_ROOT . '/' . $url;
     // Lets read the times of the files we need to merge
     foreach ($files as $file) {
         if (file_exists(JPATH_ROOT . '/' . $file)) {
             $times[] = filemtime(JPATH_ROOT . '/' . $file);
         }
     }
     // If the minFile doesn't exist or the minFile time is older than any of the times, let's do our job!
     if (!file_exists($minFile) || max($times) > filemtime($minFile)) {
         $js = '';
         foreach ($files as $file) {
             if (file_exists(JPATH_ROOT . '/' . $file)) {
                 $js[] = file_get_contents(JPATH_ROOT . '/' . $file);
             }
         }
         // Do the actual minifying
         $minJs = CompojoomMinifier::minify(implode($js));
         JFile::write($minFile, $minJs);
     }
     return $url;
 }
 /**
  *
  * 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);
     }
 }
 /**
  * Method to run after installing the component
  */
 function postflight($type, $parent)
 {
     //Restore the modified language strings by merging to language files
     $registry = new JRegistry();
     foreach (self::$languageFiles as $languageFile) {
         $backupFile = JPATH_ROOT . '/language/en-GB/bak.' . $languageFile;
         $currentFile = JPATH_ROOT . '/language/en-GB/' . $languageFile;
         if (JFile::exists($currentFile) && JFile::exists($backupFile)) {
             $registry->loadFile($currentFile, 'INI');
             $currentItems = $registry->toArray();
             $registry->loadFile($backupFile, 'INI');
             $backupItems = $registry->toArray();
             $items = array_merge($currentItems, $backupItems);
             $content = "";
             foreach ($items as $key => $value) {
                 $content .= "{$key}=\"{$value}\"\n";
             }
             JFile::write($currentFile, $content);
         }
     }
     // Restore custom modified css file
     if (JFile::exists(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css')) {
         JFile::copy(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css', JPATH_ROOT . '/components/com_osmembership/assets/css/custom.css');
         JFile::delete(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css');
     }
 }
function migrateSettings()
{
    $db =& JFactory::getDBO();
    $config =& JFactory::getConfig();
    $tables = $db->getTableList();
    if (in_array($config->getValue('config.dbprefix') . 'migration_configuration', $tables)) {
        $db->setQuery("SELECT `key`,`value` FROM #__migration_configuration");
        $results = $db->loadAssocList();
        if (!is_array($results)) {
            echo $db->getErrorMsg();
            return;
        }
        $cfg = JFactory::getConfig();
        foreach ($results as $result) {
            $cfg->setValue('config.' . $result['key'], $result['value']);
        }
        echo '<p>' . JText::_('Updating your configuration file') . '</p>';
        //echo '<pre>'.print_r(htmlspecialchars($cfg->toString('PHP', 'config', array('class' => 'JConfig'))),1).'</pre>';
        jimport('joomla.filesystem.file');
        $fname = JPATH_CONFIGURATION . DS . 'configuration.php';
        if (JFile::write($fname, $cfg->toString('PHP', 'config', array('class' => 'JConfig')))) {
            $msg = JText::_('The Configuration Details have been updated');
        } else {
            $msg = JText::_('ERRORCONFIGFILE');
        }
    } else {
        $msg = JText::_('Error') . ': ' . JText::_('Migration Configuration table not found') . '. ' . JText::_('Was this site migrated with Migrator RC7 or greater') . '?';
    }
    echo '<p>' . $msg . '</p>';
    //echo '<p><a href="index.php?option=com_migrationassistant">'. JText::_('Home') .'</a></p>';
}
Example #14
0
    /**
     * @global gantry used to access the core Gantry class
     * @param  $name
     * @param  $value
     * @param  $node
     * @param  $control_name
     * @return void
     */
	function fetchElement($name, $value, &$node, $control_name)
	{
		global $gantry;
		
        if ($gantry->get('file-inline-js-enabled') && isset($gantry->document->_script)) {
            jimport('joomla.filesystem.file');
            $filename = JPATH_ADMINISTRATOR.DS.'tmp'.DS.'inline-javascript.js';
			
			$scripts = $gantry->document->_script;
			if (is_array($scripts)){
				$buffer = "";
				foreach($scripts as $jsLine) {
					if (is_array($jsLine)) {
						foreach($jsLine as $line) $buffer .= $line;
					} else {
						$buffer .= $jsLine;
			 		}
				}
				JFile::write($filename, $buffer);
			} else {
				JFile::write($filename, $gantry->document->_script);
			}
            

            // add reference to static file
            $gantry->document->addScript('tmp/inline-javascript.js');

            // clear out the inline script from document;
            $gantry->document->_script = '';

        }

	}
Example #15
0
 public function createBackUpFileForMigrate()
 {
     $session = JFactory::getSession();
     $preVersion = (double) str_replace('.', '', $session->get('preversion', null, 'jsnimageshow'));
     $version400 = (double) str_replace('.', '', '4.0.0');
     //$preVersion = 313;
     if (!$preVersion) {
         return;
     }
     if ($preVersion < $version400) {
         $objJSNISMaintenance = JSNISFactory::getObj('classes.jsn_is_maintenance313', null, 'database');
         $xmlString = $objJSNISMaintenance->renderXMLData(true, true);
     } else {
         if ($preVersion >= $version400) {
             $objJSNISData = JSNISFactory::getObj('classes.jsn_is_data');
             $xmlString = $objJSNISData->executeBackup(true, true)->asXML();
         }
     }
     $fileBackupName = 'jsn_imageshow_backup_db.xml';
     $fileZipName = 'jsn_is_backup_for_migrate_' . $preVersion . '_' . date('YmdHis') . '.zip';
     if (JFile::write(JPATH_ROOT . DS . 'tmp' . DS . $fileBackupName, $xmlString)) {
         $config = JPATH_ROOT . DS . 'tmp' . DS . $fileZipName;
         $zip = JSNISFactory::getObj('classes.jsn_is_archive', 'JSNISZIPFile', $config);
         $zip->setOptions(array('inmemory' => 1, 'recurse' => 0, 'storepaths' => 0));
         $zip->addFiles(JPATH_ROOT . DS . 'tmp' . DS . $fileBackupName);
         $zip->createArchive();
         $zip->writeArchiveFile();
         $FileDelte = JPATH_ROOT . DS . 'tmp' . DS . $fileBackupName;
         $session->set('jsn_is_backup_for_migrate', $fileZipName, 'jsnimageshow');
         return true;
     }
     return false;
 }
Example #16
0
 /**
  * Method to create the manifest file.
  *
  * @param EcrProjectBase $project The project.
  *
  * @return boolean true on success
  */
 public function create(EcrProjectBase $project)
 {
     if (!$project->type) {
         $this->setError(__METHOD__ . ' - Invalid project given');
         return false;
     }
     $this->project = $project;
     $this->manifest = new EcrXMLElement('<?xml version="1.0" encoding="utf-8" ?><extension />');
     if (false == $this->manifest instanceof EcrXMLElement) {
         $this->setError('Could not create XML builder');
         return false;
     }
     try {
         $this->setUp()->processCredits()->processInstall()->processUpdates()->processSite()->processAdmin()->processMedia()->processPackageModules()->processPackagePlugins()->processPackageElements()->processParameters();
     } catch (Exception $e) {
         EcrHtml::message($e);
         return false;
     }
     if ($this->project->isNew) {
         //--New project
         $path = JPath::clean($this->project->basepath . '/' . $this->project->getJoomlaManifestName());
     } else {
         //--Building project
         $path = JPath::clean($this->project->basepath . '/' . JFile::getName(EcrProjectHelper::findManifest($this->project)));
     }
     $xml = $this->formatXML();
     if (false == JFile::write($path, $xml)) {
         $this->setError('Could not save XML file!');
         return false;
     }
     return true;
 }
Example #17
0
 function save()
 {
     $config = new JRegistry('config');
     $config_array = array();
     // affichage des boutons
     $config_array['bt_jamendo'] = JRequest::getVar('bt_jamendo', 0, 'post', 'int');
     $config_array['bt_artiste'] = JRequest::getVar('bt_artiste', 0, 'post', 'int');
     $config_array['bt_categories'] = JRequest::getVar('bt_categories', 0, 'post', 'int');
     $config_array['bt_sms'] = JRequest::getVar('bt_sms', 0, 'post', 'int');
     $config_array['bt_stats'] = JRequest::getVar('bt_stats', 0, 'post', 'int');
     $config_array['bt_aide'] = JRequest::getVar('bt_aide', 0, 'post', 'int');
     $config->loadArray($config_array);
     //Fichier de configuration
     $fname = JPATH_BASE . "/components/com_muzeetop/config.php";
     //écriture du fichier
     jimport('joomla.filesystem.file');
     $string = $config->toString('PHP', array('class' => 'JMztOptions'));
     if (JFile::write($fname, &$string)) {
         $msg = JTEXT::_('COM_MUZEETOP_OPTIONS_ENREGISTRE');
     } else {
         $msg = JTEXT::_('COM_MUZEETOP_ERREUR_OPTIONS_ENREGISTRE');
     }
     $link = 'index.php?option=com_muzeetop';
     $this->setRedirect($link, $msg);
 }
Example #18
0
 public function run($app)
 {
     // remove obsolete elements
     foreach (array('video', 'gallery', 'facebookilike', 'itempublishup') as $element) {
         if ($folder = $app->path->path('media:zoo/elements/' . $element)) {
             JFolder::delete($folder);
         }
     }
     // rename _itempublishup to _itempublish_up in config files
     foreach ($app->path->files('root:', true, '/positions\\.config/') as $file) {
         if (preg_match('#renderer\\/item\\/#', $file)) {
             $changed = false;
             if (!($path = $app->path->path('root:' . $file))) {
                 continue;
             }
             $data = $app->data->create(file_get_contents($path));
             if (!empty($data)) {
                 foreach ($data as $layout => $positions) {
                     foreach ($positions as $position => $elements) {
                         foreach ($elements as $index => $element) {
                             if (isset($element['element']) && $element['element'] == '_itempublishup') {
                                 $data[$layout][$position][$index]['element'] = '_itempublish_up';
                                 $changed = true;
                             }
                         }
                     }
                 }
             }
             if ($changed) {
                 $data = (string) $data;
                 JFile::write($app->path->path('root:' . $file), $data);
             }
         }
     }
 }
Example #19
0
 function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 75, $permissions = null)
 {
     $contents = '';
     if ($image_type == IMAGETYPE_JPEG) {
         ob_start();
         imagejpeg($this->image, null, $compression);
         $contents = ob_get_contents();
         ob_end_clean();
     } elseif ($image_type == IMAGETYPE_GIF) {
         ob_start();
         imagegif($this->image, null);
         $contents = ob_get_contents();
         ob_end_clean();
     } elseif ($image_type == IMAGETYPE_PNG) {
         ob_start();
         imagepng($this->image, null);
         $contents = ob_get_contents();
         ob_end_clean();
     }
     if (!$contents) {
         return false;
     }
     jimport('joomla.filesystem.file');
     $status = JFile::write($filename, $contents);
     return $status;
 }
Example #20
0
 /**
  * Method to handle upload action
  *
  * @return  void
  */
 public function uploadAction()
 {
     if ($this->request->getMethod() != 'POST') {
         return;
     }
     if (isset($_FILES['font-upload']) and $_FILES['font-upload']['error'] == 0) {
         // Verify font file
         if (!preg_match('/\\.(ttf|otf|eot|svg|woff)$/', $_FILES['font-upload']['name'])) {
             exit(JText::_('JSN_TPLFW_FONT_FILE_NOT_SUPPORTED'));
         }
         // Prepare directory to store uploaded font file
         $path = JPATH_ROOT . "/templates/{$this->template['name']}/uploads/fonts";
         if (!is_dir($path) and !JFolder::create($path)) {
             exit(JText::_('JSN_TPLFW_UPLOAD_CREATE_DIR_FAIL'));
         }
         // Check if the directory is writable
         $buffer = '<html><head></head><body></body></html>';
         if (!JFile::write("{$path}/index.html", $buffer)) {
             exit(JText::_('JSN_TPLFW_UPLOAD_CREATE_DIR_FAIL'));
         }
         // Move uploaded file to temporary folder
         $path .= '/' . str_replace(' ', '-', $_FILES['font-upload']['name']);
         if (!JFile::move($_FILES['font-upload']['tmp_name'], $path)) {
             exit(JText::_('JSN_TPLFW_UPLOAD_MOVE_FILE_FAIL'));
         }
     } else {
         exit(JText::sprintf('JSN_TPLFW_UPLOAD_FAIL', isset($_FILES['font-upload']) ? $_FILES['font-upload']['error'] : 'unknown'));
     }
     exit('OK');
 }
Example #21
0
 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);
 }
Example #22
0
 function checkUpdate()
 {
     jimport('joomla.filesystem.file');
     $dbPath = JPATH_ADMINISTRATOR . '/components/com_jak2filter/installer/sql/';
     /**
      * Example code for upgrade to version x.x.x
      */
     $versions = array("1.0.2", "1.0.7", "1.0.9", "1.1.5");
     $runIndexing = false;
     foreach ($versions as $version) {
         $check = dirname(__FILE__) . "/updated_{$version}.log";
         if (!JFile::exists($check)) {
             if ($version == "1.1.5") {
                 $runIndexing = true;
             }
             //processing code here
             $file = $dbPath . 'upgrade_v' . $version . '.sql';
             $this->parseSQLFile($file);
             //end of update code
             $flag = 'Updated at ' . date('Y-m-d H:i:s');
             JFile::write($check, $flag);
         }
     }
     if ($runIndexing) {
         $helper = new JAK2FilterHelper();
         $message = $helper->indexingData('upgrade');
         //JError::raiseNotice(100, $message);
     }
 }
Example #23
0
 function store()
 {
     JRequest::checkToken() or die('Invalid Token');
     $plugin = JRequest::getString('plugin');
     $plugin = preg_replace('#[^a-zA-Z0-9]#Uis', '', $plugin);
     $body = JRequest::getVar('templatebody', '', '', 'string', JREQUEST_ALLOWRAW);
     if (empty($body)) {
         acymailing_display(JText::_('FILL_ALL'), 'error');
         return;
     }
     $pluginsFolder = ACYMAILING_MEDIA . 'plugins';
     if (!file_exists($pluginsFolder)) {
         acymailing_createDir($pluginsFolder);
     }
     try {
         jimport('joomla.filesystem.file');
         $status = JFile::write($pluginsFolder . DS . $plugin . '.php', $body);
     } catch (Exception $e) {
         $status = false;
     }
     if ($status) {
         acymailing_display(JText::_('JOOMEXT_SUCC_SAVED'), 'success');
     } else {
         acymailing_display(JText::sprintf('FAIL_SAVE', $pluginsFolder . DS . $plugin . '.php'), 'error');
     }
 }
 private function updateLibrary($version)
 {
     $config = JFactory::getConfig();
     $filename = $this->getFilename($version);
     $url = $this->getUrlFromFilename($filename);
     $target = JPATH_ROOT . DS . 'media' . DS . 'plg_' . $this->_type . '_' . $this->_name . DS . 'js' . DS . $filename;
     if (JFile::exists($target)) {
         return true;
     }
     $php_errormsg = 'Error Unknown';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     $inputHandle = @fopen($url, "r");
     $error = strstr($php_errormsg, 'failed to open stream:');
     if (!$inputHandle) {
         JError::raiseWarning(0, JText::sprintf('PLG_SYSTEM_RVS_JQUERYLOADER_CONNECT_ERROR', $error));
         return false;
     }
     $contents = null;
     while (!feof($inputHandle)) {
         $contents .= fread($inputHandle, 4096);
         if (!$contents) {
             JError::raiseWarning(0, JText::sprintf('PLG_SYSTEM_RVS_JQUERYLOADER_READ_ERROR', $php_errormsg));
             return false;
         }
     }
     JFile::write($target, $contents);
     fclose($inputHandle);
     ini_set('track_errors', $track_errors);
     return true;
 }
Example #25
0
 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)) {
         JFolder::create($cacheDir);
     }
     $cacheFile = "{$cacheDir}/kunena.bootstrap.{$inputFile}.cache";
     if (file_exists($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);
         JFile::write($cacheFile, $cache);
         JFile::write($outputFile, $newCache['compiled']);
     }
 }
Example #26
0
 function update($parent)
 {
     //echo '<p>' . JText::sprintf('COM_PHOCAGALLERY_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';
     $folder[0][0] = 'images' . DS . 'phocagallery' . DS;
     $folder[0][1] = JPATH_ROOT . DS . $folder[0][0];
     $folder[1][0] = 'images' . DS . 'phocagallery' . DS . 'avatars' . DS;
     $folder[1][1] = JPATH_ROOT . DS . $folder[1][0];
     $message = '';
     $error = array();
     foreach ($folder as $key => $value) {
         if (!JFolder::exists($value[1])) {
             if (JFolder::create($value[1], 0755)) {
                 $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
                 JFile::write($value[1] . DS . "index.html", $data);
                 $message .= '<div><b><span style="color:#009933">Folder</span> ' . $value[0] . ' <span style="color:#009933">created!</span></b></div>';
                 $error[] = 0;
             } else {
                 $message .= '<div><b><span style="color:#CC0033">Folder</span> ' . $value[0] . ' <span style="color:#CC0033">creation failed!</span></b> Please create it manually.</div>';
                 $error[] = 1;
             }
         } else {
             $message .= '<div><b><span style="color:#009933">Folder</span> ' . $value[0] . ' <span style="color:#009933">exists!</span></b></div>';
             $error[] = 0;
         }
     }
     $msg = JText::_('COM_PHOCAGALLERY_UPDATE_TEXT');
     $msg .= ' (' . JText::_('COM_PHOCAGALLERY_VERSION') . ': ' . $parent->get('manifest')->version . ')';
     $msg .= '<br />' . $message;
     $app = JFactory::getApplication();
     $app->enqueueMessage($msg);
     $app->redirect(JRoute::_('index.php?option=com_phocagallery'));
 }
Example #27
0
 public function display($tpl = null)
 {
     $model = $this->getModel();
     $xmlContent = $model->backupAssets();
     $sqlContent = $model->backupSql();
     $version = JFactory::getDate()->toUnix();
     $xmlFilePath = JFactory::getConfig()->get('tmp_path') . '/' . 'xml-' . $version . '.xml';
     $sqlFilePath = JFactory::getConfig()->get('tmp_path') . '/' . 'sql-' . $version . '.sql';
     JFile::write($xmlFilePath, $xmlContent);
     JFile::write($sqlFilePath, $sqlContent);
     $fileDownloadName = 'solidres' . $version . '.zip';
     SRFactory::get('solidres.utilities.ziparchive')->zipFiles(array($xmlFilePath, $sqlFilePath), JFactory::getConfig()->get('tmp_path') . '/' . $fileDownloadName);
     JFile::delete($xmlFilePath);
     JFile::delete($sqlFilePath);
     //make file to download
     header('Content-Type: application/zip');
     header('Content-Disposition: attachment; filename="' . $fileDownloadName);
     header("Content-Transfer-Encoding: binary");
     header('Accept-Ranges: bytes');
     header("Cache-control: private");
     header('Pragma: private');
     header("Expires: " . JFactory::getDate()->toSql());
     header("Content-Length: " . filesize(JFactory::getConfig()->get('tmp_path') . '/' . $fileDownloadName));
     ob_clean();
     flush();
     readfile(JFactory::getConfig()->get('tmp_path') . '/' . $fileDownloadName);
     JFile::delete(JFactory::getConfig()->get('tmp_path') . '/' . $fileDownloadName);
 }
Example #28
0
 /**
  * saveTrackList
  *
  * @param $track
  *
  * @return void
  */
 public function saveTrackList($track)
 {
     jimport('joomla.filesystem.file');
     $content = $track->toString('yaml');
     \JFile::write($this->file, $content);
     $this->state->set('track.save.path', $this->file);
 }
Example #29
0
/**
 * Disables the unsupported eAccelerator caching method, replacing it with the
 * "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
    $prev = new JConfig();
    $prev = JArrayHelper::fromObject($prev);
    $data = array('cacheHandler' => 'file');
    $data = array_merge($prev, $data);
    $config = new Registry('config');
    $config->loadArray($data);
    jimport('joomla.filesystem.path');
    jimport('joomla.filesystem.file');
    // Set the configuration file path.
    $file = JPATH_CONFIGURATION . '/configuration.php';
    // Get the new FTP credentials.
    $ftp = JClientHelper::getCredentials('ftp', true);
    // Attempt to make the file writeable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
    }
    // Attempt to write the configuration file as a PHP class named JConfig.
    $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
    if (!JFile::write($file, $configuration)) {
        JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
        return;
    }
    // Attempt to make the file unwriteable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
    }
}
Example #30
0
 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);
 }