Exemplo n.º 1
0
 /**
  * checks permissions of all required filesystem resources.
  *
  * @return array An array of error messages
  */
 public static function checkFilesystem()
 {
     // -------------------------- SCHREIBRECHTE
     $writables = [rex_path::media(), rex_path::assets(), rex_path::cache(), rex_path::data(), rex_path::src()];
     $func = function ($dir) use(&$func) {
         if (!rex_dir::isWritable($dir)) {
             return ['setup_304' => [$dir]];
         }
         $res = [];
         foreach (rex_finder::factory($dir) as $path => $file) {
             if ($file->isDir()) {
                 $res = array_merge_recursive($res, $func($path));
             } elseif (!$file->isWritable()) {
                 $res['setup_305'][] = $path;
             }
         }
         return $res;
     };
     $res = [];
     foreach ($writables as $dir) {
         if (@is_dir($dir)) {
             $res = array_merge_recursive($res, $func($dir));
         } else {
             $res['setup_306'][] = $dir;
         }
     }
     return $res;
 }
Exemplo n.º 2
0
 /**
  * Installs a package.
  *
  * @param bool $installDump When TRUE, the sql dump will be importet
  *
  * @throws rex_functional_exception
  *
  * @return bool TRUE on success, FALSE on error
  */
 public function install($installDump = true)
 {
     try {
         // check package directory perms
         $install_dir = $this->package->getPath();
         if (!rex_dir::isWritable($install_dir)) {
             throw new rex_functional_exception($this->i18n('dir_not_writable', $install_dir));
         }
         // check package.yml
         $packageFile = $this->package->getPath(rex_package::FILE_PACKAGE);
         if (!is_readable($packageFile)) {
             throw new rex_functional_exception($this->i18n('missing_yml_file'));
         }
         try {
             rex_file::getConfig($packageFile);
         } catch (rex_yaml_parse_exception $e) {
             throw new rex_functional_exception($this->i18n('invalid_yml_file') . ' ' . $e->getMessage());
         }
         $packageId = $this->package->getProperty('package');
         if ($packageId === null) {
             throw new rex_functional_exception($this->i18n('missing_id', $this->package->getPackageId()));
         }
         if ($packageId != $this->package->getPackageId()) {
             $parts = explode('/', $packageId, 2);
             throw new rex_functional_exception($this->wrongPackageId($parts[0], isset($parts[1]) ? $parts[1] : null));
         }
         if ($this->package->getVersion() === null) {
             throw new rex_functional_exception($this->i18n('missing_version'));
         }
         // check requirements and conflicts
         $message = '';
         if (!$this->checkRequirements()) {
             $message = $this->message;
         }
         if (!$this->checkConflicts()) {
             $message .= $this->message;
         }
         if ($message) {
             throw new rex_functional_exception($message);
         }
         $reinstall = $this->package->getProperty('install');
         $available = $this->package->isAvailable();
         $this->package->setProperty('install', true);
         // include install.php
         if (is_readable($this->package->getPath(rex_package::FILE_INSTALL))) {
             if (!$available) {
                 rex_autoload::addDirectory($this->package->getPath('lib'));
                 rex_autoload::addDirectory($this->package->getPath('vendor'));
                 rex_i18n::addDirectory($this->package->getPath('lang'));
             }
             $this->package->includeFile(rex_package::FILE_INSTALL);
             if (($instmsg = $this->package->getProperty('installmsg', '')) != '') {
                 throw new rex_functional_exception($instmsg);
             }
             if (!$this->package->isInstalled()) {
                 throw new rex_functional_exception($this->i18n('no_reason'));
             }
         }
         // import install.sql
         $installSql = $this->package->getPath(rex_package::FILE_INSTALL_SQL);
         if ($installDump === true && is_readable($installSql)) {
             rex_sql_util::importDump($installSql);
         }
         if (!$reinstall) {
             $this->package->setProperty('status', true);
         }
         $this->saveConfig();
         if ($this->generatePackageOrder) {
             self::generatePackageOrder();
         }
         // copy assets
         $assets = $this->package->getPath('assets');
         if (is_dir($assets)) {
             if (!rex_dir::copy($assets, $this->package->getAssetsPath())) {
                 throw new rex_functional_exception($this->i18n('install_cant_copy_files'));
             }
         }
         $this->message = $this->i18n($reinstall ? 'reinstalled' : 'installed', $this->package->getName());
         return true;
     } catch (rex_functional_exception $e) {
         $this->message = $e->getMessage();
     } catch (rex_sql_exception $e) {
         $this->message = 'SQL error: ' . $e->getMessage();
     }
     $this->package->setProperty('install', false);
     $this->message = $this->i18n('no_install', $this->package->getName()) . '<br />' . $this->message;
     return false;
 }
Exemplo n.º 3
0
 /**
  * Copies a file
  *
  * @param string $srcfile Path of the source file
  * @param string $dstfile Path of the destination file or directory
  * @return boolean TRUE on success, FALSE on failure
  */
 public static function copy($srcfile, $dstfile)
 {
     global $REX;
     if (is_file($srcfile)) {
         if (is_dir($dstfile)) {
             $dstdir = rtrim($dstfile, DIRECTORY_SEPARATOR);
             $dstfile = $dstdir . DIRECTORY_SEPARATOR . basename($srcfile);
         } else {
             $dstdir = dirname($dstfile);
         }
         if (rex_dir::isWritable($dstdir) && (!file_exists($dstfile) || is_writable($dstfile)) && copy($srcfile, $dstfile)) {
             touch($dstfile, filemtime($srcfile));
             @chmod($dstfile, $REX['FILEPERM']);
             self::invalidateCache($dstfile);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Copies a file.
  *
  * @param string $srcfile Path of the source file
  * @param string $dstfile Path of the destination file or directory
  *
  * @return bool TRUE on success, FALSE on failure
  */
 public static function copy($srcfile, $dstfile)
 {
     if (is_file($srcfile)) {
         if (is_dir($dstfile)) {
             $dstdir = rtrim($dstfile, DIRECTORY_SEPARATOR);
             $dstfile = $dstdir . DIRECTORY_SEPARATOR . basename($srcfile);
         } else {
             $dstdir = dirname($dstfile);
             rex_dir::create($dstdir);
         }
         if (rex_dir::isWritable($dstdir) && (!file_exists($dstfile) || is_writable($dstfile)) && copy($srcfile, $dstfile)) {
             touch($dstfile, filemtime($srcfile));
             @chmod($dstfile, rex::getFilePerm());
             return true;
         }
     }
     return false;
 }
Exemplo n.º 5
0
            $form_tmp .= "\n" . '<div class="' . $form_field_wrp . ' ' . $warnblock["el_" . $i] . '"><label ' . $warning["el_" . $i] . ' for="FORM[' . $form_ID . '][el_' . $i . ']" >' . $element[1] . $req . '</label>' . "\n";
            $form_tmp .= '<input type="file" name="FORM[' . $form_ID . '][el_' . $i . ']" id="FORM[' . $form_ID . '][el_' . $i . ']" /></div>' . "\n";
            $formoutput[] = $form_tmp;
            $form_enctype = 'enctype="multipart/form-data"';
            break;
    }
}
// pruefe Pfad auf Vorhandensein und Schreibrechte, Wenn Pfad nicht vorhanden, ignoriere die weitere Verarbeitung.
if (isset($form_upload_folder) and $form_upload_folder != '' and rex::isBackend()) {
    // ... dum die dum ... Pfadpruefung erfolgt hier ...beginnt der Uploadpfad nicht mit einem Slash, muss es sich um einen lokalen Ordner handeln der vom Backend aus erweitert werden muss
    if (substr($form_upload_folder, 0, 1) != '/') {
        $form_upload_folder_tmp = '../' . $form_upload_folder;
    } else {
        $form_upload_folder_tmp = $form_upload_folder;
    }
    if (rex_dir::isWritable($form_upload_folder_tmp) !== true) {
        echo rex_view::warning('Der Uploadpfad "' . $form_upload_folder_tmp . '" ist nicht beschreibbar.<br />
                      Pruefe die Schreibrechte oder lasse die Angaben zum Uploadordner leer, wenn kein Uploadfeld genutzt wird.');
    }
}
// =================AUSGABE-KOPF============================
$out = '
   
   <form class="' . $form_tag_class . '" id="' . $form_ID . '" action="' . rex_getUrl(REX_ARTICLE_ID) . '#doformREX_SLICE_ID" accept-charset="UTF-8" method="post" ' . $form_enctype . '>
      <div><input type="hidden" name="FORM[' . $form_ID . '][' . $form_ID . 'send]" value="1" /><input type="hidden" name="ctype" value="ctype" /></div>
      <input type="hidden" name="token" value="' . $token . '" />';
// =================Formular-generieren=====================
foreach ($formoutput as $fields) {
    $out .= $fields;
}
// =================AUSGABE-FUSS============================