Esempio n. 1
0
 function __construct($params)
 {
     global $module;
     JModel::addIncludePath(JPATH_VM_ADMINISTRATOR . DS . 'models');
     $model = JModel::getInstance('Product', 'VirtueMartModel');
     $this->model = $model;
     $this->params = $params;
     $this->_baseurl = str_replace('modules/mod_virtuemart_quickcart/', '', JURI::base());
     $this->_pathimg = str_replace('modules/mod_virtuemart_quickcart/', '', JURI::base()) . 'modules/' . $module->module . '/libraries/timthumb.php';
     $this->_dir = JPATH::clean(JPATH_ROOT . '/cache/' . $module->module . '_' . $module->id . '/images');
     $this->_pathCacheImage = str_replace('modules/mod_virtuemart_quickcart/', '', JURI::base()) . 'cache/' . $module->module . '_' . $module->id . '/images/';
 }
Esempio n. 2
0
    private function _install($update = false, $parent)
    {
        echo JHtml::_('sliders.start', 'steps', array('allowAllClose' => true, 'startTransition' => true, true));
        $image = '<img src="../media/com_joomleague/jl_images/ext_com.png">';
        echo JHtml::_('sliders.panel', $image . ' Component', 'panel-component');
        ?>
		<h2>Welcome to JoomLeague!</h2>
		<img
			src="../media/com_joomleague/jl_images/joomleague_logo.png"
			alt="JoomLeague" title="JoomLeague" />
		<?php 
        $this->install_admin_rootfolder = JPATH::clean($parent->getParent()->getPath('source') . '/admin');
        $this->install_rootfolder = $parent->getParent()->getPath('source');
        $this->debug = false;
        $maxExecutionTime = $maxInputTime = 900;
        if ((int) ini_get('max_execution_time') < $maxExecutionTime) {
            @set_time_limit($maxExecutionTime);
        }
        if ((int) ini_get('max_input_time') < $maxInputTime) {
            @set_time_limit($maxInputTime);
        }
        $time_start = microtime(true);
        // slider - database
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Database', 'panel-database');
        include_once $this->install_admin_rootfolder . '/models/databasetools.php';
        if ($update) {
        }
        // slider - imagefolder
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Create/Update Images Folders', 'panel-images');
        self::createImagesFolder();
        // slider - basicData
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Basic Data', 'panel-basicdata');
        include_once $this->install_rootfolder . '/site/joomleague.core.php';
        include_once $this->install_admin_rootfolder . '/assets/updates/jl_install.php';
        // self::installPermissions();
        echo JHtml::_('sliders.end');
        echo self::getFxInitJSCode('steps');
        ?>
		
		<hr />
	<?php 
        $time_end = microtime(true);
        $time = $time_end - $time_start;
        echo '<hr />';
        if ($this->debug) {
            echo '<br>Overall Duration: ' . round($time) . 's<br>';
        }
    }
Esempio n. 3
0
 function onRokNavMenuRegisterParamsFile(&$param_files, $item_id)
 {
     $template_path = JPATH::clean(JPATH_ROOT . '/templates/' . $this->_getFrontSideTemplate() . '/html/mod_roknavmenu/items/item.xml');
     if (JFile::exists($template_path)) {
         $param_files['PLG.ROKNAVMENU.PARAMTERS.TEMPLATE'] = $template_path;
     }
     $template_themes_path = '/templates/' . $this->_getFrontSideTemplate() . '/html/mod_roknavmenu/themes';
     $template_themes_full_path = JPath::clean(JPATH_ROOT . $template_themes_path);
     $template_theme_text = JText::_("Template theme");
     $module_themes_path = '/modules/mod_roknavmenu/themes';
     $module_themes_full_path = JPath::clean(JPATH_ROOT . $module_themes_path);
     $module_theme_text = JText::_("Default theme");
     $lang = JFactory::getLanguage();
     // get the template items.
     /** Get the Template Themes **/
     if (JFolder::exists($template_themes_full_path)) {
         $folders = JFolder::folders($template_themes_full_path);
         if (is_array($folders)) {
             reset($folders);
             while (list($key, $val) = each($folders)) {
                 $folder =& $folders[$key];
                 $langfile = $template_themes_full_path . DS . $folder . DS . 'language' . DS . $lang->_lang . '.ini';
                 if (JFile::exists($langfile)) {
                     $lang->_load($langfile, 'roknavmenu_theme_template_' . $folder);
                 }
                 $theme_item_file = $template_themes_full_path . DS . $folder . DS . 'item.xml';
                 if (JFile::exists($theme_item_file)) {
                     $param_files[JText::sprintf('PLG.ROKNAVMENU.PARAMTERS.THEME', $template_theme_text . " - " . $folder)] = $theme_item_file;
                 }
             }
         }
     }
     if (JFolder::exists($module_themes_full_path)) {
         $folders = JFolder::folders($module_themes_full_path);
         if (is_array($folders)) {
             reset($folders);
             while (list($key, $val) = each($folders)) {
                 $folder =& $folders[$key];
                 $langfile = $module_themes_full_path . DS . $folder . DS . 'language' . DS . $lang->_lang . '.ini';
                 if (JFile::exists($langfile)) {
                     $lang->_load($langfile, 'roknavmenu_theme_module_' . $folder);
                 }
                 $theme_item_file = $module_themes_full_path . DS . $folder . DS . 'item.xml';
                 if (JFile::exists($theme_item_file)) {
                     $param_files[JText::sprintf('PLG.ROKNAVMENU.PARAMTERS.THEME', $module_theme_text . " - " . $folder)] = $theme_item_file;
                 }
             }
         }
     }
 }
Esempio n. 4
0
function addSportsType()
{
    echo JText::_('Inserting default Sport-Types');
    $status = 0;
    $db = JFactory::getDbo();
    $extension = "com_joomleague_sport_types";
    $lang = JFactory::getLanguage();
    $source = JPATH_ADMINISTRATOR . '/components/' . $extension;
    $lang->load("{$extension}", JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension, $source, null, false, false) || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension, $source, $lang->getDefault(), false, false);
    $status = 1;
    $jllang = new JLLanguage();
    $jllang->setLanguage($lang);
    $props = $jllang->getProperties();
    $strings = $props['strings'];
    $praefix = 'COM_JOOMLEAGUE_ST_';
    foreach ($strings as $key => $value) {
        // Add all Sport-types e.g. Soccer to #__joomleague_sports_type
        $pos = strpos($key, $praefix);
        if ($pos !== false) {
            $name = strtolower(substr($key, strlen($praefix)));
            $tblSportsType = JTable::getInstance("SportsType", "Table");
            //fix for existing items
            $tblSportsType->load(array("name" => $key));
            $tblSportsType->name = $key;
            $tblSportsType->icon = JPATH::clean('images/com_joomleague/database/sport_types/' . $name . '.png');
            if (!$tblSportsType->store()) {
                //echo($tblSportsType->getError());
                $status = 2;
            }
            JFolder::create(JPATH::clean(JPATH_ROOT . '/images/com_joomleague/database/events/' . $name));
        }
    }
    return $status;
}
Esempio n. 5
0
 /**
  * Method to preprocess the form for modules
  *
  * @param   JForm  $form  A form object.
  * @param   mixed  $data  The data expected for the form.
  *
  * @return  JForm
  *
  * @since   1.6
  * @throws  Exception if there is an error loading the form.
  */
 public static function preprocessFormMenu(JForm $form, $data)
 {
     jimport('joomla.filesystem.path');
     $link = $data->link;
     $type = $data->type;
     $formFile = false;
     // Initialise form with component view params if available.
     if ($type == 'component') {
         $link = htmlspecialchars_decode($link);
         // Parse the link arguments.
         $args = array();
         parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);
         // Confirm that the option is defined.
         $option = '';
         $base = '';
         if (isset($args['option'])) {
             // The option determines the base path to work with.
             $option = $args['option'];
             $base = JPATH_SITE . '/components/' . $option;
         }
         // Confirm a view is defined.
         $formFile = false;
         if (isset($args['view'])) {
             $view = $args['view'];
             // Determine the layout to search for.
             if (isset($args['layout'])) {
                 $layout = $args['layout'];
             } else {
                 $layout = 'default';
             }
             $formFile = false;
             // Check for the layout XML file. Use standard xml file if it exists.
             $tplFolders = array($base . '/views/' . $view . '/tmpl', $base . '/view/' . $view . '/tmpl');
             $path = JPath::find($tplFolders, $layout . '.xml');
             if (is_file($path)) {
                 $formFile = $path;
             }
             // If custom layout, get the xml file from the template folder
             // template folder is first part of file name -- template:folder
             if (!$formFile && strpos($layout, ':') > 0) {
                 $temp = explode(':', $layout);
                 $templatePath = JPATH::clean(JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $option . '/' . $view . '/' . $temp[1] . '.xml');
                 if (is_file($templatePath)) {
                     $formFile = $templatePath;
                 }
             }
         }
         // Now check for a view manifest file
         if (!$formFile) {
             if (isset($view)) {
                 $metadataFolders = array($base . '/view/' . $view, $base . '/views/' . $view);
                 $metaPath = JPath::find($metadataFolders, 'metadata.xml');
                 if (is_file($path = JPath::clean($metaPath))) {
                     $formFile = $path;
                 }
             } else {
                 // Now check for a component manifest file
                 $path = JPath::clean($base . '/metadata.xml');
                 if (is_file($path)) {
                     $formFile = $path;
                 }
             }
         }
         $lang = JFactory::getLanguage();
         $lang->load($option, JPATH_BASE, null, false, false) || $lang->load($option, JPATH_BASE . "/components/" . $option, null, false, false) || $lang->load($option, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($option, JPATH_BASE . "/components/" . $option, $lang->getDefault(), false, false);
     }
     if ($formFile) {
         // If an XML file was found in the component, load it first.
         // We need to qualify the full path to avoid collisions with component file names.
         if ($form->loadFile($formFile, true, '/metadata') == false) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Now load the component params.
     // TODO: Work out why 'fixing' this breaks JForm
     if ($isNew = false) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $option . '/config.xml');
     } else {
         $path = 'null';
     }
     if (is_file($path)) {
         // Add the component params last of all to the existing form.
         if (!$form->load($path, true, '/config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the specific type file
     if (!$form->loadFile('item_' . $type, false, false)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     return $form;
 }
Esempio n. 6
0
 public function apply($id)
 {
     jimport('joomla.client.github');
     jimport('joomla.client.curl');
     $table = JTable::getInstance('tests', 'PatchTesterTable');
     $github = new JGithub();
     $pull = $github->pulls->get($this->getState('github_user'), $this->getState('github_repo'), $id);
     if (is_null($pull->head->repo)) {
         throw new Exception(JText::_('COM_PATCHTESTER_REPO_IS_GONE'));
     }
     $patch = JCurl::getAdapter($pull->diff_url)->fetch()->body;
     $files = $this->parsePatch($patch);
     foreach ($files as $file) {
         if ($file->action == 'deleted' && !file_exists(JPATH_ROOT . '/' . $file->old)) {
             throw new Exception(sprintf(JText::_('COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S'), $file->old));
         }
         if ($file->action == 'added' || $file->action == 'modified') {
             // if the backup file already exists, we can't apply the patch
             if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->new) . '.txt')) {
                 throw new Exception(sprintf(JText::_('COM_PATCHTESTER_CONFLICT_S'), $file->new));
             }
             if ($file->action == 'modified' && !file_exists(JPATH_ROOT . '/' . $file->old)) {
                 throw new Exception(sprintf(JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old));
             }
             $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . $pull->head->ref . '/' . $file->new;
             $file->body = JCurl::getAdapter($url)->fetch()->body;
         }
     }
     // at this point, we have ensured that we have all the new files and there are no conflicts
     foreach ($files as $file) {
         // we only create a backup if the file already exists
         if ($file->action == 'deleted' || file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified') {
             if (!JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')) {
                 throw new Exception(sprintf('Can not copy file %s to %s', JPATH_ROOT . '/' . $file->old, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'));
             }
         }
         switch ($file->action) {
             case 'modified':
             case 'added':
                 if (!JFile::write(JPath::clean(JPATH_ROOT . '/' . $file->new), $file->body)) {
                     throw new Exception(sprintf('Can not write the file: %s', JPATH_ROOT . '/' . $file->new));
                 }
                 break;
             case 'deleted':
                 if (!JFile::delete(JPATH::clean(JPATH_ROOT . '/' . $file->old))) {
                     throw new Exception(sprintf('Can not delete the file: %s', JPATH_ROOT . '/' . $file->old));
                 }
                 break;
         }
     }
     $table->pull_id = $pull->number;
     $table->data = json_encode($files);
     $table->patched_by = JFactory::getUser()->id;
     $table->applied = 1;
     $version = new JVersion();
     $table->applied_version = $version->getShortVersion();
     if (!$table->store()) {
         throw new Exception($table->getError());
     }
     return true;
 }
Esempio n. 7
0
File: item.php Progetto: akksi/jcg
 /**
  * @param	object	$form	A form object.
  * @param	mixed	$data	The data expected for the form.
  *
  * @return	void
  * @since	1.6
  * @throws	Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // Initialise variables.
     $link = $this->getState('item.link');
     $type = $this->getState('item.type');
     $formFile = false;
     // Initialise form with component view params if available.
     if ($type == 'component') {
         $link = htmlspecialchars_decode($link);
         // Parse the link arguments.
         $args = array();
         parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);
         // Confirm that the option is defined.
         $option = '';
         $base = '';
         if (isset($args['option'])) {
             // The option determines the base path to work with.
             $option = $args['option'];
             $base = JPATH_SITE . '/components/' . $option;
         }
         // Confirm a view is defined.
         $formFile = false;
         if (isset($args['view'])) {
             $view = $args['view'];
             // Determine the layout to search for.
             if (isset($args['layout'])) {
                 $layout = $args['layout'];
             } else {
                 $layout = 'default';
             }
             $formFile = false;
             // Check for the layout XML file. Use standard xml file if it exists.
             $path = JPath::clean($base . '/views/' . $view . '/tmpl/' . $layout . '.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             }
             // if custom layout, get the xml file from the template folder
             // template folder is first part of file name -- template:folder
             if (!$formFile && strpos($layout, ':') > 0) {
                 $temp = explode(':', $layout);
                 $templatePath = JPATH::clean(JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $option . '/' . $view . '/' . $temp[1] . '.xml');
                 if (JFile::exists($templatePath)) {
                     $formFile = $templatePath;
                 }
             }
         }
         //Now check for a view manifest file
         if (!$formFile) {
             $path = JPath::clean($base . '/views/metadata.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             } else {
                 //Now check for a component manifest file
                 $path = JPath::clean($base . '/metadata.xml');
                 if (JFile::exists($path)) {
                     $formFile = $path;
                 }
             }
         }
     }
     if ($formFile) {
         // If an XML file was found in the component, load it first.
         // We need to qualify the full path to avoid collisions with component file names.
         if ($form->loadFile($formFile, true, '/metadata') == false) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/metadata/layout/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $helpLoc = trim((string) $help[0]['local']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
             $this->helpLocal = $helpLoc == 'true' || $helpLoc == '1' || $helpLoc == 'local' ? true : false;
         }
     }
     // Now load the component params.
     // TODO: Work out why 'fixing' this breaks JForm
     if ($isNew = false) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $option . '/config.xml');
     } else {
         $path = 'null';
     }
     if (JFile::exists($path)) {
         // Add the component params last of all to the existing form.
         if (!$form->load($path, true, '/config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the specific type file
     if (!$form->loadFile('item_' . $type, false, false)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data);
 }
 /**
  * @param    object $form A form object.
  * @param    mixed  $data The data expected for the form.
  *
  * @return    void
  * @since       1.1.0
  * @throws    Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     $data = $data instanceof JRegistry ? $data : new JRegistry($data);
     $fieldType = $data->get('type', $this->getState($this->getName() . '.type'));
     $typeMode = $data->get('type_mode', FieldsandfiltersModes::getModeName($data->get('mode', $this->getState($this->getName() . '.mode')), FieldsandfiltersModes::MODE_NAME_TYPE));
     try {
         if ($fieldType && $typeMode && ($type = FieldsandfiltersFactory::getTypes()->getTypes(true)->get($fieldType))) {
             $path = $type->forms->get($typeMode, new JObject())->get('path');
             $form::addFormPath($path);
             if (!$form->loadFile($typeMode, true, '/metadata/form/*')) {
                 throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
             }
             if ($layoutType = $data->get('params.type.' . $typeMode . '_layout', $this->getState($this->getName() . '.layoutType'))) {
                 $paths = array(JPath::clean(JPATH_PLUGINS . '/' . $type->type . '/' . $type->name . '/tmpl/' . $typeMode));
                 if (strpos($layoutType, ':') > 0 && strpos($layoutType, '_:') !== 0) {
                     list($template, $layoutType) = explode(':', $layoutType);
                     $paths[] = JPATH::clean(JPATH_SITE . '/templates/' . $template . '/html/plg_' . $type->type . '_' . $type->name . '/' . $typeMode);
                 }
                 $path = JPath::find($paths, $layoutType . '.xml');
                 if (is_file($path)) {
                     if (!$form->loadFile($path, true, '/form/*')) {
                         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
                     }
                 }
             }
             // load plugin language
             KextensionsLanguage::load('plg_' . $type->type . '_' . $type->name, JPATH_ADMINISTRATOR);
         }
         $contentTypeId = $data->get('content_type_id', $this->getState($this->getName() . '.content_type_id'));
         $extensionForm = $data->get('extension_form', 'extension');
         // get extension type objet by type id or plugin type
         if ($contentTypeId && ($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByTypeID($contentTypeId, true, true)->get($contentTypeId))) {
             $path = $extension->forms->get($extensionForm, new JObject())->get('path');
             $form::addFormPath($path);
             if (!$form->loadFile($extensionForm, true, '/metadata/form/*')) {
                 throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
             }
             // load plugin language
             KextensionsLanguage::load('plg_' . $extension->type . '_' . $extension->name, JPATH_ADMINISTRATOR);
         }
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return;
     }
     // overwrite the mode default of the plugin type mode
     $form->setFieldAttribute('mode', 'default', FieldsandfiltersModes::getMode($form->getFieldAttribute('mode', 'value', 'field.text', 'properties')));
     // Trigger the default form events.
     parent::preprocessForm($form, $data, $group);
 }
Esempio n. 9
0
    /**
     *
     * static method which return a <img> tag with the given picture
     * @param string $picture
     * @param string $alttext
     * @param int $width=40, if set to 0 the original picture width will be used
     * @param int $height=40, if set to 0 the original picture height will be used
     * @param int $type=0, 0=player, 1=club logo big, 2=club logo medium, 3=club logo small, 4=icon, 5=team, 6=small flag, 7=big flag
     * @return string
     */
    public static function getPictureThumb($picture, $alttext, $width = 40, $height = 40, $type = 0)
    {
        $ret = "";
        $picturepath = JPath::clean(JPATH_SITE . '/' . str_replace(JPATH_SITE . '/', '', $picture));
        $params = JComponentHelper::getParams('com_joomleague');
        $ph_player = $params->get('ph_player', 0);
        $ph_logo_big = $params->get('ph_logo_big', 0);
        $ph_logo_medium = $params->get('ph_logo_medium', 0);
        $ph_logo_small = $params->get('ph_logo_small', 0);
        $ph_icon = $params->get('ph_icon', 0);
        $ph_team = $params->get('ph_team', 0);
        $ph_flag_small = $params->get('ph_flag_small', 0);
        $ph_flag_big = $params->get('ph_flag_big', 0);
        if (!file_exists($picturepath) || $picturepath == JPATH_SITE . '/') {
            //setup the different placeholders
            switch ($type) {
                case 0:
                    //player
                    $picture = $ph_player;
                    break;
                case 1:
                    //club logo big
                    $picture = $ph_logo_big;
                    break;
                case 2:
                    //club logo medium
                    $picture = $ph_logo_medium;
                    break;
                case 3:
                    //club logo small
                    $picture = $ph_logo_small;
                    break;
                case 4:
                    //icon
                    $picture = $ph_icon;
                    break;
                case 5:
                    //team picture
                    $picture = $ph_team;
                    break;
                case 6:
                    //small flag picture
                    $picture = $ph_flag_small;
                    break;
                case 7:
                    //big flag picture
                    $picture = $ph_flag_big;
                    break;
                default:
                    $picture = null;
                    break;
            }
        }
        if (!empty($picture) && is_file(JPath::clean(JPATH_SITE . '/' . str_replace(JPATH_SITE . '/', '', $picture)))) {
            $params = JComponentHelper::getParams('com_joomleague');
            $format = "JPG";
            //PNG is not working in IE8
            $format = $params->get('thumbformat', 'PNG');
            $bUseThumbLib = $params->get('usethumblib', false);
            $useThumbCache = $params->get('usethumbnailcache', false);
            // Set vars to check if thumbnailcreation is needed
            list($source_width, $source_height) = getimagesize(JPath::clean(JPATH_SITE . '/' . str_replace(JPATH_SITE . '/', '', $picture)));
            $needthumb = 1;
            // Check if thumbnailcreation with phpThumb is really needed
            if ($height == $source_height && $width == $source_width) {
                $needthumb = 0;
            } elseif ($height == 0 && $width == $source_width) {
                $needthumb = 0;
            } elseif ($height == $source_height && $width == 0) {
                $needthumb = 0;
            } elseif ($height == 0 && $width == 0) {
                $needthumb = 0;
            }
            // End Check
            if ($bUseThumbLib && $needthumb == 1 && $useThumbCache == 0 && file_exists($picturepath)) {
                try {
                    $thumb = PhpThumbFactory::create($picturepath);
                    $thumb->setFormat($format);
                    //height and width set, resize it with the thumblib
                    if ($height > 0 && $width > 0) {
                        $thumb->resize($width, $height);
                        $pic = $thumb->getImageAsString();
                        $ret .= '<img src="data:image/' . $format . ';base64,' . base64_encode($pic);
                        $ret .= '" alt="' . $alttext . '" title="' . $alttext . '"/>';
                    }
                    //height==0 and width set, let the browser resize it
                    if ($height == 0 && $width > 0) {
                        $thumb->setMaxWidth($width);
                        $pic = $thumb->getImageAsString();
                        $ret .= '<img src="data:image/' . $format . ';base64,' . base64_encode($pic);
                        $ret .= '" width="' . $width . '" alt="' . $alttext . '" title="' . $alttext . '"/>';
                    }
                    //width==0 and height set, let the browser resize it
                    if ($height > 0 && $width == 0) {
                        $thumb->setMaxHeight($height);
                        $pic = $thumb->getImageAsString();
                        $ret .= '<img src="data:image/' . $format . ';base64,' . base64_encode($pic);
                        $ret .= '" height="' . $height . '" alt="' . $alttext . '" title="' . $alttext . '"/>';
                    }
                    //width==0 and height==0, use original picture size
                    if ($height == 0 && $width == 0) {
                        $thumb->setMaxHeight($height);
                        $pic = $thumb->getImageAsString();
                        $ret .= '<img src="data:image/' . $format . ';base64,' . base64_encode($pic);
                        $ret .= '" alt="' . $alttext . '" title="' . $alttext . '"/>';
                    }
                } catch (Exception $e) {
                    $ret = '';
                }
            } elseif ($useThumbCache == 0) {
                $picturepath = $picture;
                $picture = JUri::root(true) . '/' . str_replace(JPATH_SITE . '/', "", $picture);
                $title = $alttext;
                //height and width set, let the browser resize it
                $bUseHighslide = $params->get('use_highslide', false);
                // no highslide if the source picture has exact the same size as the parameters width/height
                // e.g placeholders or correct sized images
                if (function_exists('getimagesize') && JFile::exists($picturepath) && $width > 0 && $height > 0) {
                    list($iWidth, $iHeight, $type, $attr) = getimagesize($picturepath);
                    $bUseHighslide = $width != $iWidth && $iHeight != $height ? true : false;
                }
                $arrNoHighSlidePicTypes = array(3, 4, 6, 7, 99);
                if ($bUseHighslide && !in_array($type, $arrNoHighSlidePicTypes)) {
                    $title .= ' (' . JText::_('COM_JOOMLEAGUE_GLOBAL_CLICK_TO_ENLARGE') . ')';
                    $ret .= '<a onclick="return hs.expand(this)" href="' . $picture . '" class="highslide">';
                }
                $ret .= '<img ';
                $ret .= ' ';
                if ($height > 0 && $width > 0) {
                    $ret .= ' src="' . $picture;
                    $ret .= '" width="' . $width . '" height="' . $height . '"
							alt="' . $alttext . '" title="' . $title . '"';
                }
                //height==0 and width set, let the browser resize it
                if ($height == 0 && $width > 0) {
                    $ret .= ' src="' . $picture;
                    $ret .= '" width="' . $width . '" alt="' . $alttext . '" title="' . $title . '"';
                }
                //width==0 and height set, let the browser resize it
                // @todo check! // 23-07-2015
                // added "style="height:'.$height.'px;"" to have a smaller output of the image
                // in persons-view. The template css did overrule the image height.
                if ($height > 0 && $width == 0) {
                    $ret .= ' src="' . $picture;
                    $ret .= '" height="' . $height . '" style="height:' . $height . 'px;" alt="' . $alttext . '" title="' . $title . '"';
                }
                //width==0 and height==0, use original picture size
                if ($height == 0 && $width == 0) {
                    $ret .= ' src="' . $picture;
                    $ret .= '" alt="' . $alttext . '" title="' . $title . '"';
                }
                $ret .= '/>';
                if ($bUseHighslide && !in_array($type, $arrNoHighSlidePicTypes)) {
                    $ret .= '</a>';
                }
            }
            // Use phpThumb to create cached images and check if the source-file really exists
            $picturepath = JPath::clean(JPATH_SITE . '/' . str_replace(JPATH_SITE . '/', '', $picture));
            if ($bUseThumbLib && $useThumbCache == 1 && file_exists($picturepath)) {
                $thumb_cache = PhpThumbFactory::create($picturepath);
                $thumb_cache->setFormat($format);
                if ($needthumb == 1) {
                    // check if the cache-directory exitst if not create one
                    $image_path_parts = pathinfo($picture);
                    $image_cache_path = JPATH::clean(JPATH_SITE . '/cache/joomleague/' . $image_path_parts[dirname]);
                    if (!file_exists($image_cache_path)) {
                        mkdir($image_cache_path, 0750, true);
                    }
                    // check if there is a chached actual image if not, create one
                    $image_timestamp = date("mdY_His", filectime($picturepath));
                    $cached_thumb = JPATH::clean(JPATH_SITE . '/cache/joomleague/' . $image_path_parts[dirname] . '/' . $image_timestamp . '_' . $height . '_' . $width . '_' . $image_path_parts[filename] . '.' . $format);
                    $web_cached_thumb = JUri::root(true) . '/' . str_replace(JPATH_SITE . '/', "", $cached_thumb);
                    if (!file_exists($cached_thumb)) {
                        // Check if there is are older files. If Yes, delete them.
                        $matches = glob(JPATH::clean(JPATH_SITE . '/cache/joomleague/' . $image_path_parts[dirname] . '/' . '*_' . $height . '_' . $width . '_' . $image_path_parts[filename] . '*'));
                        foreach ($matches as $delete_matches) {
                            unlink($delete_matches);
                        }
                        //height and width set
                        if ($height > 0 && $width > 0) {
                            $thumb_cache->adaptiveResize($width, $height)->save($cached_thumb, $format);
                        }
                        //height==0 and width set
                        if ($height == 0 && $width > 0) {
                            $thumb_cache->resize($width, 0)->save($cached_thumb, $format);
                        }
                        //width==0 and height set
                        if ($height > 0 && $width == 0) {
                            $thumb_cache->resize(0, $height)->save($cached_thumb, $format);
                        }
                        //width==0 and height==0, do nothing
                        if ($height == 0 && $width == 0) {
                            $web_cached_thumb = JUri::root(true) . '/' . str_replace(JPATH_SITE . '/', "", $picture);
                        }
                    }
                } else {
                    $web_cached_thumb = JUri::root(true) . '/' . str_replace(JPATH_SITE . '/', "", $picture);
                }
                // If windows Server is used, replace backslashes with slashes befor return.
                $web_cached_thumb = str_replace('\\', '/', $web_cached_thumb);
                // return cached or uncached (if not necessary) images
                $title = $alttext;
                $bUseHighslide = $params->get('use_highslide', false);
                // no highslide if the source picture has exact the same size as the parameters width/height
                // e.g placeholders or correct sized images
                if (function_exists('getimagesize') && JFile::exists($picturepath) && $width > 0 && $height > 0) {
                    list($iWidth, $iHeight, $type, $attr) = getimagesize($picturepath);
                    $bUseHighslide = $width != $iWidth && $iHeight != $height ? true : false;
                }
                $arrNoHighSlidePicTypes = array(3, 4, 6, 7, 99);
                if ($bUseHighslide && !in_array($type, $arrNoHighSlidePicTypes)) {
                    $title .= ' (' . JText::_('COM_JOOMLEAGUE_GLOBAL_CLICK_TO_ENLARGE') . ')';
                    $ret .= '<a onclick="return hs.expand(this)" href="' . $picture . '" class="highslide">';
                }
                $ret .= '<img ';
                $ret .= ' ';
                if ($height > 0 && $width > 0) {
                    $ret .= ' src="' . $web_cached_thumb;
                    $ret .= '" width="' . $width . '" height="' . $height . '"
							alt="' . $alttext . '" title="' . $title . '"';
                }
                //height==0 and width set, let the browser resize it
                if ($height == 0 && $width > 0) {
                    $ret .= ' src="' . $web_cached_thumb;
                    $ret .= '" width="' . $width . '" alt="' . $alttext . '" title="' . $title . '"';
                }
                //width==0 and height set, let the browser resize it
                if ($height > 0 && $width == 0) {
                    $ret .= ' src="' . $web_cached_thumb;
                    $ret .= '" height="' . $height . '" alt="' . $alttext . '" title="' . $title . '"';
                }
                //width==0 and height==0, use original picture size
                if ($height == 0 && $width == 0) {
                    $ret .= ' src="' . $web_cached_thumb;
                    $ret .= '" alt="' . $alttext . '" title="' . $title . '"';
                }
                $ret .= '/>';
                if ($bUseHighslide && !in_array($type, $arrNoHighSlidePicTypes)) {
                    $ret .= '</a>';
                }
            }
        }
        return $ret;
    }
Esempio n. 10
0
    private function _install($update = false, $parent)
    {
        echo JHtml::_('sliders.start', 'steps', array('allowAllClose' => true, 'startTransition' => true, true));
        $image = '<img src="../media/com_joomleague/jl_images/ext_com.png">';
        echo JHtml::_('sliders.panel', $image . ' Component', 'panel-component');
        ?>
		<h2>Welcome to JoomLeague!</h2>
		<img
			src="../media/com_joomleague/jl_images/joomleague_logo.png"
			alt="JoomLeague" title="JoomLeague" />
		<?php 
        $this->install_admin_rootfolder = JPATH::clean($parent->getParent()->getPath('source') . '/admin');
        $this->install_rootfolder = $parent->getParent()->getPath('source');
        $this->debug = false;
        $maxExecutionTime = $maxInputTime = 900;
        if ((int) ini_get('max_execution_time') < $maxExecutionTime) {
            @set_time_limit($maxExecutionTime);
        }
        if ((int) ini_get('max_input_time') < $maxInputTime) {
            @set_time_limit($maxInputTime);
        }
        $time_start = microtime(true);
        // slider - database
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Database', 'panel-database');
        include_once $this->install_admin_rootfolder . '/models/databasetools.php';
        if ($update) {
            // self::updateDatabase();
        }
        if ($update) {
            $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
            echo JHtml::_('sliders.panel', $image . ' Migrate Picture Pathes', 'panel-picpath');
            // JoomleagueModelDatabaseTools::migratePicturePath();
            echo JHtml::_('sliders.panel', $image . ' Update Eventtypes Suspensions', 'panel-picpath');
            // JoomleagueModelDatabaseTools::updateEventtypeSuspensions();
        }
        // slider - imagefolder
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Create/Update Images Folders', 'panel-images');
        self::createImagesFolder();
        // slider - basicData
        $image = '<img src="../media/com_joomleague/jl_images/ext_esp.png">';
        echo JHtml::_('sliders.panel', $image . ' Basic Data', 'panel-basicdata');
        include_once $this->install_rootfolder . '/site/joomleague.core.php';
        include_once $this->install_admin_rootfolder . '/assets/updates/jl_install.php';
        // slider - modules
        $image = '<img src="../media/com_joomleague/jl_images/ext_mod.png">';
        echo JHtml::_('sliders.panel', $image . ' Modules', 'panel-modules');
        // self::installModules();
        // slider - plugins
        $image = '<img src="../media/com_joomleague/jl_images/ext_plugin.png">';
        echo JHtml::_('sliders.panel', $image . ' Plugins', 'panel-plugins');
        // self::installPlugins();
        self::installPermissions();
        echo JHtml::_('sliders.end');
        echo self::getFxInitJSCode('steps');
        ?>
		
		<hr />
		<br>Click on <a href="index.php?option=com_installer&view=discover&task=discover.refresh">Discover-&gt;Refresh</a> to discover new or updated Modules and Plugins.
	<?php 
        $time_end = microtime(true);
        $time = $time_end - $time_start;
        echo '<hr />';
        if ($this->debug) {
            echo '<br>Overall Duration: ' . round($time) . 's<br>';
        }
    }
Esempio n. 11
0
 public static function getPath($userid = null, $folderType = 'user')
 {
     $config = CFactory::getConfig();
     if (!$userid) {
         $my = CFactory::getUser();
         $userid = $my->id;
     }
     $prefix = $folderType == 'original' ? ORIGINAL_VIDEO_FOLDER_NAME : VIDEO_FOLDER_NAME;
     $isThumb = $folderType == 'thumb' ? '/' . VIDEO_THUMB_FOLDER_NAME : '';
     $folder = JPATH_ROOT . '/' . $config->get('videofolder') . '/' . $prefix . '/' . $userid . $isThumb;
     $folder = JPATH::clean($folder);
     return $folder;
 }
 /**
  * Method to add a new sportstype if not already exists
  *
  * @access	private
  * @return	boolean	True on success
  * @since	1.5
  **/
 function addSportsType($newsportstype)
 {
     //check if sportstype exists. If not add a new sportstype to table
     $query = "SELECT * FROM #__joomleague_sport_type WHERE name=" . $this->_db->Quote($newsportstype);
     $this->_db->setQuery($query);
     $sportstypeObject = $this->_db->loadObject();
     if ($sportstypeObject->id) {
         //sportstype already exists
         return $sportstypeObject->id;
     }
     JFolder::create(JPATH::clean(JPATH_ROOT . '/images/com_joomleague/database/events/' . JFolder::makesafe($name)));
     //sportstype does NOT exist and has to be created
     $p_sportstype =& $this->getTable();
     $p_sportstype->set('name', $newsportstype);
     if (!$p_sportstype->store()) {
         $sportstypeObject->id = 0;
     } else {
         $sportstypeObject->id = $this->_db->insertid();
         //mysql_insert_id();
     }
     return $sportstypeObject->id;
 }
Esempio n. 13
0
 public function upload()
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $my = $this->plugin->get('user');
     $creatorType = JRequest::getVar('creatortype', VIDEO_USER_TYPE);
     $groupid = $creatorType == VIDEO_GROUP_TYPE ? JRequest::getInt('groupid', 0) : 0;
     $config = CFactory::getConfig();
     CFactory::load('helpers', 'videos');
     CFactory::load('libraries', 'videos');
     $redirect = CVideosHelper::getVideoReturnUrlFromRequest();
     // Process according to video creator type
     if (!empty($groupid)) {
         CFactory::load('helpers', 'group');
         $allowManageVideos = CGroupHelper::allowManageVideo($groupid);
         $creatorType = VIDEO_GROUP_TYPE;
         $videoLimit = $config->get('groupvideouploadlimit');
         CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__);
     } else {
         $creatorType = VIDEO_USER_TYPE;
         $videoLimit = $config->get('videouploadlimit');
     }
     // Check is video upload is permitted
     CFactory::load('helpers', 'limits');
     if (CLimitsHelper::exceededVideoUpload($my->id, $creatorType)) {
         $message = JText::sprintf('CC VIDEOS CREATION REACH LIMIT', $videoLimit);
         $this->setError($message);
         return false;
     }
     if (!$config->get('enablevideos')) {
         $this->setError(JText::_('CC VIDEO DISABLED', 'notice'));
         return false;
     }
     if (!$config->get('enablevideosupload')) {
         $this->setError(JText::_('CC VIDEO UPLOAD DISABLED', 'notice'));
         return false;
     }
     // Check if the video file is valid
     $files = JRequest::get('files');
     $videoFile = !empty($files['video']) ? $files['video'] : array();
     if (empty($files) || empty($videoFile['name']) && $videoFile['size'] < 1) {
         $this->setError(JText::_('CC VIDEO UPLOAD ERROR', 'error'));
         return false;
     }
     // Check file type.
     $fileType = $videoFile['type'];
     // Override from iphone
     $fileType = 'video/quicktime';
     $allowable = CVideosHelper::getValidMIMEType();
     if (!in_array($fileType, $allowable)) {
         $this->setError(JText::sprintf('CC VIDEO FILE TYPE NOT SUPPORTED', $fileType));
         return false;
     }
     // Check if the video file exceeds file size limit
     $uploadLimit = $config->get('maxvideouploadsize') * 1024 * 1024;
     $videoFileSize = sprintf("%u", filesize($videoFile['tmp_name']));
     if ($uploadLimit > 0 && $videoFileSize > $uploadLimit) {
         $this->setError(JText::sprintf('CC VIDEO FILE SIZE EXCEEDED', $uploadLimit));
         return false;
     }
     // Passed all checking, attempt to save the video file
     CFactory::load('helpers', 'file');
     $folderPath = CVideoLibrary::getPath($my->id, 'original');
     $randomFileName = CFileHelper::getRandomFilename($folderPath, $videoFile['name'], '');
     $destination = JPATH::clean($folderPath . DS . $randomFileName);
     if (!CFileHelper::upload($videoFile, $destination)) {
         $this->setError(JText::_('CC VIDEO UPLOAD FAILED', 'error'));
         return false;
     }
     $config = CFactory::getConfig();
     $videofolder = $config->get('videofolder');
     CFactory::load('models', 'videos');
     $video = JTable::getInstance('Video', 'CTable');
     $video->set('path', $videofolder . '/originalvideos/' . $my->id . '/' . $randomFileName);
     $video->set('title', JRequest::getVar('title'));
     $video->set('description', JRequest::getVar('description'));
     $video->set('category_id', JRequest::getInt('category', 0, 'post'));
     $video->set('permissions', JRequest::getInt('privacy', 0, 'post'));
     $video->set('creator', $my->id);
     $video->set('creator_type', $creatorType);
     $video->set('groupid', $groupid);
     $video->set('filesize', $videoFileSize);
     if (!$video->store()) {
         $this->setError(JText::_('CC VIDEO SAVE ERROR', 'error'));
         return false;
     }
     // Trigger for onVideoCreate
     $this->_triggerEvent('onVideoCreate', $video);
     // Video saved, redirect
     return $video;
 }
Esempio n. 14
0
    require_once JPATH_LIBRARIES . '/joomla/environment/uri.php';
} else {
    require_once JPATH_LIBRARIES . '/joomla/uri/uri.php';
}
require_once JPATH_LIBRARIES . '/joomla/filesystem/file.php';
require_once JPATH_LIBRARIES . '/joomla/log/log.php';
require_once JPATH_LIBRARIES . '/joomla/log/entry.php';
$pos = $post_string;
$file = JURI::getInstance()->toString();
$pieces = explode('/', $file);
$count = count($pieces);
$file = $pieces[$count - 1];
$pieces = explode('?', $file);
$file = $pieces[0];
//$file	= str_replace( JURI::root() , '', $file); var_dump($file);
$file = JPATH::clean(JPATH_BASE . '/' . urldecode($file));
$fileName = JFile::getName($file);
if (!JFile::exists($file)) {
    echo 'file not found: ' . $fileName;
    exit;
}
$fh = fopen($file, 'rb') or die('cannot open file: ' . $fileName);
$fileSize = filesize($file) - ($pos > 0 ? $pos + 1 : 0);
fseek($fh, $pos);
$binary_header = strtoupper(JFile::getExt($file)) . pack('C', 1) . pack('C', 1) . pack('N', 9) . pack('N', 9);
session_cache_limiter('none');
JResponse::clearHeaders();
JResponse::setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true);
JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
JResponse::setHeader('Pragma', 'no-cache', true);
Esempio n. 15
0
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'base' . DS . 'object.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'environment' . DS . 'request.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'environment' . DS . 'response.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'environment' . DS . 'uri.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'filter' . DS . 'filterinput.php';
require_once JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
$pos = JRequest::getVar('target', 0);
$file = JURI::getInstance()->toString();
$pieces = explode('/', $file);
$count = count($pieces);
$file = $pieces[$count - 1];
$pieces = explode('?', $file);
$file = $pieces[0];
//$file	= str_replace( JURI::root() , '', $file); var_dump($file);
$file = JPATH::clean(JPATH_BASE . DS . base64_decode($file));
$fileName = JFile::getName($file);
if (!JFile::exists($file)) {
    echo 'file not found: ' . $fileName;
    exit;
}
$fh = fopen($file, 'rb') or die('cannot open file: ' . $fileName);
$fileSize = filesize($file) - ($pos > 0 ? $pos + 1 : 0);
fseek($fh, $pos);
$binary_header = strtoupper(JFile::getExt($file)) . pack('C', 1) . pack('C', 1) . pack('N', 9) . pack('N', 9);
session_cache_limiter('none');
JResponse::clearHeaders();
JResponse::setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true);
JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
JResponse::setHeader('Pragma', 'no-cache', true);
Esempio n. 16
0
 function _getParcomAndSuffixFilePath()
 {
     $parcom = JPATH::clean($this->params->get('pathfile')) . 'parmcom' . '.' . $this->params->get('payment_solution_name');
     return $parcom;
 }
 /**
  * Extract pictures from zip
  *
  * @param int $catid id of destination category
  */
 function Upload_Batch($catid)
 {
     $config = Joom_getConfig();
     $mainframe =& JFactory::getApplication('administrator');
     $database =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $debugoutput = '';
     if (JFolder::exists(JPATH::clean(JPATH_ROOT . DS . $config->jg_pathtemp))) {
         $temp_dir = $config->jg_pathtemp;
     } else {
         $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=batchupload', JText::_('JGA_ERROR_TEMP_MISSING'), 'error');
     }
     //include zip class
     require_once JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
     //check existence of uploaded zip
     if (!JFile::exists($this->zippack["tmp_name"])) {
         $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=batchupload', JText::_('JGA_ERROR_FILE_NOT_UPLOADED'), 'error');
     }
     //make temp path writeable if it is not, workaround for servers with wwwrun-problem
     if (!is_writeable(JPath::clean(JPATH_ROOT . DS . $temp_dir))) {
         Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $temp_dir), 0777);
         $permissions_changed = true;
     }
     //Create ZIP object, make array containing file info, and extract files to temporary location
     $this->zippack = $this->zippack["tmp_name"];
     $zipfile = new PclZip($this->zippack);
     $ziplist = $zipfile->extract(PCLZIP_OPT_PATH, JPath::clean(JPATH_ROOT . DS . $temp_dir), PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_BY_PREG, "/^(.*).((jpg)|(JPG)|(jpeg)|(JPEG)|(jpe)|(JPE)|(png)|(PNG)|(gif)|(GIF))\$/");
     //set back temp path permissions if they were changed before
     if (isset($permissions_changed)) {
         Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $temp_dir), 0755);
     }
     //check error code of extraction
     if ($zipfile->error_code != 1) {
         $ziperror = str_replace("'", "", $zipfile->errorInfo());
         $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=batchupload', $ziperror, 'error');
     }
     $sizeofzip = sizeof($ziplist);
     //For each file extracted from zip get original filename and create unique filename
     //copy to new location, delete file in temp. location, make thumbnail and add to database
     $debugoutput .= '<hr />';
     $debugoutput .= $sizeofzip . ' ' . JText::_('JGA_FILES_IN_BATCH');
     $debugoutput .= '<hr />';
     usort($ziplist, "Joom_SortBatch");
     $ziplist = array_reverse($ziplist);
     //Path of category
     $catpath = Joom_GetCatPath($catid);
     for ($i = 0; $i < $sizeofzip; $i++) {
         //get the filename without path, JFile::getName() does not
         //work on local installations
         $filepathinfos = pathinfo($ziplist[$i]['filename']);
         $origfilename = $filepathinfos["basename"];
         $fileextension = strtolower(JFile::getExt($origfilename));
         //check the possible available memory for picture resizing
         //if not available echo error message and continue with next picture
         if ($this->Upload_CheckMemory($debugoutput, JPATH_ROOT . DS . $temp_dir . $origfilename, $fileextension) == false) {
             $this->debug = true;
             continue;
         }
         //Check for path exploits, and replace spaces
         if ($config->jg_useorigfilename) {
             $compacttitle = Joom_FixFilename($origfilename, 1);
         } else {
             $compacttitle = Joom_FixFilename($this->gentitle);
         }
         //get the serial number if use of original name is deactivated
         //and numbering is activated
         if (!$config->jg_useorigfilename && $config->jg_filenamenumber) {
             $picserial = $this->Upload_GetSerial($sizeofzip);
             $newfilename = $this->Upload_GenFilename($compacttitle, $fileextension, $picserial);
         } else {
             $newfilename = $this->Upload_GenFilename($compacttitle, $fileextension);
         }
         $debugoutput .= '<hr />' . "\n";
         $debugoutput .= JText::_('JGA_FILENAME') . ': ';
         $debugoutput .= "{$origfilename} <br />\n";
         $debugoutput .= JText::_('JGA_NEW_FILENAME') . ": {$newfilename} <br />";
         //Move the picture from temp. folder to originals folder
         $returnval = JFile::move($temp_dir . DS . $origfilename, $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT);
         if (!$returnval) {
             $debugoutput .= JText::_('JGA_PROBLEM_COPYING') . ': ' . JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages) . '. ' . JText::_('JGA_CHECK_PERMISSIONS');
             $this->debug = 1;
             continue;
         }
         //Set permissions to 644
         $returnval = Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename));
         if (!$returnval) {
             $debugoutput .= JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename . ' ' . JText::_('JGA_CHECK_PERMISSIONS');
             $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, null);
             $this->debug = 1;
             continue;
         }
         $debugoutput .= JText::_('JGA_UPLOAD_START') . '<br />';
         $debugoutput .= JText::_('JGA_UPLOAD_COMPLETE') . '<br />';
         //Create the thumb from original picture
         $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality);
         if (!$returnval) {
             $debugoutput .= JText::_('JGA_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename;
             $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
             $this->debug = 1;
             continue;
         }
         $debugoutput .= JText::_('JGA_THUMBNAIL_CREATED') . '<br />';
         //Create the detail picture from original
         if ($config->jg_resizetomaxwidth) {
             $returnval = Joom_ResizeImage($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true);
             if (!$returnval) {
                 $debugoutput .= JText::_('JGA_WRONG_FILENAME') . ': ' . JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename;
                 $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, null, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
                 $this->debug = 1;
                 continue;
             }
             $debugoutput .= JText::_('JGA_RESIZED_TO_MAXWIDTH') . '...<br />';
         } else {
             //Otherwise only copy the picture from original to detail
             $returnval = JFile::copy($config->jg_pathoriginalimages . $catpath . $newfilename, $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT);
             if (!$returnval) {
                 $debugoutput .= JText::_('JGA_PROBLEM_COPYING ') . $config->jg_pathimages . $catpath . $newfilename;
                 $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
                 $this->debug = 1;
                 continue;
             }
             $returnval = Joom_Chmod(JPath::clean(JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename));
             if (!$returnval) {
                 $debugoutput .= JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename . ' ' . JText::_('JGA_CHECK_PERMISSIONS');
                 $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
                 $this->debug = 1;
                 continue;
             }
         }
         if ($config->jg_delete_original == 1 || $config->jg_delete_original == 2 && $this->original_delete == 1) {
             //Delete original if setted in backend
             $returnval = JFile::delete(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename);
             if (!$returnval) {
                 $debugoutput .= JText::_('JGA_PROBLEM_DELETING_ORIGINAL') . ': ' . JPath::clean(JPATH_ROOT . DS . $config->jg_pathoriginalimages) . ' ' . JText::_('JGA_CHECK_PERMISSIONS');
                 $this->Upload_Rollback($debugoutput, null, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
                 $this->debug = 1;
                 continue;
             }
             $debugoutput .= JText::_('JGA_ORIGINAL_DELETED') . '<br />';
         }
         //New entry for ordering
         $ordering = $this->Upload_GetOrdering($config->jg_uploadorder, $catid);
         if ($config->jg_useorigfilename) {
             $fileextensionlength = strlen($fileextension);
             $filenamelength = strlen($origfilename);
             $imgname = substr($origfilename, -$filenamelength, -$fileextensionlength - 1);
         } else {
             if ($config->jg_filenamenumber) {
                 $imgname = $this->gentitle . $this->imgname_separator . $picserial;
             } else {
                 $imgname = $this->gentitle;
             }
         }
         $batchtime = mktime();
         $database->setQuery("INSERT INTO #__joomgallery(id, catid, imgtitle, imgauthor,\n          imgtext, imgdate, imgcounter, imgvotes,\n          imgvotesum, published, imgfilename, imgthumbname,\n          checked_out,owner,approved, ordering)\n          VALUES\n          (NULL, '{$catid}', '{$imgname}', '{$this->photocred}',\n          '{$this->gendesc}', '{$batchtime}', '0', '0',\n          '0', '1', '{$newfilename}', '{$newfilename}',\n          '0', '" . $user->get('id') . "', 1, '{$ordering}')");
         if (!$database->query()) {
             $debugoutput .= $database->getErrorMsg();
             $this->Upload_Rollback($debugoutput, JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $newfilename, JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $newfilename);
             $this->debug = 1;
             continue;
         }
     }
     $debugoutput .= '<hr /><br />' . "\n";
     if (!$this->debug) {
         $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=batchupload', JText::_('JGA_UPLOAD_SUCCESSFULL'));
     } else {
         echo $debugoutput;
     }
 }
Esempio n. 18
0
 /**
  * Method to add a new sportstype if not already exists
  *
  * @access	private
  * @return	boolean	True on success
  **/
 function addSportsType($newSportsTypeName)
 {
     $path = JPATH::clean(JPATH_ROOT . '/images/com_joomleague/database/events/' . JFolder::makesafe($newSportsTypeName));
     if (!JFolder::exists($path)) {
         JFolder::create($path);
     }
     // SportsType does NOT exist and has to be created
     $tblSportsType = $this->getTable();
     $tblSportsType->load(array('name' => $newSportsTypeName));
     $tblSportsType->name = $newSportsTypeName;
     $tblSportsType->store();
     return $tblSportsType->id;
 }
Esempio n. 19
0
 /**
  * @param	object	$form	A form object.
  * @param	mixed	$data	The data expected for the form.
  *
  * @return	void
  * @since	1.6
  * @throws	Exception if there is an error in the form event.
  */
 protected function preprocessForm(JForm $form, $data, $group = 'content')
 {
     // Initialise variables.
     $link = $this->getState('item.link');
     $type = $this->getState('item.type');
     $formFile = false;
     // Initialise form with component view params if available.
     if ($type == 'component') {
         $link = htmlspecialchars_decode($link);
         // Parse the link arguments.
         $args = array();
         parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);
         // Confirm that the option is defined.
         $option = '';
         $base = '';
         if (isset($args['option'])) {
             // The option determines the base path to work with.
             $option = $args['option'];
             $base = JPATH_SITE . '/components/' . $option;
         }
         // Confirm a view is defined.
         $formFile = false;
         if (isset($args['view'])) {
             $view = $args['view'];
             // Determine the layout to search for.
             if (isset($args['layout'])) {
                 $layout = $args['layout'];
             } else {
                 $layout = 'default';
             }
             $formFile = false;
             // Check for the layout XML file. Use standard xml file if it exists.
             $path = JPath::clean($base . '/views/' . $view . '/tmpl/' . $layout . '.xml');
             if (JFile::exists($path)) {
                 $formFile = $path;
             }
             // if custom layout, get the xml file from the template folder
             // template folder is first part of file name -- template:folder
             if (!$formFile && strpos($layout, ':') > 0) {
                 $temp = explode(':', $layout);
                 $templatePath = JPATH::clean(JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $option . '/' . $view . '/' . $temp[1] . '.xml');
                 if (JFile::exists($templatePath)) {
                     $formFile = $templatePath;
                 }
             }
         }
         //Now check for a view manifest file
         if (!$formFile) {
             if (isset($view) && JFile::exists($path = JPath::clean($base . '/views/' . $view . '/metadata.xml'))) {
                 $formFile = $path;
             } else {
                 //Now check for a component manifest file
                 $path = JPath::clean($base . '/metadata.xml');
                 if (JFile::exists($path)) {
                     $formFile = $path;
                 }
             }
         }
     }
     if ($formFile) {
         // If an XML file was found in the component, load it first.
         // We need to qualify the full path to avoid collisions with component file names.
         if ($form->loadFile($formFile, true, '/metadata') == false) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Attempt to load the xml file.
         if (!($xml = simplexml_load_file($formFile))) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
         // Get the help data from the XML file if present.
         $help = $xml->xpath('/metadata/layout/help');
         if (!empty($help)) {
             $helpKey = trim((string) $help[0]['key']);
             $helpURL = trim((string) $help[0]['url']);
             $helpLoc = trim((string) $help[0]['local']);
             $this->helpKey = $helpKey ? $helpKey : $this->helpKey;
             $this->helpURL = $helpURL ? $helpURL : $this->helpURL;
             $this->helpLocal = $helpLoc == 'true' || $helpLoc == '1' || $helpLoc == 'local' ? true : false;
         }
     }
     // Now load the component params.
     // TODO: Work out why 'fixing' this breaks JForm
     if ($isNew = false) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $option . '/config.xml');
     } else {
         $path = 'null';
     }
     if (JFile::exists($path)) {
         // Add the component params last of all to the existing form.
         if (!$form->load($path, true, '/config')) {
             throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
         }
     }
     // Load the specific type file
     if (!$form->loadFile('item_' . $type, false, false)) {
         throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
     }
     // Association menu items
     if (JFactory::getApplication()->get('menu_associations', 0)) {
         $languages = JLanguageHelper::getLanguages('lang_code');
         $addform = new JXMLElement('<form />');
         $fields = $addform->addChild('fields');
         $fields->addAttribute('name', 'associations');
         $fieldset = $fields->addChild('fieldset');
         $fieldset->addAttribute('name', 'item_associations');
         $fieldset->addAttribute('description', 'COM_MENUS_ITEM_ASSOCIATIONS_FIELDSET_DESC');
         $add = false;
         foreach ($languages as $tag => $language) {
             if ($tag != $data['language']) {
                 $add = true;
                 $field = $fieldset->addChild('field');
                 $field->addAttribute('name', $tag);
                 $field->addAttribute('type', 'menuitem');
                 $field->addAttribute('language', $tag);
                 $field->addAttribute('label', $language->title);
                 $field->addAttribute('translate_label', 'false');
                 $option = $field->addChild('option', 'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE');
                 $option->addAttribute('value', '');
             }
         }
         if ($add) {
             $form->load($addform, false);
         }
     }
     // Trigger the default form events.
     parent::preprocessForm($form, $data);
 }
Esempio n. 20
0
 /**
  * This function will regenerate the thumbnail of videos
  * @param int $id
  * @param bool $returnThumb
  * @return bool
  */
 public function _fetchThumbnail($id = 0, $returnThumb = false)
 {
     if (!COwnerHelper::isRegisteredUser()) {
         return;
     }
     if (!$id) {
         return false;
     }
     $table = JTable::getInstance('Video', 'CTable');
     $table->load($id);
     $config = CFactory::getConfig();
     if ($table->type == 'file') {
         // We can only recreate the thumbnail for local video file only
         // it's not possible to process remote video file with ffmpeg
         if ($table->storage != 'file') {
             $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . 'FFmpeg cannot process remote video.');
             return false;
         }
         $videoLib = new CVideoLibrary();
         $videoFullPath = JPATH::clean(JPATH_ROOT . '/' . $table->path);
         if (!JFile::exists($videoFullPath)) {
             return false;
         }
         // Read duration
         $videoInfo = $videoLib->getVideoInfo($videoFullPath);
         if (!$videoInfo) {
             return false;
         } else {
             $videoFrame = CVideosHelper::formatDuration((int) ($videoInfo['duration']['sec'] / 2), 'HH:MM:SS');
             // Create thumbnail
             $oldThumb = $table->thumb;
             $thumbFolder = CVideoLibrary::getPath($table->creator, 'thumb');
             $thumbSize = CVideoLibrary::thumbSize();
             $thumbFilename = $videoLib->createVideoThumb($videoFullPath, $thumbFolder, $videoFrame, $thumbSize);
         }
         if (!$thumbFilename) {
             return false;
         }
     } else {
         if (!CRemoteHelper::curlExists()) {
             $this->setError(JText::_('COM_COMMUNITY_CURL_NOT_EXISTS'));
             return false;
         }
         $videoLib = new CVideoLibrary();
         $videoObj = $videoLib->getProvider($table->path);
         if ($videoObj == false) {
             $this->setError($videoLib->getError());
             return false;
         }
         if (!$videoObj->isValid()) {
             $this->setError($videoObj->getError());
             return false;
         }
         $remoteThumb = $videoObj->getThumbnail();
         $thumbData = CRemoteHelper::getContent($remoteThumb, true);
         if (empty($thumbData)) {
             $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $remoteThumb);
             return false;
         }
         // split the header and body
         list($headers, $body) = explode("\r\n\r\n", $thumbData, 2);
         preg_match('/Content-Type: image\\/(.*)/i', $headers, $matches);
         if (!empty($matches)) {
             $thumbPath = CVideoLibrary::getPath($table->creator, 'thumb');
             $thumbFileName = CFileHelper::getRandomFilename($thumbPath);
             $tmpThumbPath = $thumbPath . '/' . $thumbFileName;
             if (!JFile::write($tmpThumbPath, $body)) {
                 $this->setError(JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST') . ': ' . $thumbFileName);
                 return false;
             }
             // We'll remove the old or none working thumbnail after this
             $oldThumb = $table->thumb;
             // Get the image type first so we can determine what extensions to use
             $info = getimagesize($tmpThumbPath);
             $mime = image_type_to_mime_type($info[2]);
             $thumbExtension = CImageHelper::getExtension($mime);
             $thumbFilename = $thumbFileName . $thumbExtension;
             $thumbPath = $thumbPath . '/' . $thumbFilename;
             if (!JFile::move($tmpThumbPath, $thumbPath)) {
                 $this->setError(JText::_('WARNFS_ERR02') . ': ' . $thumbFileName);
                 return false;
             }
             // Resize the thumbnails
             //CImageHelper::resizeProportional( $thumbPath , $thumbPath , $mime , CVideoLibrary::thumbSize('width') , CVideoLibrary::thumbSize('height') );
             list($width, $height) = explode('x', $config->get('videosThumbSize'));
             CImageHelper::resizeAspectRatio($thumbPath, $thumbPath, $width, $height);
         } else {
             $this->setError(JText::_('COM_COMMUNITY_PHOTOS_IMAGE_NOT_PROVIDED_ERROR'));
             return false;
         }
     }
     // Update the DB with new thumbnail
     $thumb = $config->get('videofolder') . '/' . VIDEO_FOLDER_NAME . '/' . $table->creator . '/' . VIDEO_THUMB_FOLDER_NAME . '/' . $thumbFilename;
     $table->set('thumb', $thumb);
     $table->store();
     // If this video storage is not on local, we move it to remote storage
     // and remove the old thumb if existed
     if ($table->storage != 'file') {
         // && ($table->storage == $storageType))
         $config = CFactory::getConfig();
         $storageType = $config->getString('videostorage');
         $storage = CStorage::getStorage($storageType);
         $storage->delete($oldThumb);
         $localThumb = JPATH::clean(JPATH_ROOT . '/' . $table->thumb);
         $tempThumbname = JPATH::clean(JPATH_ROOT . '/' . md5($table->thumb));
         if (JFile::exists($localThumb)) {
             JFile::copy($localThumb, $tempThumbname);
         }
         if (JFile::exists($tempThumbname)) {
             $storage->put($table->thumb, $tempThumbname);
             JFile::delete($localThumb);
             JFile::delete($tempThumbname);
         }
     } else {
         if (JFile::exists(JPATH_ROOT . '/' . $oldThumb)) {
             JFile::delete(JPATH_ROOT . '/' . $oldThumb);
         }
     }
     if ($returnThumb) {
         return $table->getThumbnail();
     }
     return true;
 }
Esempio n. 21
0
 /**
  * Install a dependency.
  *
  * @param   object  $extension  Object containing extension details.
  *
  * @return  void
  */
 public function installExtension($extension)
 {
     // Get application object
     isset($this->app) or $this->app = JFactory::getApplication();
     // Get database object
     $db = JFactory::getDbo();
     $q = $db->getQuery(true);
     // Build query to get dependency installation status
     $q->select('manifest_cache, custom_data');
     $q->from('#__extensions');
     $q->where("element = '{$extension->name}'");
     $q->where("type = '{$extension->type}'");
     $extension->type != 'plugin' or $q->where("folder = '{$extension->folder}'");
     // Execute query
     $db->setQuery($q);
     if ($status = $db->loadObject()) {
         // Initialize variables
         $jVersion = new JVersion();
         $manifest = json_decode($status->manifest_cache);
         // Get information about the dependency to be installed
         $xml = JPATH::clean($extension->source . '/' . $extension->name . '.xml');
         if (is_file($xml) and $xml = simplexml_load_file($xml)) {
             if ($jVersion->RELEASE == (string) $xml['version'] and version_compare($manifest->version, (string) $xml->version, '<')) {
                 // The dependency to be installed is newer than the existing one, mark for update
                 $doInstall = true;
             }
             if ($jVersion->RELEASE != (string) $xml['version'] and version_compare($manifest->version, (string) $xml->version, '<=')) {
                 // The dependency to be installed might not newer than the existing one but Joomla version is difference, mark for update
                 $doInstall = true;
             }
         }
     } elseif (isset($extension->source)) {
         // The dependency to be installed not exist, mark for install
         $doInstall = true;
     }
     if (isset($doInstall) and $doInstall) {
         // Install dependency
         $installer = new JInstaller();
         if (!$installer->install($extension->source)) {
             $this->app->enqueueMessage(sprintf('Error installing "%s" %s', $extension->name, $extension->type), 'error');
         } else {
             $this->app->enqueueMessage(sprintf('Install "%s" %s was successfull', $extension->name, $extension->type));
             // Update dependency status
             $this->updateExtension($extension);
             // Build query to get dependency installation status
             $q = $db->getQuery(true);
             $q->select('manifest_cache, custom_data');
             $q->from('#__extensions');
             $q->where("element = '{$extension->name}'");
             $q->where("type = '{$extension->type}'");
             $extension->type != 'plugin' or $q->where("folder = '{$extension->folder}'");
             $db->setQuery($q);
             // Load dependency installation status
             $status = $db->loadObject();
         }
     }
     // Update dependency tracking
     if (isset($status)) {
         $ext = isset($this->name) ? $this->name : substr($this->app->input->getCmd('option'), 4);
         $dep = !empty($status->custom_data) ? (array) json_decode($status->custom_data) : array();
         // Backward compatible: move all dependency data from params to custom_data column
         if (is_array($params = (isset($extension->params) and $extension->params != '{}') ? (array) json_decode($extension->params) : null)) {
             foreach (array('imageshow', 'poweradmin', 'sample') as $com) {
                 if ($com != $ext and isset($params[$com])) {
                     $dep[] = $com;
                 }
             }
         }
         // Update dependency list
         in_array($ext, $dep) or $dep[] = $ext;
         $status->custom_data = array_unique($dep);
         // Build query to update dependency data
         $q = $db->getQuery(true);
         $q->update('#__extensions');
         $q->set("custom_data = '" . json_encode($status->custom_data) . "'");
         // Backward compatible: keep data in this column for older product to recognize
         $manifestCache = json_decode($status->manifest_cache);
         $manifestCache->dependency = $status->custom_data;
         $q->set("manifest_cache = '" . json_encode($manifestCache) . "'");
         // Backward compatible: keep data in this column also for another old product to recognize
         $params = is_array($params) ? array_merge($params, array_combine($status->custom_data, $status->custom_data)) : array_combine($status->custom_data, $status->custom_data);
         $q->set("params = '" . json_encode($params) . "'");
         $q->where("element = '{$extension->name}'");
         $q->where("type = '{$extension->type}'");
         $extension->type != 'plugin' or $q->where("folder = '{$extension->folder}'");
         $db->setQuery($q);
         $db->execute();
     }
 }
Esempio n. 22
0
 /**
  * @param $id video id
  * @param $videoName videoname
  * Delete the original video if there is a callback from zencoder notification
  * @return bool
  */
 public function zencoderCallback($id, $videoName)
 {
     $video = JTable::getInstance('Video', 'CTable');
     $video->load($id);
     $videoNameChunk = explode('.', $videoName);
     // little security to prevent ".."
     //to make sure the video is in s3
     if ($video->storage == 's3' && $video->status == 'ready' && count($videoNameChunk) == 2) {
         $videoIn = JPATH::clean(JPATH_ROOT . '/' . CFactory::getConfig()->get('videofolder') . '/' . ORIGINAL_VIDEO_FOLDER_NAME . '/' . $video->creator . '/' . $videoName);
         $deleteOriginal = CFactory::getConfig()->get('deleteoriginalvideos');
         if ($deleteOriginal) {
             JFile::delete($videoIn);
             return true;
         }
     }
     return false;
 }
Esempio n. 23
0
					<?php 
    }
    ?>
					<div class="span<?php 
    echo round(12 / $columns);
    ?>
">
							<span class="upsell-product-image">
							<?php 
    $thumb_image = '';
    if (isset($upsell_product->thumb_image) && $upsell_product->thumb_image) {
        $thumb_image = $upsell_product->thumb_image;
    }
    ?>
			   				<?php 
    if (isset($thumb_image) && JFile::exists(JPATH::clean(JPATH_SITE . '/' . $thumb_image))) {
        ?>
			   					<img alt="<?php 
        echo $upsell_product->product_name;
        ?>
" class="j2store-product-thumb-image-<?php 
        echo $upsell_product->j2store_product_id;
        ?>
"  src="<?php 
        echo JUri::root() . JPath::clean($thumb_image);
        ?>
" />
						   	<?php 
    }
    ?>
	
Esempio n. 24
0
 public function _processVideoStorage($updateNum = 5)
 {
     $config = CFactory::getConfig();
     $jconfig = JFactory::getConfig();
     $videoStorage = $config->getString('videostorage');
     CFactory::load('libraries', 'storage');
     CFactory::load('models', 'videos');
     CFactory::load('helpers', 'videos');
     $db = JFactory::getDBO();
     $query = ' SELECT * FROM ' . $db->nameQuote('#__community_videos') . ' WHERE ' . $db->nameQuote('storage') . ' != ' . $db->quote($videoStorage) . ' AND ' . $db->nameQuote('status') . ' = ' . $db->quote('ready') . ' ORDER BY rand() limit ' . $updateNum;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         $this->message[] = JText::_('No Videos to transfer.');
         return;
     }
     $storage = CStorage::getStorage($videoStorage);
     $tempFolder = $jconfig->getValue('tmp_path');
     $fileTransferCount = 0;
     foreach ($result as $videoEntry) {
         $currentStorage = CStorage::getStorage($videoEntry->storage);
         if ($videoEntry->type == 'file') {
             // If it exist on current storage, we can transfer it to preferred storage
             if ($currentStorage->exists($videoEntry->path)) {
                 // File exist on remote storage, move it locally first
                 $tempFilename = JPATH::clean($tempFolder . DS . md5($videoEntry->path));
                 $tempThumbname = JPATH::clean($tempFolder . DS . md5($videoEntry->thumb));
                 $currentStorage->get($videoEntry->path, $tempFilename);
                 $currentStorage->get($videoEntry->thumb, $tempThumbname);
                 if (JFile::exists($tempFilename) && JFile::exists($tempThumbname)) {
                     // we assume thumbnails is always there
                     // put both video and thumbnails remotely
                     if ($storage->put($videoEntry->path, $tempFilename) && $storage->put($videoEntry->thumb, $tempThumbname)) {
                         // if the put is successful, update storage type
                         $video = JTable::getInstance('Video', 'CTable');
                         $video->load($videoEntry->id);
                         $video->storage = $videoStorage;
                         $video->store();
                         // remove files on storage and temporary files
                         $currentStorage->delete($videoEntry->path);
                         $currentStorage->delete($videoEntry->thumb);
                         JFile::delete($tempFilename);
                         JFile::delete($tempThumbname);
                         $fileTransferCount++;
                     }
                 }
             }
         } else {
             // This is for non-upload video file type e.g. YouTube etc
             // We'll just process the video thumbnail only
             if ($currentStorage->exists($videoEntry->thumb)) {
                 $tempThumbname = JPATH::clean($tempFolder . DS . md5($videoEntry->thumb));
                 $currentStorage->get($videoEntry->thumb, $tempThumbname);
                 if (JFile::exists($tempThumbname)) {
                     if ($storage->put($videoEntry->thumb, $tempThumbname)) {
                         $video = JTable::getInstance('Video', 'CTable');
                         $video->load($videoEntry->id);
                         $video->storage = $videoStorage;
                         $video->store();
                         $currentStorage->delete($videoEntry->thumb);
                         JFile::delete($tempThumbname);
                         $fileTransferCount++;
                     }
                 }
             }
         }
     }
     $this->message[] = $fileTransferCount . ' video file(s) transferred';
 }