Несколько полезностей, если хостинг не торт.
И снова, здравствуйте.
Иногда бывает так, что клиентский хостиг – грабли на костылях. Что же делать, когда нету ни SSH, ни нормальной контрольной панели? А есть только FTP.Здесь нам на помощь приходит чистый PHP.
Итак:
- UNZIP. Залили по фтп архив с MODx и извлекли.
<?php require_once('pclzip.lib.php'); $archive = new PclZip('modx-1.0.6.zip'); if ($archive->extract() == 0) { die("Error : ".$archive->errorInfo(true)); }else{ echo 'ok'; } ?>
Внимание: Для работы нужна библиотека pclzip.lib.php
- DELETE. Удаляем папку modx-1.0.6 рекурсивно от имени www-data.
<?php function deltree($folder) { if (is_dir($folder)) { $handle = opendir($folder); while ($subfile = readdir($handle)) { if ($subfile == '.' or $subfile == '..') continue; if (is_file($subfile)) @unlink("{$folder}/{$subfile}"); else deltree("{$folder}/{$subfile}"); } @closedir($handle); if (@rmdir($folder)) return true; else return false; } else { if (@unlink($folder)) return true; else return false; } return false; } deltree(modx-1.0.6); ?>
- CHMOD. Обычно в этом нуждается директория assets:. Рекурсивно меняем права.
<?php function chmod_r($path, $filemode, $dirmode) { if (is_dir($path) ) { if (!chmod($path, $dirmode)) { $dirmode_str=decoct($dirmode); print "Failed applying filemode '$dirmode_str' on directory '$path'\n"; print " `-> the directory '$path' will be skipped from recursive chmod\n"; return; } $dh = opendir($path); while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; chmod_R($fullpath, $filemode,$dirmode); } } closedir($dh); } else { if (is_link($path)) { print "link '$path' is skipped\n"; return; } if (!chmod($path, $filemode)) { $filemode_str=decoct($filemode); print "Failed applying filemode '$filemode_str' on file '$path'\n"; return; } } } chmod_r("assets", 0777, 0777); ?>