public function display($tpl = null)
 {
     // Page title
     $this->setTitle('Updates');
     // Toolbar options
     JToolBarHelper::custom('refresh', 'preview.png', 'preview_f2.png', 'Refresh', false);
     // Add jQuery for selection effects
     MageBridgeTemplateHelper::load('jquery');
     JHTML::script('media/com_magebridge/js/backend-update.js');
     $update = MAGEBRIDGE_UPDATE_NOTAVAILABLE;
     $component_version = null;
     $data = MageBridgeUpdateHelper::getData();
     foreach ($data as $index => $extension) {
         if (empty($extension['latest_version'])) {
             continue;
         }
         if ($extension['current_version'] != $extension['latest_version']) {
             $update = MAGEBRIDGE_UPDATE_AVAILABLE;
             break;
         } else {
             $update = MAGEBRIDGE_UPDATE_NOTNEEDED;
         }
         $data[$index] = $extension;
     }
     if ($update != MAGEBRIDGE_UPDATE_NOTAVAILABLE) {
         JToolBarHelper::custom('update', 'download.png', 'download_f2.png', 'Update', false);
     }
     if ($update == MAGEBRIDGE_UPDATE_AVAILABLE) {
         JError::raiseNotice('UPDATE', 'There are new updates available');
     }
     $this->assignRef('data', $data);
     $this->assignRef('update', $update);
     parent::display($tpl);
 }
Esempio n. 2
0
 /**
  * Get the version of the MageBridge component
  *
  * @param null
  * @return string
  */
 public static function getComponentVersion()
 {
     static $version = false;
     if ($version == false) {
         $version = MageBridgeUpdateHelper::getCurrentVersion(array('type' => 'component', 'name' => 'com_magebridge'));
     }
     return $version;
 }
Esempio n. 3
0
 public static function getComponentVersion()
 {
     $packages = MageBridgeUpdateHelper::getPackageList();
     foreach ($packages as $package) {
         if ($package['type'] == 'component') {
             return MageBridgeUpdateHelper::getCurrentVersion($package);
         }
     }
 }
 public function display($tpl = null)
 {
     $this->setTitle('Control Panel');
     $lang = JFactory::getLanguage();
     $alignment = $lang->isRTL() ? 'right' : 'left';
     $this->assignRef('alignment', $alignment);
     $icons = array();
     $icons[] = $this->icon('config', 'Configuration', 'config.png');
     $icons[] = $this->icon('stores', 'Store Conditions', 'store.png');
     $icons[] = $this->icon('products', 'Product Relations', 'product.png');
     $icons[] = $this->icon('connectors', 'Connectors', 'connect.png');
     $icons[] = $this->icon('users', 'Users', 'user.png');
     $icons[] = $this->icon('check', 'System Check', 'cpanel.png');
     $icons[] = $this->icon('logs', 'Logs', 'info.png');
     $icons[] = $this->icon('update', 'Update', 'install.png');
     $icons[] = $this->icon('cache', 'Empty Cache', 'trash.png');
     $icons[] = $this->icon('magento', 'Magento Admin', 'magento.png', '_blank');
     $icons[] = $this->icon('tutorials', 'Tutorials', 'tutorials.png', '_blank');
     $icons[] = $this->icon('forum', 'Forum', 'forum.png', '_blank');
     $this->assignRef('icons', $icons);
     //jimport('joomla.html.pane');
     //$pane = JPane::getInstance('sliders');
     //$this->assignRef('pane', $pane);
     $current_version = MageBridgeUpdateHelper::getComponentVersion();
     $this->assignRef('current_version', $current_version);
     $changelog_url = 'http://www.yireo.com/tutorials/magebridge/updates/975-magebridge-changelog';
     $this->assignRef('changelog_url', $changelog_url);
     $jed_url = 'http://extensions.joomla.org/extensions/bridges/e-commerce-bridges/9440';
     $this->assignRef('jed_url', $jed_url);
     $backend_feed = MagebridgeModelConfig::load('backend_feed');
     $this->assignRef('backend_feed', $backend_feed);
     if ($backend_feed == 1) {
         $this->ajax('index.php?option=com_magebridge&view=home&format=ajax&layout=feeds', 'latest_news');
         $this->ajax('index.php?option=com_magebridge&view=home&format=ajax&layout=promotion', 'promotion');
         $document = JFactory::getDocument();
         if (JURI::getInstance()->isSSL() == true) {
             $document->addStylesheet('https://fonts.googleapis.com/css?family=Just+Me+Again+Down+Here');
         } else {
             $document->addStylesheet('http://fonts.googleapis.com/css?family=Just+Me+Again+Down+Here');
         }
     }
     parent::display($tpl);
 }
Esempio n. 5
0
 /**
  * Method to upgrade a specific extension
  *
  * @package MageBridge
  * @access public
  * @param string $exension_name
  * @return bool
  */
 private function update($extension_name = null)
 {
     // Do not continue if the extension name is empty
     if ($extension_name == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_EXTENSION'));
         return false;
     }
     // Fetch a list of available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     foreach ($packages as $package) {
         if ($package['name'] == $extension_name) {
             $extension = $package;
             break;
         }
     }
     // Do not continue if the extension does not appear from the list
     if ($extension == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_UNKNOWN_EXTENSION'));
         return false;
     }
     // Premature check for the component-directory to be writable
     if ($extension['type'] == 'component' && JFactory::getConfig()->get('ftp_enable') == 0) {
         if (is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components/' . $extension['name'])) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components/' . $extension['name']));
             return false;
         } else {
             if (!is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components')) {
                 JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DIR_NOT_WRITABLE', JPATH_ADMINISTRATOR . '/components'));
                 return false;
             }
         }
     }
     // Construct the update URL
     $extension_uri = $extension['name'];
     $extension_uri .= '_j25';
     $extension_uri .= '.' . MagebridgeModelConfig::load('update_format');
     $extension_url = $this->getUrl($extension_uri);
     // Either use fopen() or CURL
     if (ini_get('allow_url_fopen') == 1 && MagebridgeModelConfig::load('update_method') == 'joomla') {
         $package_file = JInstallerHelper::downloadPackage($extension_url, $extension_uri);
     } else {
         $package_file = MageBridgeUpdateHelper::downloadPackage($extension_url, $extension_uri);
     }
     // Simple check for the result
     if ($package_file == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_DOWNLOAD_FAILED', $extension_uri));
         return false;
     }
     // Check if the downloaded file exists
     $tmp_path = JFactory::getConfig()->get('tmp_path');
     $package_path = $tmp_path . '/' . $package_file;
     if (!is_file($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_EXISTS', $package_path));
         return false;
     }
     // Check if the file is readable
     if (!is_readable($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NOT_READABLE', $package_path));
         return false;
     }
     // Check if the downloaded file is abnormally small (so it might just contain a simple warning-text)
     if (filesize($package_path) < 128) {
         $contents = @file_get_contents($package_path);
         if (empty($contents)) {
             JError::raiseWarning('MB', JText::_('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_EMPTY'));
             return false;
         } else {
             if (preg_match('/^Restricted/', $contents)) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_NO_ACCESS'));
                 return false;
             }
         }
         JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_NO_ARCHIVE', $package_path));
         return false;
     }
     // Now we assume this is an archive, so let's unpack it
     $package = JInstallerHelper::unpack($package_path);
     if ($package == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FILE_GONE', $extension['name']));
         return false;
     }
     // Quick workaround to prevent Koowa proxying the database
     if (class_exists('KInput')) {
         KInput::set('option', 'com_installer', 'get');
     }
     // Call the actual installer to install the package
     $installer = JInstaller::getInstance();
     if ($installer->install($package['dir']) == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FAILED', $extension['name']));
         return false;
     }
     // Get the name of downloaded package
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = JFactory::getConfig()->get('tmp_path') . '/' . $package['packagefile'];
     }
     // Clean up the installation
     @JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     // Post install procedure
     if (isset($extension['post_install_query'])) {
         $query = trim($extension['post_install_query']);
         if (!empty($query)) {
             $db = JFactory::getDBO();
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (Exception $e) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_POSTQUERY_FAILED', $db->getErrorMsg()));
                 return false;
             }
             if ($db->getErrorMsg()) {
                 JError::raiseWarning('MB', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_POSTQUERY_FAILED', $db->getErrorMsg()));
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 6
0
 /**
  * Method to do all bridge-based checks
  *
  * @package MageBridge
  * @access public
  * @return null
  */
 public function doBridgeChecks()
 {
     $register = MageBridgeModelRegister::getInstance();
     $bridge = MageBridgeModelBridge::getInstance();
     // First add all the things we need to the bridge
     $version_id = $register->add('version');
     // Build the bridge
     $bridge->build();
     $magebridge_version_magento = $register->getDataById($version_id);
     $magebridge_version_joomla = MageBridgeUpdateHelper::getComponentVersion();
     if (empty($magebridge_version_magento)) {
         $this->addResult('bridge', 'Bridge version', self::CHECK_WARNING, JText::_('CHECK_BRIDGE_NO_VERSION'));
     } else {
         $result = version_compare($magebridge_version_magento, $magebridge_version_joomla, '=') ? self::CHECK_OK : self::CHECK_ERROR;
         $this->addResult('bridge', 'Bridge version', $result, JText::sprintf('CHECK_BRIDGE_VERSION', $magebridge_version_magento, $magebridge_version_joomla));
     }
     $result = MageBridgeModelConfig::load('modify_url') == 1 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('bridge', 'Modify URLs', $result, JText::_('CHECK_BRIDGE_MODIFY_URL'));
     $result = MageBridgeModelConfig::load('link_to_magento') == 0 ? self::CHECK_OK : self::CHECK_WARNING;
     $this->addResult('bridge', 'Link to Magento', $result, JText::_('CHECK_BRIDGE_LINK_TO_MAGENTO'));
     //$result = (defined('MAGEBRIDGE_MODULEHELPER_OVERRIDE') == true) ? self::CHECK_OK : self::CHECK_WARNING;
     //$this->addResult('bridge', 'Modulehelper override', $result, JText::_('CHECK_BRIDGE_MODULEHELPER_OVERRIDE'));
     return;
 }
Esempio n. 7
0
 /**
  * Method to get a User-Agent string for MageBridge
  *
  * @return string
  */
 public function getUserAgentBySystem()
 {
     $user_agent = 'MageBridge ' . MageBridgeUpdateHelper::getComponentVersion();
     $user_agent .= ' (Joomla! ' . MageBridgeHelper::getJoomlaVersion() . ')';
     return $user_agent;
 }
Esempio n. 8
0
 private function update($extension_name = null)
 {
     // Do not continue if the extension name is empty
     if ($extension_name == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('No extension specified'));
         return false;
     }
     // Fetch a list of available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     foreach ($packages as $package) {
         if ($package['name'] == $extension_name) {
             $extension = $package;
             break;
         }
     }
     // Do not continue if the extension does not appear from the list
     if ($extension == null) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('Unknown extension'));
         return false;
     }
     // Premature check for the component-directory to be writable
     if ($extension['type'] == 'component' && JFactory::getConfig()->getValue('ftp_enable') == 0) {
         if (is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components/' . $extension['name'])) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::_('Component directory is not writable'));
             return false;
         } else {
             if (!is_dir(JPATH_ADMINISTRATOR . '/components/' . $extension['name']) && !is_writable(JPATH_ADMINISTRATOR . '/components')) {
                 JError::raiseWarning('SOME_ERROR_CODE', JText::_('Components folder is not writable'));
                 return false;
             }
         }
     }
     // Construct the update URL
     $extension_uri = $extension['name'];
     $extension_uri .= MageBridgeHelper::isJoomla15() ? '_j15' : '_j25';
     $extension_uri .= '.' . MagebridgeModelConfig::load('update_format');
     $extension_url = $this->getUrl($extension_uri);
     // Either use fopen() or CURL
     if (ini_get('allow_url_fopen') == 1 && MagebridgeModelConfig::load('update_method') == 'joomla') {
         $package_file = JInstallerHelper::downloadPackage($extension_url, $extension_uri);
     } else {
         $package_file = MageBridgeUpdateHelper::downloadPackage($extension_url, $extension_uri);
     }
     // Simple check for the result
     if ($package_file == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('Failed to download update for %s', $extension_uri));
         return false;
     }
     // Check if the downloaded file exists
     $tmp_path = JFactory::getConfig()->getValue('config.tmp_path');
     $package_path = $tmp_path . '/' . $package_file;
     if (!is_file($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('File %s does not exist', $package_path));
         return false;
     }
     // Check if the file is readable
     if (!is_readable($package_path)) {
         JError::raiseWarning('MB', JText::sprintf('File %s is not readable', $package_path));
         return false;
     }
     // Check if the downloaded file is abnormally small (so it might just contain a simple warning-text)
     if (filesize($package_path) < 128) {
         $contents = @file_get_contents($package_path);
         if (empty($contents)) {
             JError::raiseWarning('MB', JText::sprintf('Valid archive but empty content.'));
             return false;
         } else {
             if (preg_match('/^Restricted/', $contents)) {
                 JError::raiseWarning('MB', JText::sprintf('Not allowed to access updates.'));
                 return false;
             }
         }
         JError::raiseWarning('MB', JText::sprintf('File %s is not a valid archive', $package_path));
         return false;
     }
     // Now we assume this is an archive, so let's unpack it
     $package = JInstallerHelper::unpack($package_path);
     if ($package == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('Unable to find update for %s on local filesystem', $extension['name']));
         return false;
     }
     // Quick workaround to prevent Koowa proxying the database
     if (class_exists('KInput')) {
         KInput::set('option', 'com_installer', 'get');
     }
     // Call the actual installer to install the package
     $installer = JInstaller::getInstance();
     if ($installer->install($package['dir']) == false) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('Failed to install %s', $extension['name']));
         return false;
     }
     // Get the name of downloaded package
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = JFactory::getConfig()->getValue('config.tmp_path') . '/' . $package['packagefile'];
     }
     // Clean up the installation
     @JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     // Post install procedure
     if (isset($extension['post_install_query'])) {
         $query = trim($extension['post_install_query']);
         if (!empty($query)) {
             $db = JFactory::getDBO();
             $db->setQuery($query);
             $db->query();
             if ($db->getErrorMsg()) {
                 JError::raiseWarning('MB', JText::sprintf('Post install query failed: %s', $db->getErrorMsg()));
                 return false;
             }
         }
     }
     return true;
 }
    die('Illegal access');
}
$_SERVER['HTTP_HOST'] = null;
// System definitions
define('_JEXEC', 1);
define('JPATH_BASE', dirname(dirname(dirname(dirname(__FILE__)))));
defined('_JEXEC') or die;
// Include the Joomla! framework
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
// Initialize Joomla!
$mainframe = JFactory::getApplication('administrator');
$mainframe->initialise();
// Include the needed MageBridge classes
require_once JPATH_SITE . '/components/com_magebridge/helpers/loader.php';
require_once JPATH_ADMINISTRATOR . '/components/com_magebridge/models/update.php';
// Set the hostname to enable license checks
$_SERVER['HTTP_HOST'] = MagebridgeModelConfig::load('host');
// Initialize the updater
$update = new MagebridgeModelUpdate();
$packages = MageBridgeUpdateHelper::getPackageList();
$files = array();
// Add current packages to the update list
foreach ($packages as $package) {
    if (MageBridgeUpdateHelper::getCurrentVersion($package) == true) {
        $files[] = $package['name'];
    }
}
// Perform the actual update
@$update->updateAll($files);
// End
Esempio n. 10
0
 /**
  * Display method
  *
  * @param string $tpl
  * @return null
  */
 public function display($tpl = null)
 {
     // ???
     MageBridgeViewHelper::initialize('UPDATE');
     // Filters - type
     $options = array(array('value' => '', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_NONE')), array('value' => 'module', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE')), array('value' => 'module-site', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE_SITE')), array('value' => 'module-admin', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_MODULE_ADMIN')), array('value' => 'plugin', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN')), array('value' => 'plugin-other', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_OTHER')), array('value' => 'plugin-magebridgeproduct', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_PRODUCT')), array('value' => 'plugin-magebridgestore', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_STORE')), array('value' => 'plugin-magebridgeprofile', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_PROFILE')), array('value' => 'plugin-magebridgenewsletter', 'text' => JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_FILTER_TYPE_PLUGIN_NEWSLETTER')));
     $filter_type = $this->getFilter('type');
     $javascript = 'onchange="document.adminForm.submit();"';
     $this->lists['type'] = JHTML::_('select.genericlist', $options, 'filter_type', $javascript, 'value', 'text', $filter_type);
     // Filters - search
     $filter_search = $this->getFilter('search');
     // Toolbar options
     JToolBarHelper::custom('home', 'back', '', 'LIB_YIREO_VIEW_TOOLBAR_HOME', false);
     JToolBarHelper::custom('refresh', 'preview.png', 'preview_f2.png', 'LIB_YIREO_VIEW_TOOLBAR_REFRESH', false);
     JToolBarHelper::custom('updateQueries', 'archive', '', 'LIB_YIREO_VIEW_TOOLBAR_DBUPGRADE', false);
     // Add jQuery for selection effects
     MageBridgeTemplateHelper::load('jquery');
     $this->addJs('backend-update.js');
     // Load the packages
     $data = MageBridgeUpdateHelper::getData();
     // Add filtering
     if (!empty($filter_type) || !empty($filter_search)) {
         if (!empty($filter_type)) {
             $filter_type = explode('-', $filter_type);
         }
         foreach ($data as $index => $extension) {
             if (!empty($filter_search)) {
                 if (!stristr($extension['name'], $filter_search) && !stristr($extension['title'], $filter_search) && !stristr($extension['description'], $filter_search)) {
                     unset($data[$index]);
                     continue;
                 }
             }
             if (!empty($filter_type)) {
                 if (count($filter_type) == 1) {
                     if ($extension['type'] != $filter_type[0]) {
                         unset($data[$index]);
                         continue;
                     }
                 } else {
                     if ($filter_type[0] == 'module') {
                         if ($extension['type'] != 'module') {
                             unset($data[$index]);
                             continue;
                         } elseif ($extension['type'] != $filter_type[0] || $extension['app'] != $filter_type[1]) {
                             unset($data[$index]);
                             continue;
                         }
                     } elseif ($filter_type[0] == 'plugin') {
                         if ($extension['type'] != 'plugin') {
                             unset($data[$index]);
                             continue;
                         } elseif ($filter_type[1] == 'other' && in_array($extension['group'], array('magebridgeproduct', 'magebridgenewsletter', 'magebridgestore', 'magebridgeprofile'))) {
                             unset($data[$index]);
                             continue;
                         } elseif ($filter_type[1] != 'other' && $extension['group'] != $filter_type[1]) {
                             unset($data[$index]);
                             continue;
                         }
                     }
                 }
             }
         }
     }
     // Detect whether updates are available
     $update = MAGEBRIDGE_UPDATE_NOTAVAILABLE;
     if (!empty($data)) {
         $update = MAGEBRIDGE_UPDATE_NOTNEEDED;
         foreach ($data as $index => $extension) {
             // Skip this entry for version detection
             if (empty($extension['version']) || empty($extension['current_version'])) {
                 continue;
             }
             if ($extension['current_version'] != $extension['version']) {
                 $update = MAGEBRIDGE_UPDATE_AVAILABLE;
                 break;
             }
         }
     }
     if ($update == MAGEBRIDGE_UPDATE_NOTAVAILABLE) {
         JError::raiseWarning('MB', JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_EMPTY_VERSION'));
     } else {
         JToolBarHelper::custom('update', 'download.png', 'download_f2.png', 'Update', false);
     }
     if ($update == MAGEBRIDGE_UPDATE_AVAILABLE) {
         JError::raiseNotice('UPDATE', JText::_('COM_MAGEBRIDGE_VIEW_UPDATE_NEW_VERSIONS'));
     }
     $this->data = $data;
     $this->update = $update;
     $this->search = $filter_search;
     parent::display($tpl);
 }