Пример #1
0
function shLoadPluginLanguage($pluginName, $language, $defaultString, $path = '')
{
    // V 1.2.4.m
    global $sh_LANG;
    // load the Language File
    $path = JString::rtrim($path, DS) . DS;
    $path = $path == DS ? sh404SEF_ADMIN_ABS_PATH . 'language' . DS . 'plugins' . DS : $path;
    if (shFileExists($path . $pluginName . '.php')) {
        include_once $path . $pluginName . '.php';
    } else {
        JError::RaiseWarning(500, 'sh404SEF - missing language file for plugin ' . $pluginName . '.');
    }
    if (!isset($sh_LANG[$language][$defaultString])) {
        return 'en';
    } else {
        return $language;
    }
}
Пример #2
0
    $sql = "INSERT INTO `#__extensions` ( `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state` ) VALUES ('System - jsecure', 'plugin','jsecure', 'system', 0,1,1,0,'', '','', '', 0, '0000-00-00 00:00:00',0,0);";
    $database->setQuery($sql);
    $database->query();
    $session =& JFactory::getSession();
    $session->set('jSecureAuthentication', 1);
} else {
    if ($r1 === true) {
        JFile::delete(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . 'jsecure.php');
    }
    if ($r2 === true) {
        JFile::delete(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . 'jsecure.xml');
    }
    JFile::delete(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . '404.html');
    JFile::delete(JPATH_ADMINISTRATOR . '/' . 'language' . '/' . 'en-GB' . '/' . 'en-GB.plg_system_jsecure.ini');
    deleteDir(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . 'jsecure/');
    JError::RaiseWarning(500, JText::_('Could not install jsecure system plugin'));
}
if (file_exists(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . 'jsecure' . '/' . 'jsecure.php') && file_exists(JPATH_ROOT . '/' . 'plugins' . '/' . 'system' . '/' . 'jsecure' . '/' . 'jsecure' . '/' . 'jsecure.class.php')) {
    deleteDir(JPATH_ADMINISTRATOR . '/' . 'components' . '/' . 'com_jsecure' . '/' . 'sysplugin/');
} else {
    echo '<strong><font color="red">Sorry, something went wrong while installing jsecure on your web site. Please try uninstalling first, then check permissions on your file system, and make sure Joomla can write to the /plugin directory. Or contact your site administrator for assistance. <br>You can also report this on our website at <a target="_blank" href="#" >our support forum.</a></font>';
}
function deleteDir($dir)
{
    if ($handle = opendir($dir)) {
        $array = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . $file)) {
                    if (!@rmdir($dir . $file)) {
                        deleteDir($dir . $file . '/');
Пример #3
0
/**
 * Insert in the db the previously retrieved parameters for a plugin
 * including publication information. Also move files as required
 *
 * @param string $basePath , the base path to get original files from
 * @param array $shConfig an array holding the database parameters of the plugin
 * @param array $files, an array holding list of files from the plugin
 */
function shInsertPlugin($basePath, $shConfig, $files, $folders, $foldersToCopy)
{
    // check data
    if (empty($files)) {
        return;
    }
    // move the files to target location
    $result = array();
    $resultFolders = array();
    $success = true;
    // create folders as needed
    if (!empty($folders)) {
        foreach ($folders as $folder) {
            $success = $success && JFolder::create(JPATH_ROOT . DS . 'plugins' . DS . $folder);
        }
    }
    // copy raw folders as needed
    if (!empty($foldersToCopy)) {
        foreach ($foldersToCopy as $folder) {
            $success = $success && JFolder::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder, JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder, $path = '', $forced = true);
            $result[$folder] = $success;
        }
    }
    // now move files across
    if ($success) {
        foreach ($files as $pluginFile) {
            $target = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $pluginFile);
            $source = JPath::clean($basePath . DS . $pluginFile);
            $success = $success && true === JFile::copy($source, $target);
            $resultFolders[$pluginFile] = $success;
        }
        // check and add an index.html file if it does not exists
        $target = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . 'index.html');
        if (!JFile::exists($target)) {
            $source = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . 'index.html');
            $success = $success && true === JFile::copy($source, $target);
        }
    }
    // if files moved to destination, setup plugin in Joomla database
    if ($success) {
        $shouldRestore = shShouldRestore();
        if ($shouldRestore) {
            // read stored params from disk
            shGetExtensionSavedParams($shConfig['folder'] . '.' . $shConfig['element'], $shConfig);
        }
        // insert elements in db, but only if it does not exist
        // we can't use insert ignore, as the record may have been modified by user (unpublished, order change)
        $db =& JFactory::getDBO();
        $sql = 'select count(id) from `#__plugins` where ' . ' `element` = ' . $db->Quote($shConfig['element']) . ' and `folder` = ' . $db->Quote($shConfig['folder']);
        $db->setQuery($sql);
        $alreadyInstalled = $db->loadResult();
        if (empty($alreadyInstalled)) {
            $sql = "INSERT INTO `#__plugins` ( `name`, `element`, `folder`, `access`, `ordering`, `published`," . " `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`)" . " VALUES ('{$shConfig['name']}', '{$shConfig['element']}', '{$shConfig['folder']}', '{$shConfig['access']}', '{$shConfig['ordering']}'," . " '{$shConfig['published']}', '{$shConfig['iscore']}', '{$shConfig['client_id']}', '{$shConfig['checked_out']}'," . " '{$shConfig['checked_out_time']}', '{$shConfig['params']}');";
            $db->setQuery($sql);
            $db->query();
            if (!empty($db->getErrorNum)) {
                echo $db->getErrorMsg() . '<br />';
            }
        }
    } else {
        // failure while copying files
        // don't leave anything behind
        foreach ($files as $pluginFile) {
            if (!empty($result[$pluginFile])) {
                // if file was copied, try to delete it
                JFile::delete(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $pluginFile);
            }
        }
        // also delete folders
        if (!empty($resultFolders)) {
            foreach ($resultFolders as $folder) {
                if ($resultFolders[$folder]) {
                    // if file was copied, try to delete it
                    JFolder::delete(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder);
                }
            }
        }
        JError::RaiseWarning(500, JText::_('Could not install plugin'));
    }
    return $success;
}
Пример #4
0
/**
 * Insert in the db the previously retrieved parameters for a plugin
 * including publication information. Also move files as required
 *
 * @param string $basePath , the base path to get original files from
 * @param array $shConfig an array holding the database parameters of the plugin
 * @param array $files, an array holding list of files from the plugin
 */
function shInsertPlugin($basePath, $shConfig, $files, $folders, $foldersToCopy)
{
    // check data
    if (empty($files)) {
        return;
    }
    // move the files to target location
    $result = array();
    $resultFolders = array();
    $success = true;
    // create folders as needed
    if (!empty($folders)) {
        foreach ($folders as $folder) {
            $success = $success && JFolder::create(JPATH_ROOT . DS . 'plugins' . DS . $folder);
        }
    }
    // copy raw folders as needed
    if (!empty($foldersToCopy)) {
        foreach ($foldersToCopy as $folder) {
            $success = $success && JFolder::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder, JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder);
            $result[$folder] = $success;
        }
    }
    // now move files across
    if ($success) {
        foreach ($files as $pluginFile) {
            $target = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $pluginFile);
            $source = JPath::clean($basePath . DS . $pluginFile);
            $success = $success && true === JFile::copy($source, $target);
            $resultFolders[$pluginFile] = $success;
        }
    }
    // if files moved to destination, setup plugin in Joomla database
    if ($success) {
        // read stored params from disk
        shGetExtensionSavedParams($shConfig['folder'] . '.' . $shConfig['element'], $shConfig);
        // insert elements in db
        $db =& JFactory::getDBO();
        $sql = "INSERT INTO `#__plugins` ( `name`, `element`, `folder`, `access`, `ordering`, `published`," . " `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`)" . " VALUES ('{$shConfig['name']}', '{$shConfig['element']}', '{$shConfig['folder']}', '{$shConfig['access']}', '{$shConfig['ordering']}'," . " '{$shConfig['published']}', '{$shConfig['iscore']}', '{$shConfig['client_id']}', '{$shConfig['checked_out']}'," . " '{$shConfig['checked_out_time']}', '{$shConfig['params']}');";
        $db->setQuery($sql);
        $db->query();
    } else {
        // don't leave anything behind
        foreach ($files as $pluginFile) {
            if ($result[$pluginFile]) {
                // if file was copied, try to delete it
                JFile::delete(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $pluginFile);
            }
        }
        // also delete folders
        if (!empty($resultFolders)) {
            foreach ($resultFolders as $folder) {
                if ($resultFolders[$folder]) {
                    // if file was copied, try to delete it
                    JFolder::delete(JPATH_ROOT . DS . 'plugins' . DS . $shConfig['folder'] . DS . $folder);
                }
            }
        }
        JError::RaiseWarning(500, JText::_('Could not install plugin'));
    }
    return $success;
}