/**
  * Create a folder
  *
  * @param   string   $path  Folder path
  * @param   bitmask  $mode  Permissions
  *
  * @return bool
  */
 public function createFolder($path, $mode = 0755)
 {
     if (JFolder::create($path, $mode)) {
         return $this->createIndexFile($path);
     }
     return false;
 }
Beispiel #2
0
 /**
  * Get Page JavaScript from either session or cached .js file
  *
  * @return string
  */
 public static function js()
 {
     $config = JFactory::getConfig();
     if ($config->get('caching') == 0) {
         $script = self::buildJs();
     } else {
         $uri = JURI::getInstance();
         $session = JFactory::getSession();
         $uri = $uri->toString(array('path', 'query'));
         $file = md5($uri) . '.js';
         $folder = JPATH_SITE . '/cache/com_fabrik/js/';
         if (!JFolder::exists($folder)) {
             JFolder::create($folder);
         }
         $cacheFile = $folder . $file;
         // Check for cached version
         if (!JFile::exists($cacheFile)) {
             $script = self::buildJs();
             file_put_contents($cacheFile, $script);
         } else {
             $script = JFile::read($cacheFile);
         }
     }
     self::clearJs();
     return $script;
 }
 /**
  * Create missing folders
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.0
  */
 public function createFolder()
 {
     $app = JFactory::getApplication();
     jimport('joomla.filesystem.folder');
     $folder = str_ireplace(JPATH_ROOT, '', JRequest::getVar('folder'));
     return JFolder::create($folder);
 }
Beispiel #4
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;
 }
Beispiel #5
0
 private function createFolders()
 {
     $thumbFolder = JPATH_ROOT . '/images/ariimageslider';
     if (!JFolder::exists($thumbFolder)) {
         JFolder::create($thumbFolder);
     }
 }
Beispiel #6
0
 /**
  * Called on installation
  *
  * @param   JAdapterInstance  $adapter  The object responsible for running this script
  *
  * @return  boolean  True on success
  */
 public function install(JAdapterInstance $adapter)
 {
     if (version_compare(JVERSION, '2.5.5') >= 0) {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->update('#__extensions');
         $query->set('enabled = 1');
         $query->where('type = "plugin"');
         $query->where('folder = "system"');
         $query->where('element = "pwebj3ui"');
         $db->setQuery($query);
         try {
             $db->execute();
         } catch (Exception $e) {
         }
     }
     if (version_compare(JVERSION, '3.0.0') == -1) {
         $this->copyMedia(true);
     } else {
         if (version_compare(JVERSION, '3.1.4') == -1) {
             // Update Bootstrap to version 2.3.2
             $this->copyBootstrap();
         }
         // remove unused files from plugin
         $plugin_path = JPATH_ROOT . '/plugins/system/pwebj3ui/';
         JFolder::delete($plugin_path . 'libraries/cms');
         JFolder::delete($plugin_path . 'media');
         JFolder::create($plugin_path . 'media');
         JFile::copy($plugin_path . 'index.html', $plugin_path . 'media/index.html');
     }
 }
Beispiel #7
0
 /**
  * Class constructor
  *
  * @param string $file Path to cache file
  * @param boolean $hash Wether the key should be hashed
  * @param int $lifetime The values lifetime
  * @since 2.0
  */
 public function __construct($file, $hash = true, $lifetime = null)
 {
     // if cache file doesn't exist, create it
     if (!JFile::exists($file)) {
         JFolder::create(dirname($file));
         $buffer = '';
         JFile::write($file, $buffer);
     }
     // set file and parse it
     $this->_file = $file;
     $this->_hash = $hash;
     $this->_parse();
     // clear out of date values
     if ($lifetime) {
         $lifetime = (int) $lifetime;
         $remove = array();
         foreach ($this->_items as $key => $value) {
             if (time() - $value['timestamp'] > $lifetime) {
                 $remove[] = $key;
             }
         }
         foreach ($remove as $key) {
             unset($this->_items[$key]);
         }
     }
 }
Beispiel #8
0
 public static function thumb($image, $width, $height, $ratio = false, $uniqid)
 {
     // remove any / that begins the path
     if (substr($image, 0, 1) == '/') {
         $image = substr($image, 1);
     }
     // create a thumb filename
     $file_dir = dirname($image);
     $thumb_dir = $file_dir . DS . "tzslider_thumbs";
     if (!JFolder::exists($thumb_dir)) {
         JFolder::create($thumb_dir);
     }
     $file_name = JFile::stripExt(basename($image));
     $file_ext = JFile::getExt($image);
     $thumb_path = $thumb_dir . DS . $file_name . '_' . $uniqid . "_thumb." . $file_ext;
     // check to see if this file exists, if so we don't need to create it
     if (function_exists("gd_info")) {
         //Check existing thumbnails dimensions
         if (file_exists($thumb_path)) {
             $size = GetImageSize($thumb_path);
             $currentWidth = $size[0];
             $currentHeight = $size[1];
         }
         //Creating thumbnails
         if (!file_exists($thumb_path) || $currentWidth != $width || $currentHeight != $height) {
             modTzContentSliderCommonHelper::crop($image, $width, $height, $ratio, $thumb_path);
         }
     }
     return str_replace("\\", "/", $thumb_path);
 }
Beispiel #9
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');
 }
Beispiel #10
0
 public static function processImage($width = 0, $height = 0, $type = '', $pk = 0, $uploadname = 'default.gif')
 {
     // get what sizes we need
     list($width, $height) = static::getImageSizes($width, $height);
     // check if we have the original image
     $origpath = static::makePath($type, $pk, $uploadname);
     if (!JFile::exists(JPATH_ROOT . '/' . $origpath)) {
         return $pk ? static::processImage($width, $height) : false;
     }
     // check if we have already made the resized image
     $path = static::makePath($type, $pk, $uploadname, $width, $height);
     if (JFile::exists(JPATH_ROOT . '/' . $path)) {
         return $path;
     }
     // check if our folder exists and if not, if we can create it
     $folder = dirname(JPATH_ROOT . '/' . $path);
     if (!JFolder::exists($folder) && !JFolder::create($folder)) {
         return $pk ? static::processImage($width, $height) : false;
     }
     // create us a resized image
     $LNSimpleImage = new LNSimpleImage(JPATH_ROOT . '/' . $origpath);
     $LNSimpleImage->resizeToFit($width, $height);
     $LNSimpleImage->save(JPATH_ROOT . '/' . $path);
     return $path;
 }
Beispiel #11
0
 public static function uploader()
 {
     $params = modPwebcontactHelper::getParams();
     // check if upload is enabled
     if (!$params->get('show_upload', 0)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Uploader disabled');
         }
         return array('status' => 402, 'files' => array());
     }
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $path = $params->get('upload_path');
     if (!JFolder::exists($path)) {
         JFolder::create($path, 0777);
     }
     if (!is_writable($path) and JPath::canChmod($path)) {
         JPath::setPermissions($path, null, '0777');
     }
     if (!is_writable($path)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Upload dir is not writable');
         }
         return array('status' => 403, 'files' => array());
     }
     // load uploader
     $uploader = new modPWebContactUploader(array('upload_dir' => $params->get('upload_path'), 'upload_url' => $params->get('upload_url'), 'accept_file_types' => '/(\\.|\\/)(' . $params->get('upload_allowed_ext', '.+') . ')$/i', 'max_file_size' => (double) $params->get('upload_size_limit', 1) * 1024 * 1024, 'image_versions' => array(), 'delete_type' => 'POST'), false, array(1 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 3 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_3'), 4 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_4'), 6 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_6'), 7 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_7'), 8 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_8'), 'post_max_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 'max_file_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_SIZE_ERR'), 'accept_file_types' => JText::_('MOD_PWEBCONTACT_UPLOAD_TYPE_ERR')));
     $response = $uploader->handleRequest();
     if (PWEBCONTACT_DEBUG) {
         modPwebcontactHelper::setLog('Uploader exit');
     }
     return $response;
 }
Beispiel #12
0
 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;
 }
Beispiel #13
0
 /**
  * Extract a ZIP compressed file to a given path
  *
  * @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 on success
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 public function extract($archive, $destination, array $options = array())
 {
     $this->_data = null;
     $this->_metadata = null;
     $this->_data = file_get_contents($archive);
     if (!$this->_data) {
         throw new RuntimeException('Unable to read archive');
     }
     $this->_getTarInfo($this->_data);
     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 . '/' . $this->_metadata[$i]['name']);
             // Make sure the destination folder exists
             if (!JFolder::create(dirname($path))) {
                 throw new RuntimeException('Unable to create destination');
             }
             if (JFile::write($path, $buffer) === false) {
                 throw new RuntimeException('Unable to write entry');
             }
         }
     }
     return true;
 }
Beispiel #14
0
 /**
  * Create ZIP archive.
  *
  * @param   array    $files  An array of files to put in archive.
  * @param   boolean  $save   Whether to save zip data to file or not?
  * @param   string   $name   Name with path to store archive file.
  *
  * @return  mixed  Zip data if $save is FALSE, or boolean value if $save is TRUE
  */
 public static function createZip($files, $save = false, $name = '')
 {
     if (is_array($files) and count($files)) {
         // Initialize variables
         $zip = new zipfile();
         $root = str_replace('\\', '/', JPATH_ROOT);
         foreach ($files as $file) {
             // Add file to zip archive
             if (is_array($file)) {
                 foreach ($file as $k => $v) {
                     $zip->create_file($v, $k);
                 }
             } elseif (is_string($file) and is_readable($file)) {
                 // Initialize file path
                 $file = str_replace('\\', '/', $file);
                 $path = str_replace($root, '', $file);
                 $zip->create_file(JFile::read($file), $path);
             }
         }
         // Save zip archive to file system
         if ($save) {
             if (!JFolder::create($dest = dirname($name))) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_FOLDER_NOT_EXISTS', $dest));
             }
             if (!JFile::write($name, $zip->zipped_file())) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_CANNOT_WRITE_FILE', $name));
             }
             return true;
         } else {
             return $zip->zipped_file();
         }
     }
     return false;
 }
Beispiel #15
0
 public function createInitialDirectories()
 {
     if (!JFolder::exists($this->gallery->getPhotosPath())) {
         // TODO error handling
         JFolder::create($this->gallery->getPhotosPath());
     }
 }
Beispiel #16
0
 function InstallCBPlugin($plugintitle, $tabtitle, $pluginname, $folder, $class)
 {
     $database = JFactory::getDBO();
     $query = "SELECT id FROM #__comprofiler_plugin where element='{$pluginname}'";
     $database->setQuery($query);
     $plugid = $database->loadResult();
     if (!$plugid) {
         $query = "INSERT INTO #__comprofiler_plugin SET\r\n                `name`='{$plugintitle}',\r\n                `element`='{$pluginname}',\r\n                `type`='user',\r\n                `folder`='{$folder}',\r\n                `ordering`=99,\r\n                `published`=1,\r\n                `iscore`=0\r\n            ";
         $database->setQuery($query);
         $database->query();
         $plugid = $database->insertid();
     }
     $query = "SELECT COUNT(1) FROM #__comprofiler_tabs where pluginid='{$plugid}'";
     $database->setQuery($query);
     $tabs = $database->loadResult();
     if (!$tabs) {
         $query = "INSERT INTO #__comprofiler_tabs set\r\n                `title`='{$tabtitle}',\r\n                `ordering`=999,\r\n                `enabled`=1,\r\n                `pluginclass`='{$class}',\r\n                `pluginid`='{$plugid}',\r\n                `fields`=0,\r\n                `displaytype`='tab',\r\n                `position`='cb_tabmain'\r\n            ";
         $database->setQuery($query);
         $database->query();
     }
     $sourceFolder = $this->_sourcepath . DS . $folder;
     $destinationFolder = JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . $folder;
     JFolder::create($destinationFolder);
     JFolder::copy($sourceFolder, $destinationFolder, '', true);
     return "Installed CB plugin " . $plugintitle;
 }
Beispiel #17
0
 /**
  * create a folder
  * @param $path
  * @return unknown_type
  */
 function createFolder($path)
 {
     if (JFolder::create($path)) {
         return $this->createIndexFile($path);
     }
     return false;
 }
Beispiel #18
0
 function getbackup()
 {
     global $mainframe;
     if (!JFile::exists(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php')) {
         JError::raiseWarning(304, 'Backup file doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     $version = JRequest::getCmd('version');
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . 'backup.php';
     if (!JFile::exists($urlbackup)) {
         JError::raiseWarning(400, 'File backup doesn\'t exist!');
         $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version');
         return false;
     }
     // do the unpacking of the archive
     $extractdir = JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . uniqid($version . '_');
     $archivename = $urlbackup;
     JFolder::create($extractdir);
     $result = JArchive::extract($archivename, $extractdir);
     // Get Instance
     $autoupdate = new AutoupdateHelper($extractdir . DS . 'update.xml', false, true, false, $extractdir);
     $autoupdate->upgradeFile();
     $autoupdate->cleanFileUpdate();
     $mainframe->redirect('index.php?option=com_yos_resources_manager&view=version', $autoupdate->getReport());
 }
Beispiel #19
0
 /**
  * unzip the file
  * @return bool
  */
 public function unzip()
 {
     JRequest::checkToken() or die('Invalid Token');
     $appl = JFactory::getApplication();
     // if folder doesn't exist - create it!
     if (!JFolder::exists($this->pathUnzipped)) {
         JFolder::create($this->pathUnzipped);
     } else {
         // let us remove all previous unzipped files
         $folders = JFolder::folders($this->pathUnzipped);
         foreach ($folders as $folder) {
             JFolder::delete($this->pathUnzipped . '/' . $folder);
         }
     }
     $file = JFolder::files($this->pathArchive);
     $result = JArchive::extract($this->pathArchive . '/' . $file[0], $this->pathUnzipped . '/' . $file[0]);
     if ($result) {
         // scan unzipped folders if we find zip file -> unzip them as well
         $this->unzipAll($this->pathUnzipped . '/' . $file[0]);
         $message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
     } else {
         $message = 'COM_JEDCHECKER_UNZIP_FAILED';
     }
     $appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
     return $result;
 }
Beispiel #20
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'));
 }
Beispiel #21
0
 public function __construct($options = array())
 {
     $this->db = JFactory::getDbo();
     $this->tmp = JFactory::getConfig()->get('tmp_path');
     $this->key = isset($options['key']) ? $options['key'] : null;
     $this->overwrite = isset($options['overwrite']) ? $options['overwrite'] : null;
     $this->form = isset($options['form']) ? $options['form'] : null;
     $this->file = isset($options['file']) ? (int) $options['file'] : 0;
     $this->formId = isset($options['formId']) ? (int) $options['formId'] : 0;
     $this->keepId = isset($options['keepId']) ? true : false;
     // Check if the temporary folder is writable.
     if (!is_writable($this->tmp)) {
         throw new Exception(sprintf('The temporary folder "%s" is not writable!', $this->tmp));
     }
     // Generate a path where we will copy the backup.
     $this->path = $this->tmp . '/rsform_backup_' . $this->getKey();
     // Let's create our folder if it doesn't exist.
     if (!is_dir($this->path) && !JFolder::create($this->path)) {
         throw new Exception(sprintf('Could not create temporary path "%s"!', $this->path));
     }
     // Check if the newly created path (or supplied one) is writable.
     if (!is_writable($this->path)) {
         throw new Exception(sprintf('Path "%s" is not writable!', $this->path));
     }
 }
Beispiel #22
0
 public static function recreateCacheFolder($joomla_caching = 0, $params)
 {
     if (!class_exists('JFile')) {
         jimport('joomla.filesystem.file');
     }
     if (!class_exists('JFolder')) {
         jimport('joomla.filesystem.folder');
     }
     if (!is_object($params)) {
         return false;
     }
     $app = JFactory::getApplication();
     $cache_folder = self::getCacheFolder($params);
     if (!JFolder::exists($cache_folder)) {
         JFolder::create($cache_folder);
     }
     if ($joomla_caching) {
         return $cache_folder;
     }
     //else
     $cached_time = intval($params->get('script_default_cached_time', 0));
     $time = time();
     $cached_time_limit = intval($time) + intval($params->get('cache_time', 0));
     if ($cached_time == 0 || $time > $cached_time) {
         $nome_barrajs = self::getCacheFileName($params);
         @unlink($cache_folder . '/' . $nome_barrajs);
         self::setCachedTime($cached_time_limit, $cached_time);
     }
     return $cache_folder;
 }
Beispiel #23
0
 /**
  * Method is responsible to create a folder in the site.
  *
  * @access	public
  * @param	null
  */
 public function createFolder()
 {
     $ajax = EasyBlogHelper::getHelper('Ajax');
     // This is the relative path to the items that needs to be deleted.
     $path = JRequest::getVar('path');
     // This let's us know the type of folder we should lookup to
     $place = JRequest::getString('place');
     // @task: Create the media object.
     $media = new EasyBlogMediaManager();
     $absolutePath = EasyBlogMediaManager::getAbsolutePath($path, $place);
     if (JFolder::exists($absolutePath)) {
         return $ajax->fail(JText::_('COM_EASYBLOG_FOLDER_EXISTS'));
     }
     // @task: Let's create the folder
     JFolder::create($absolutePath);
     // @task: Let's copy a standard index.html to prevent any directory browsing here.
     $source = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'index.html';
     $destination = $absolutePath . DIRECTORY_SEPARATOR . 'index.html';
     JFile::copy($source, $destination);
     // @task: Get the absolute URI to the destination item.
     $uri = EasyBlogMediaManager::getAbsoluteURI($path, $place);
     // @task: Try to get the relative path of the "path" . Since the last fragment is always the folder that we're trying to create.
     $relative = dirname($path);
     $obj = $media->getItem($absolutePath, $uri, $relative, false, $place)->toArray();
     $ajax->success($obj);
 }
Beispiel #24
0
 /**
  * Execute Create Instance
  *
  * @param	string	$path	Path of create files
  */
 public static function execute($config = array())
 {
     $item = JModelLegacy::getInstance("Template", "JDeveloperModel")->getItem($config['item_id']);
     $dir = $item->createDir;
     // Create folders
     JFolder::create($dir . "/css");
     JFolder::create($dir . "/html");
     JFolder::create($dir . "/images");
     JFolder::create($dir . "/js");
     JFolder::create($dir . "/less");
     // Copy files
     JFile::copy(JDeveloperTEMPLATES . "/template/template.css", $dir . "/css/template.css");
     foreach (JFolder::files(JDeveloperCREATE . "/template", "php\$") as $file) {
         $class = JDeveloperCreate::getInstance("template." . JFile::stripExt($file), $config);
         if (!$class->create()) {
             $errors = $class->getErrors();
             if (!empty($errors)) {
                 throw new JDeveloperException($errors);
             }
         }
     }
     JDeveloperCreate::getInstance("language.template", $config)->create();
     JDeveloperCreate::getInstance("language.template.sys", $config)->create();
     JFile::copy(JDeveloperTEMPLATES . "/template/favicon.ico", $dir . "/favicon.ico");
 }
Beispiel #25
0
function com_install()
{
    $mainframe = JFactory::getApplication();
    jimport('joomla.filesystem.folder');
    // Initialize variables
    jimport('joomla.client.helper');
    $FTPOptions = JClientHelper::getCredentials('ftp');
    $language = JFactory::getLanguage();
    $language->load('com_jce_imgmanager_ext', JPATH_SITE);
    $cache = $mainframe->getCfg('tmp_path');
    // Check for tmp folder
    if (!JFolder::exists($cache)) {
        // Create if does not exist
        if (!JFolder::create($cache)) {
            $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error');
        }
    }
    // Check if folder exists and is writable or the FTP layer is enabled
    if (JFolder::exists($cache) && (is_writable($cache) || $FTPOptions['enabled'] == 1)) {
        $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_CACHE_DESC'));
    } else {
        $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_CACHE_DESC'), 'error');
    }
    // Check for GD
    if (!function_exists('gd_info')) {
        $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_NO_GD_DESC'), 'error');
    } else {
        $info = gd_info();
        $mainframe->enqueueMessage(WFText::_('WF_IMGMANAGER_EXT_GD_DESC') . ' - ' . $info['GD Version']);
    }
    // remove wideimage folder
    if (JFolder::exists(dirname(__FILE) . '/classes/wideimage')) {
        @JFolder::delete(dirname(__FILE) . '/classes/wideimage');
    }
}
function civicrm_setup()
{
    global $adminPath, $compileDir;
    $adminPath = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm';
    $jConfig = JFactory::getConfig();
    set_time_limit(4000);
    // Path to the archive
    $archivename = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.zip';
    // a bit of support for the non-alternaive joomla install
    if (file_exists($archivename)) {
        // ensure that the site has native zip, else abort
        if (!function_exists('zip_open') || !function_exists('zip_read')) {
            echo "Your PHP version is missing  zip functionality. Please ask your system administrator / hosting provider to recompile PHP with zip support.<p>";
            echo "If this is a new install, you will need to uninstall CiviCRM from the Joomla Extension Manager.<p>";
            exit;
        }
        $extractdir = $adminPath;
        JArchive::extract($archivename, $extractdir);
    }
    $scratchDir = JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'civicrm';
    if (!is_dir($scratchDir)) {
        JFolder::create($scratchDir, 0777);
    }
    $compileDir = $scratchDir . DIRECTORY_SEPARATOR . 'templates_c';
    if (!is_dir($compileDir)) {
        JFolder::create($compileDir, 0777);
    }
    $db = JFactory::getDBO();
    $db->setQuery(' SELECT count( * )
FROM information_schema.tables
WHERE table_name LIKE "civicrm_domain"
AND table_schema = "' . $jConfig->getValue('config.db') . '" ');
    global $civicrmUpgrade;
    $civicrmUpgrade = $db->loadResult() == 0 ? FALSE : TRUE;
}
Beispiel #27
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']);
     }
 }
Beispiel #28
0
 public function loadFromUrl($url, $overwrite = false, $tempFolder = null)
 {
     if (is_null($tempFolder)) {
         $tempFolder = JPATH_ROOT . '/tmp/crex/media';
     }
     if (!JFolder::exists($tempFolder)) {
         JFolder::create($tempFolder);
     }
     $fileExtension = JFile::getExt($url);
     $filePath = $tempFolder . '/' . md5($url) . '.' . $fileExtension;
     if (!JFile::exists($filePath) || $overwrite == true) {
         $fileHandeler = fopen($filePath, 'w+');
         $curlHandeler = curl_init(str_replace(" ", "%20", $url));
         curl_setopt($curlHandeler, CURLOPT_TIMEOUT, 50);
         curl_setopt($curlHandeler, CURLOPT_FILE, $fileHandeler);
         curl_setopt($curlHandeler, CURLOPT_FOLLOWLOCATION, true);
         curl_exec($curlHandeler);
         curl_close($curlHandeler);
         fclose($fileHandeler);
     }
     if (JFile::exists($filePath)) {
         $this->loadFile($filePath);
     } else {
         $this->setError(JText::_('CREX_ERROR_FILE_NOT_FOUND'));
     }
     return $this;
 }
Beispiel #29
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;
 }
Beispiel #30
0
 public function display($tpl = null)
 {
     $params = JComponentHelper::getParams('com_staticcontent');
     $base_directory = $params->get('base_directory');
     $this->sef = JFactory::getConfig()->get('sef', 0);
     $this->base_directory = empty($base_directory) ? '' : JPath::clean($base_directory);
     if (!JFolder::exists($this->base_directory) && !empty($this->base_directory)) {
         JFolder::create($this->base_directory);
         JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_STATICCONTENT_HTML_CREATED_DIRECTORY_MESSAGE', $this->base_directory));
     }
     if (JFolder::exists($this->base_directory) && !empty($this->base_directory)) {
         if ($this->sef == 0) {
             $this->_layout = 'message';
             $this->message = 'COM_STATICCONTENT_HTML_SEF_DISABLED';
         } else {
             $this->items = JFolder::files($this->base_directory, '.html', true, true);
             foreach ($this->items as &$item) {
                 $item = JPath::clean($item);
                 $path = JPath::clean($this->base_directory . DIRECTORY_SEPARATOR);
                 $item = str_replace($path, '', $item);
                 $item = str_replace(DIRECTORY_SEPARATOR, '/', $item);
             }
             $this->baseUri = rtrim($params->get('base_url'), '/') . '/';
         }
     } else {
         $this->_layout = 'message';
         $this->message = 'COM_STATICCONTENT_HTML_CONFIG_DIRECTORY';
     }
     $this->addToolbar();
     parent::display($tpl);
 }