public function install_extension_confirm()
 {
     if ($_FILES['mod_archive']['error'] != UPLOAD_ERR_OK) {
         switch ($_FILES['mod_archive']['error']) {
             case UPLOAD_ERR_INI_SIZE:
             case UPLOAD_ERR_FORM_SIZE:
                 //					echo gt('The file you uploaded exceeded the size limits for the server.').'<br />';
                 flash('error', gt('The file you uploaded exceeded the size limits for the server.'));
                 break;
             case UPLOAD_ERR_PARTIAL:
                 //					echo gt('The file you uploaded was only partially uploaded.').'<br />';
                 flash('error', gt('The file you uploaded was only partially uploaded.'));
                 break;
             case UPLOAD_ERR_NO_FILE:
                 //					echo gt('No file was uploaded.').'<br />';
                 flash('error', gt('No file was uploaded.'));
                 break;
         }
     } else {
         $basename = basename($_FILES['mod_archive']['name']);
         // Check future radio buttons
         // for now, try auto-detect
         $compression = null;
         $ext = '';
         if (substr($basename, -4, 4) == '.tar') {
             $compression = null;
             $ext = '.tar';
         } else {
             if (substr($basename, -7, 7) == '.tar.gz') {
                 $compression = 'gz';
                 $ext = '.tar.gz';
             } else {
                 if (substr($basename, -4, 4) == '.tgz') {
                     $compression = 'gz';
                     $ext = '.tgz';
                 } else {
                     if (substr($basename, -8, 8) == '.tar.bz2') {
                         $compression = 'bz2';
                         $ext = '.tar.bz2';
                     } else {
                         if (substr($basename, -4, 4) == '.zip') {
                             $compression = 'zip';
                             $ext = '.zip';
                         }
                     }
                 }
             }
         }
         if ($ext == '') {
             //				echo gt('Unknown archive format. Archives must either be regular ZIP files, TAR files, Gzipped Tarballs, or Bzipped Tarballs.').'<br />';
             flash('error', gt('Unknown archive format. Archives must either be regular ZIP files, TAR files, Gzipped Tarballs, or Bzipped Tarballs.'));
         } else {
             // Look for stale sessid directories:
             $sessid = session_id();
             if (file_exists(BASE . "tmp/extensionuploads/{$sessid}") && is_dir(BASE . "tmp/extensionuploads/{$sessid}")) {
                 expFile::removeDirectory("tmp/extensionuploads/{$sessid}");
             }
             $return = expFile::makeDirectory("tmp/extensionuploads/{$sessid}");
             if ($return != SYS_FILES_SUCCESS) {
                 switch ($return) {
                     case SYS_FILES_FOUNDFILE:
                     case SYS_FILES_FOUNDDIR:
                         //							echo gt('Found a file in the directory path when creating the directory to store the files in.').'<br />';
                         flash('error', gt('Found a file in the directory path when creating the directory to store the files in.'));
                         break;
                     case SYS_FILES_NOTWRITABLE:
                         //							echo gt('Destination parent is not writable.').'<br />';
                         flash('error', gt('Destination parent is not writable.'));
                         break;
                     case SYS_FILES_NOTREADABLE:
                         //							echo gt('Destination parent is not readable.').'<br />';
                         flash('error', gt('Destination parent is not readable.'));
                         break;
                 }
             }
             $dest = BASE . "tmp/extensionuploads/{$sessid}/archive{$ext}";
             move_uploaded_file($_FILES['mod_archive']['tmp_name'], $dest);
             if ($compression != 'zip') {
                 // If not zip, must be tar
                 include_once BASE . 'external/Tar.php';
                 $tar = new Archive_Tar($dest, $compression);
                 PEAR::setErrorHandling(PEAR_ERROR_PRINT);
                 $return = $tar->extract(dirname($dest));
                 if (!$return) {
                     //						echo '<br />'.gt('Error extracting TAR archive').'<br />';
                     flash('error', gt('Error extracting TAR archive'));
                 } else {
                     //						header('Location: ' . URL_FULL . 'index.php?module=administrationmodule&action=verify_extension&type=tar');
                     //						self::verify_extension('tar');
                 }
             } else {
                 // must be zip
                 include_once BASE . 'external/Zip.php';
                 $zip = new Archive_Zip($dest);
                 PEAR::setErrorHandling(PEAR_ERROR_PRINT);
                 if ($zip->extract(array('add_path' => dirname($dest))) == 0) {
                     //						echo '<br />'.gt('Error extracting ZIP archive').':<br />';
                     //						echo $zip->_error_code . ' : ' . $zip->_error_string . '<br />';
                     flash('error', gt('Error extracting ZIP archive: ') . $zip->_error_code . ' : ' . $zip->_error_string . '<br />');
                 } else {
                     //						header('Location: ' . URL_FULL . 'index.php?module=administrationmodule&action=verify_extension&type=zip');
                     //						self::verify_extension('zip');
                 }
             }
             $sessid = session_id();
             $files = array();
             foreach (expFile::listFlat(BASE . 'tmp/extensionuploads/' . $sessid, true, null, array(), BASE . 'tmp/extensionuploads/' . $sessid) as $key => $f) {
                 if ($key != '/archive.tar' && $key != '/archive.tar.gz' && $key != '/archive.tar.bz2' && $key != '/archive.zip') {
                     $files[] = array('absolute' => $key, 'relative' => $f, 'canCreate' => expFile::canCreate(BASE . substr($key, 1)), 'ext' => substr($f, -3, 3));
                 }
             }
             assign_to_template(array('relative' => 'tmp/extensionuploads/' . $sessid, 'files' => $files));
         }
     }
 }
示例#2
0
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/** @define "BASE" "../../../../.." */
if (!defined('EXPONENT')) {
    exit('');
}
$dest_dir = $_POST['dest_dir'];
$files = array();
foreach (array_keys($_POST['mods']) as $file) {
    $files[$file] = expFile::canCreate(BASE . 'files/' . $file);
    //	if (class_exists($mod)) {
    //		$files[$mod][0] = call_user_func(array($mod,'name'));
    //	}
    //	foreach (array_keys(expFile::listFlat($dest_dir.'/files',1,null,array(),$dest_dir.'/files/')) as $file) {
    //		$files[$mod][1][$file] = expFile::canCreate(BASE.'files/'.$file);
    //	}
}
expSession::set('dest_dir', $dest_dir);
expSession::set('files_data', $files);
$template = new template('importer', '_files_verifyFiles');
$template->assign('files_data', $files);
$template->output();
示例#3
0
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/** @define "BASE" "../../../../.." */
if (!defined('EXPONENT')) {
    exit('');
}
$template = new template("importer", "_usercsv_form_start");
if (expFile::canCreate(BASE . "framework/modules-1/importer/importers/usercsv/tmp/test") != SYS_FILES_SUCCESS) {
    $template->assign("error", "The modules/importer/importers/usercsv/tmp directory is not writable.  Please contact your administrator.");
    $template->output();
} else {
    //Setup the mete data (hidden values)
    $form = new form();
    $form->meta("module", "importer");
    $form->meta("action", "page");
    $form->meta("page", "mapper");
    $form->meta("importer", "usercsv");
    //Setup the arrays with the name/value pairs for the dropdown menus
    $delimiterArray = array(',' => gt('Comma'), ';' => gt('Semicolon'), ':' => gt('Colon'), ' ' => gt('Space'));
    //Register the dropdown menus
    $form->register("delimiter", gt('Delimiter Character'), new dropdowncontrol(",", $delimiterArray));
    $form->register("upload", gt('CSV File to Upload'), new uploadcontrol());
    $form->register("rowstart", gt('Row to Begin at'), new textcontrol("1", 1, 0, 6));