Example #1
0
function _proGeneral($gr = 'mod', $ext_name)
{
    $folder = 'exts_dowload_tmp';
    $jversion = null;
    if (!file_exists($folder)) {
        mkdir($folder, 0777);
    }
    if (!defined('_JEXEC')) {
        define('_JEXEC', 1);
    }
    if (!defined('JPATH_PLATFORM')) {
        define('JPATH_PLATFORM', __DIR__);
    }
    if (file_exists('libraries/cms/version/version.php')) {
        if (!class_exists('JVersion')) {
            require_once dirname(__FILE__) . '/libraries/cms/version/version.php';
        }
        $version = new JVersion();
        $jversion = $version->RELEASE;
    }
    $file_name = $ext_name;
    switch ($gr) {
        case 'mod':
            $xml = simplexml_load_file('modules/' . $file_name . '/' . $file_name . '.xml');
            $_file_name = _getVersion($file_name, $jversion, $xml);
            $file_path = $folder . '/' . $_file_name . '.zip';
            $zip = new ZipArchive();
            if ($zip->open($file_path, ZIPARCHIVE::CREATE) === true) {
                if (!file_exists($file_path)) {
                    addAll("modules/" . $file_name . "/", "", $zip);
                }
                $zip->close();
            }
            break;
        case 'pls':
            $path = 'plugins/system/';
            $prefix = '.plg_system_';
        case 'plc':
            if ($gr == 'plc') {
                $path = 'plugins/content/';
                $prefix = '.plg_content_';
            }
        case 'tmp':
            if ($gr == 'tmp') {
                $path = 'templates/';
                $prefix = '.tpl_';
                $folder_plc = $path . $file_name;
                if ($file_name == 'system') {
                    echo 'Can not download this file';
                    exit;
                }
                $xml = simplexml_load_file($folder_plc . '/templateDetails.xml');
            } else {
                $folder_plc = $path . $file_name;
                $xml = simplexml_load_file($folder_plc . '/' . $file_name . '.xml');
            }
            $_file_name = _getVersion($file_name, $jversion, $xml);
            $lag = $xml->languages->language['tag'];
            $folder_lag = $path . $file_name . '/language';
            if ($lag != null && !file_exists($folder_lag)) {
                if ($gr == 'tmp') {
                    $srcfile = 'language/' . $lag . '/' . $lag . $prefix . $file_name . '.ini';
                    $srcfile1 = 'language/' . $lag . '/' . $lag . $prefix . $file_name . '.sys.ini';
                } else {
                    $srcfile = 'administrator/language/' . $lag . '/' . $lag . $prefix . $file_name . '.ini';
                    $srcfile1 = 'administrator/language/' . $lag . '/' . $lag . $prefix . $file_name . '.sys.ini';
                }
                $src_index = $folder_plc . '/index.html';
                $dstfile = $folder_lag . '/' . $lag . '/' . $lag . $prefix . $file_name . '.ini';
                $dstfile1 = $folder_lag . '/' . $lag . '/' . $lag . $prefix . $file_name . '.sys.ini';
                $dh = opendir($folder_plc);
                while (($file = readdir($dh)) !== false) {
                    if ($file !== "." && $file !== "..") {
                        if (!file_exists($folder_lag)) {
                            mkdir($folder_lag, 0777);
                            mkdir($folder_lag . '/' . $lag, 0777);
                            copy($src_index, $folder_lag . '/index.html');
                            copy($src_index, $folder_lag . '/' . $lag . '/index.html');
                            copy($srcfile, $dstfile);
                            copy($srcfile1, $dstfile1);
                        }
                    }
                }
            }
            $file_path = $folder . '/' . $_file_name . '.zip';
            $zip = new ZipArchive();
            if ($zip->open($file_path, ZIPARCHIVE::CREATE) === true) {
                if (!file_exists($file_path)) {
                    addAll($path . $file_name . "/", "", $zip);
                }
                $zip->close();
            }
            break;
        default:
    }
}
Example #2
0
 $conf_link = Horde::link($conf_link, sprintf(_("Configure %s"), $app), '', '', '', sprintf(_("Configure %s"), $app));
 $apps[$i]['sort'] = $registry->getParam('name', $app) . ' (' . $app . ')';
 $apps[$i]['name'] = $conf_link . $apps[$i]['sort'] . '</a>';
 if (!file_exists($path . '/conf.php')) {
     /* No conf.php exists. */
     $apps[$i]['conf'] = $conf_link . $error;
     $apps[$i]['status'] = _("Missing configuration. You have to generate it now if you want to use this application.");
 } else {
     /* A conf.php exists, get the xml version. */
     if (($xml_ver = _getVersion($path . '/conf.xml')) === false) {
         $apps[$i]['conf'] = $conf_link . $warning . '</a>';
         $apps[$i]['status'] = _("No version found in original configuration. Regenerate configuration.");
         continue;
     }
     /* Get the generated php version. */
     if (($php_ver = _getVersion($path . '/conf.php')) === false) {
         /* No version found in generated php, suggest regenarating
          * just in case. */
         $apps[$i]['conf'] = $conf_link . $warning . '</a>';
         $apps[$i]['status'] = _("No version found in your configuration. Regenerate configuration.");
         continue;
     }
     if ($xml_ver != $php_ver) {
         /* Versions are not the same, configuration needs updating. */
         $apps[$i]['conf'] = $conf_link . $error . '</a>';
         $apps[$i]['status'] = _("Configuration needs updating.");
         continue;
     } else {
         /* Configuration is ok. */
         $apps[$i]['conf'] = $conf_link . $success . '</a>';
         $apps[$i]['status'] = _("Application is ready.");