Skip to content

Commit

Permalink
removed rex_is_writable(), _rex_is_writable_info(), _rex_is_writable()
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Apr 29, 2012
1 parent 5d0fefb commit 1cdffea
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,78 @@ function rex_absPath($rel_path, $rel_to_current = false)
{
return rex_path::absolute($rel_path, $rel_to_current);
}

/**
* @deprecated 5.0
*/
function rex_is_writable($item)
{
return _rex_is_writable_info(_rex_is_writable($item), $item);
}

/**
* @deprecated 5.0
*/
function _rex_is_writable_info($is_writable, $item = '')
{
$state = true;
$key = '';
switch($is_writable)
{
case 1:
{
$key = 'setup_012';
break;
}
case 2:
{
$key = 'setup_014';
break;
}
case 3:
{
$key = 'setup_015';
break;
}
}

if($key != '')
{
$file = '';
if($item != '')
$file = '<b>'. $item .'</b>';

$state = rex_i18n::msg($key, '<span class="rex-error">', '</span>', rex_path::absolute($file));
}

return $state;
}

/**
* @deprecated 5.0
*/
function _rex_is_writable($item)
{
// Fehler unterdrücken, falls keine Berechtigung
if (@ is_dir($item))
{
if (!@ is_writable($item . '/.'))
{
return 1;
}
}
// Fehler unterdrücken, falls keine Berechtigung
elseif (@ is_file($item))
{
if (!@ is_writable($item))
{
return 2;
}
}
else
{
return 3;
}

return 0;
}
73 changes: 0 additions & 73 deletions redaxo/src/core/functions/function_rex_other.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,6 @@ function rex_deleteCache()
return rex_extension::registerPoint('CACHE_DELETED', rex_i18n::msg('delete_cache_message'));
}

/**
* Prüfen ob ein/e Datei/Ordner beschreibbar ist
*
* @access public
* @param string $item Datei oder Verzeichnis
* @return mixed true bei Erfolg, sonst Fehlermeldung
*/
function rex_is_writable($item)
{
return _rex_is_writable_info(_rex_is_writable($item), $item);
}

function _rex_is_writable_info($is_writable, $item = '')
{
$state = true;
$key = '';
switch($is_writable)
{
case 1:
{
$key = 'setup_012';
break;
}
case 2:
{
$key = 'setup_014';
break;
}
case 3:
{
$key = 'setup_015';
break;
}
}

if($key != '')
{
$file = '';
if($item != '')
$file = '<b>'. $item .'</b>';

$state = rex_i18n::msg($key, '<span class="rex-error">', '</span>', rex_path::absolute($file));
}

return $state;
}

function _rex_is_writable($item)
{
// Fehler unterdrücken, falls keine Berechtigung
if (@ is_dir($item))
{
if (!@ is_writable($item . '/.'))
{
return 1;
}
}
// Fehler unterdrücken, falls keine Berechtigung
elseif (@ is_file($item))
{
if (!@ is_writable($item))
{
return 2;
}
}
else
{
return 3;
}

return 0;
}

function rex_ini_get($val)
{
$val = trim(ini_get($val));
Expand Down
8 changes: 5 additions & 3 deletions redaxo/src/core/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ setup_step1 = Setup: Schritt 1 von 5
setup_010 = Die PHP-Version des Servers ist veraltet ({0}), bitte aktualisieren Sie auf eine höhere Version (mindestens {1}, neueste empfohlen)
setup_010_1 = Die benötigte PHP-Extension <strong>{0}</strong> wurde nicht gefunden!
setup_011 = {0}Fehler{1} | Benötigte System-Addons fehlen
setup_012 = {0}Fehler{1} | Das Verzeichnis {2} ist weder beschreibar noch ausführbar!
setup_014 = {0}Fehler{1} | Die Datei {2} ist nicht beschreibbar!
setup_015 = {0}Fehler{1} | Die aufgelisteten Dateien und/oder Verzeichnisse existieren nicht oder es besteht keine Schreibberechtigung. {2} Bitte korrigieren Sie dies und starten das Setup erneut.
setup_012 = {0}Fehler{1} | Das Verzeichnis ist weder beschreibar noch ausführbar!
setup_014 = {0}Fehler{1} | Die Datei ist nicht beschreibbar!
setup_015 = {0}Fehler{1} | Die aufgelisteten Dateien und/oder Verzeichnisse existieren nicht oder es besteht keine Schreibberechtigung. Bitte korrigieren Sie dies und starten das Setup erneut.
setup_016 = {0}PHP-Versionscheck | Rechteüberprüfung{1}
setup_016_1 = <ul{0}><li>PHP-Version {1}ok{2}</li><li>Ordnerrechte {1}ok{2}</li></ul>
setup_017 = Weiter mit Schritt 2
Expand Down Expand Up @@ -201,6 +201,7 @@ addon_caption = Liste der verfügbaren AddOns
addon_summary = Auflistung aller AddOns
addon_systemaddon = System AddOn
addon_systempackage_delete_not_allowed = System AddOns dürfen nicht gelöscht werden!
addon_dir_not_writable = Der AddOn-Ordner hat keine Schreibrechte!
addon_install_cant_copy_files = Fehler beim Kopieren des /assets Ordners!
addon_install_cant_delete_files = Fehler beim Löschen des /assets Ordners!
addon_requirement_error_redaxo_exact_version = Die REDAXO-Version ({1}) entspricht nicht der geforderten Version ({0})!
Expand Down Expand Up @@ -238,6 +239,7 @@ plugin_install_cant_copy_files = Fehler beim Kopieren des /assets Ordners!
plugin_install_cant_delete_files = Fehler beim Löschen des /assets Ordners!
plugin_systemplugin = System PlugIn
plugin_systempackage_delete_not_allowed = System PlugIns dürfen nicht gelöscht werden!
plugin_dir_not_writable = Der PlugIn-Ordner hat keine Schreibrechte!

# redaxo\include\pages\credits.inc.php
credits = Credits
Expand Down
10 changes: 8 additions & 2 deletions redaxo/src/core/lib/packages/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,16 @@ public function install($installDump = TRUE)

// Pruefen des Addon Ornders auf Schreibrechte,
// damit das Addon spaeter wieder geloescht werden kann
$state = rex_is_writable($install_dir);
if(!rex_dir::isWritable($install_dir))
{
$state = $this->I18N('dir_not_writable', $install_dir);
}

// check if requirements are met
$state = $state && $this->checkRequirements();
if($state === TRUE)
{
$state = $this->checkRequirements();
}

$this->package->setProperty('install', true);

Expand Down
12 changes: 12 additions & 0 deletions redaxo/src/core/lib/util/dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ static public function create($dir, $recursive = true)
return false;
}

/**
* Returns wether the directory is writable
*
* @param string $dir Path of the directory
* @return boolean
*/
static public function isWritable($dir)
{
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
return @is_dir($dir) && @is_writable($dir .DIRECTORY_SEPARATOR .'.');
}

/**
* Copies a directory
*
Expand Down
51 changes: 28 additions & 23 deletions redaxo/src/core/pages/setup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,6 @@ function rex_setup_import($import_sql, $import_archiv = null)
return $err_msg;
}

function rex_setup_is_writable($items)
{
$res = array();

foreach($items as $item)
{
$is_writable = _rex_is_writable($item);

// 0 => kein Fehler
if($is_writable != 0)
{
$res[$is_writable][] = $item;
}
}

return $res;
}

// -------------------------- System AddOns prüfen
function rex_setup_addons($uninstallBefore = false, $installDump = true)
{
Expand Down Expand Up @@ -294,19 +276,42 @@ function rex_setup_addons($uninstallBefore = false, $installDump = true)

foreach(rex::getProperty('system_addons') as $system_addon)
{
if(strpos($system_addon, '/') === false)
$WRITEABLES[] = rex_path::addon($system_addon);
$WRITEABLES[] = rex_path::addon($system_addon);
}

$res = array();
foreach($WRITEABLES as $item)
{
// Fehler unterdrücken, falls keine Berechtigung
if(@is_dir($item))
{
if(!@is_writable($item . '/.'))
{
$res['setup_012'][] = $item;
}
}
// Fehler unterdrücken, falls keine Berechtigung
elseif(@is_file($item))
{
if(!@is_writable($item))
{
$res['setup_014'][] = $item;
}
}
else
{
$res['setup_015'][] = $item;
}
}

$res = rex_setup_is_writable($WRITEABLES);
if(count($res) > 0)
{
$MSG['err'] .= '<li>';
foreach($res as $type => $messages)
foreach($res as $key => $messages)
{
if(count($messages) > 0)
{
$MSG['err'] .= '<h3 class="rex-hl3">'. _rex_is_writable_info($type) .'</h3>';
$MSG['err'] .= '<h3 class="rex-hl3">'.rex_i18n::msg($key, '<span class="rex-error">', '</span>') .'</h3>';
$MSG['err'] .= '<ul>';
foreach($messages as $message)
{
Expand Down

0 comments on commit 1cdffea

Please sign in to comment.